Added issue creation

This commit is contained in:
2024-08-19 14:30:17 -05:00
parent fcd558b4c6
commit e75f5c707e
3 changed files with 149 additions and 13 deletions
+8 -13
View File
@@ -9,8 +9,8 @@ class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
def __init__(self):
super().__init__()
self.client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
self.model = "gpt-4o-mini"
self.max_tokens = 16384
self.model = "gpt-4o"
self.max_tokens = 4096
def get_chat_response(self, messages):
response = self.client.chat.completions.create(
@@ -32,13 +32,12 @@ class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
response = self.get_chat_response(messages)
tool_calls = []
assistant_message = {}
for message_part in response.choices:
if message_part.finish_reason == "function_call":
tool_calls.append(message_part.message.function_call)
else:
assistant_message = response.choices[0].message
messages.append(response.choices[0].message)
tool_use_count = 0
while len(tool_calls) > 0 and tool_use_count < 50:
@@ -51,24 +50,20 @@ class ChatGPTTelegramInferenceBot(BaseTelegramInferenceBot):
messages.extend(tool_use_results)
response = self.get_chat_response(messages)
response = self.get_chat_response(messages)
for message_part in response.choices:
if message_part.finish_reason == "function_call":
tool_calls.append(message_part.message.function_call)
else:
assistant_message = response.choices[0].message
messages.append({"role": "assistant", "content": assistant_message.content})
messages.append(response.choices[0].message)
tool_use_count += 1
if tool_use_count == 0:
messages.append({"role": "assistant", "content": assistant_message.content})
if len(self.conversation_history[user_id]) > 20:
self.conversation_history[user_id] = self.conversation_history[user_id][-20:]
return messages[-1]["content"]
return messages[-1].content
async def start(self):
logging.info("Bot started")