From 9ebc193394a30835f1f5577b97d735ded75f4e46 Mon Sep 17 00:00:00 2001 From: "raoha.rh" Date: Wed, 4 Sep 2024 17:24:46 +0800 Subject: [PATCH 1/2] fix: bot builder --- server/agent/bot/bot_builder.py | 11 +++++------ server/agent/prompts/bot_builder.py | 5 ++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/agent/bot/bot_builder.py b/server/agent/bot/bot_builder.py index 42ea2169..054506d3 100644 --- a/server/agent/bot/bot_builder.py +++ b/server/agent/bot/bot_builder.py @@ -1,12 +1,11 @@ -from typing import AsyncIterator -from agent.bot.get_bot import Bot +from typing import AsyncIterator, Optional +from agent.llm.openai import OpenAIClient from petercat_utils.data_class import ChatData from agent.base import AgentBuilder from agent.prompts.bot_builder import generate_prompt_by_user_id from agent.tools import bot_builder - TOOL_MAPPING = { "create_bot": bot_builder.create_bot, "edit_bot": bot_builder.edit_bot, @@ -16,11 +15,11 @@ def agent_stream_chat( input_data: ChatData, user_id: str, - bot: Bot, + bot_id: str, ) -> AsyncIterator[str]: - prompt = generate_prompt_by_user_id(user_id, bot.id) + prompt = generate_prompt_by_user_id(user_id, bot_id) agent = AgentBuilder( - chat_model=bot.llm, + chat_model=OpenAIClient(), prompt=prompt, tools=TOOL_MAPPING, enable_tavily=False ) return agent.run_stream_chat(input_data) diff --git a/server/agent/prompts/bot_builder.py b/server/agent/prompts/bot_builder.py index 3bf09879..688987e6 100644 --- a/server/agent/prompts/bot_builder.py +++ b/server/agent/prompts/bot_builder.py @@ -1,3 +1,6 @@ +from typing import Optional + + CREATE_PROMPT = """ ## Role: You are a GitHub Answering Bot Creation Assistant. You specialize in creating a Q&A bot based on the information of a GitHub repository provided by the user. @@ -45,7 +48,7 @@ """ -def generate_prompt_by_user_id(user_id: str, bot_id: str): +def generate_prompt_by_user_id(user_id: str, bot_id: Optional[str]): if bot_id: return EDIT_PROMPT.format(bot_id=bot_id, user_id=user_id) else: From ad2f8f08fee698b85e01b1c00e6c2749ac9e6a25 Mon Sep 17 00:00:00 2001 From: "raoha.rh" Date: Wed, 4 Sep 2024 17:28:10 +0800 Subject: [PATCH 2/2] fix: bot builder --- server/agent/bot/bot_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/agent/bot/bot_builder.py b/server/agent/bot/bot_builder.py index 054506d3..6bd7a224 100644 --- a/server/agent/bot/bot_builder.py +++ b/server/agent/bot/bot_builder.py @@ -1,4 +1,4 @@ -from typing import AsyncIterator, Optional +from typing import AsyncIterator from agent.llm.openai import OpenAIClient from petercat_utils.data_class import ChatData