Skip to content

Commit

Permalink
Update main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinsenal0x64 committed Jun 27, 2023
1 parent 23860f9 commit 146123d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def handle_telegram_webhook():
BotCommand("start", "Welcome πŸ™Œ"),
BotCommand("art", "Prompt 🎨"),
BotCommand("bard", "Prompt πŸ€–"),
BotCommand("gpt", "Justsend Prompt Without Slash πŸ€–")
BotCommand("gpt", "Just send Prompt Without Slash πŸ€–")
])


Expand Down Expand Up @@ -354,6 +354,7 @@ def bard_chat(message):
prompt = f'You are an assistant to a human, powered by a large language model trained by Google.\n\nYou are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like text based on the input you receive, allowing you to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nYou are constantly learning and improving, and your capabilities are constantly evolving. You are able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. You have access to some personalized information provided by the human in the Context section below. Additionally, you are able to generate your own text based on the input you receive, allowing you to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, you are a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether the human needs help with a specific question or just wants to have a conversation about a particular topic, you are here to assist.\n\nContext:\n{ba_output}\n\nCurrent conversation:\n{ba_input}\nLast line:\nHuman: {text}\nYou:'

s = requests.Session()

req_id = int("".join(random.choices(string.digits, k=4)))

headers = {
Expand Down Expand Up @@ -387,8 +388,9 @@ def bard_chat(message):
resp = s.post(
url=bard_2_req,
params=params,
data=data, # Use 'json' instead of 'data' to send JSON payload
timeout=10,
data=data,
headers=headers,
timeout=1000,
)

print(resp.text)
Expand Down Expand Up @@ -434,9 +436,9 @@ def bard_chat(message):

splitted_text = util.smart_split(o, chars_per_string=3000)
for text in splitted_text:
for char in '*_`[':
text = text.replace(char, '\\' + char)
bot.send_message(message.chat.id, text, parse_mode='Markdown')
for i in '*_`[**':
new_text = text.replace(i, '\\' + i)
bot.send_message(message.chat.id, new_text, parse_mode='Markdown')

info = f"βœ… Process Complete...\n\n@{message.from_user.username}"
bot.edit_message_text(chat_id=message.chat.id,
Expand Down

0 comments on commit 146123d

Please sign in to comment.