Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinsenal0x64 committed Jul 23, 2023
1 parent 2d44886 commit 72a3c0c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

load_dotenv(find_dotenv())

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
open_api = os.getenv("OPENAI_API_KEY")
telegram_token = os.getenv("TELEGRAM_TOKEN")
host_url = os.getenv("HOST_URL")
bard_token = os.getenv("BARD_TOKEN")
Expand Down Expand Up @@ -465,7 +465,8 @@ def search(message):
msg = bot.send_message(message.chat.id,
"🌀 Processing...",
reply_to_message_id=message.message_id)
prompt = message.text.replace('/search', '')

prompt = message.text.replace('/search', '').strip()

search = BraveSearch.from_api_key(api_key=brave_key,
search_kwargs={"count": 10})
Expand All @@ -477,7 +478,7 @@ def search(message):
"useful when you need to answer questions about current events"),
]

memory = ConversationBufferMemory(memory_key="chat_history",
memory = ConversationBufferMemory(openai_api_key=open_api,memory_key="chat_history",
return_messages=True)

llm = ChatOpenAI(temperature=0, model="gpt-3.5-turbo-16k")
Expand All @@ -491,8 +492,6 @@ def search(message):

output = agent_chain.run(input=prompt)

rich.print(output)

splitted_text = util.smart_split(output, chars_per_string=3000)
for text in splitted_text:
bot.send_message(message.from_user.id, text, parse_mode='Markdown')
Expand Down

0 comments on commit 72a3c0c

Please sign in to comment.