Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update discord_app.py #106

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions discord_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,35 @@ async def build_prompt_and_reply(executor, user_name, user_id):
break

prompt = await build_prompt(ppm, win_size=user_args["max-windows"])
prompt = async build_prompt(ppm, win_size=user_args["max_windows"])

if tgi_server_addr is None:
response = await loop.run_in_executor(executor, gen_method, prompt, user_args)
response = post.clean(response)
else:
response = await gen_method(prompt, user_args)

threads = []
import threading
def handle_request(request):]
response = f"**{model_name}** 💬\n{response.strip()}"
if len(response) >= max_response_length:
response = response[:max_response_length]
if other_job_on_progress is True:
await progress_msg.delete()
await msg.reply(response, mention_author=False)
except IndexError:
await msg.channel.send("Index error")
except HTTPException:
pass
pass
for request in requests:
t = threading.Thread(target=handle_request, args=(request,))
t.start()
threads.append(t)

response = f"**{model_name}** 💬\n{response.strip()}"
if len(response) >= max_response_length:
response = response[:max_response_length]

if other_job_on_progress is True:
await progress_msg.delete()

for t in threads:
t.join()
await msg.reply(response, mention_author=False)
except IndexError:
await msg.channel.send("Index error")
Expand Down