Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
rollback: cancel concurrent request
Browse files Browse the repository at this point in the history
  • Loading branch information
ciuzaak committed May 12, 2023
1 parent 9ed5990 commit 1bc5cd3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async def recv_msg(update: Update, context: ContextTypes.DEFAULT_TYPE):
await reset_chat(update, context)

else: # Bard
response = await session.send_message(input_text)
response = session.client.ask(input_text)
# get source links
sources = ''
if response['factualityQueries']:
Expand Down Expand Up @@ -272,8 +272,8 @@ async def post_init(application: Application):

def run_bot():
print(f'[+] bot started, calling loop!')
application = ApplicationBuilder().token(bot_token).post_init(
post_init).concurrent_updates(True).build()
application = ApplicationBuilder().token(
bot_token).post_init(post_init).build()

user_filter = filters.Chat(chat_id=user_ids)
message_filter = filters.TEXT & ~filters.COMMAND
Expand Down
7 changes: 0 additions & 7 deletions utils/bard_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from asyncio import get_event_loop
from concurrent.futures import ThreadPoolExecutor

from Bard import Chatbot

from config import bard_api
Expand All @@ -14,7 +11,3 @@ def reset(self):
self.client.conversation_id = ''
self.client.response_id = ''
self.client.choice_id = ''

async def send_message(self, message):
with ThreadPoolExecutor() as executor:
return await get_event_loop().run_in_executor(executor, self.client.ask, message)

0 comments on commit 1bc5cd3

Please sign in to comment.