Files
autoMate/agent/programmer_agent.py
yuruo 2fc88263f0 (programmer_agent.py): 重构run方法以处理LLM_Util().invoke()的返回值
📝 (chat_list.py): 导入PythonExecute模块以支持代码执行功能,修改运行按钮布局
🔧 (chat_list.py): 重构run_button_clicked方法以支持更灵活的消息展示处理
🔧 (chat_list.py): 重构new_response方法,支持不同类型消息的展示
🔧 (chat_list.py): 重构stream_response方法以支持更灵活的消息流处理
🔧 (chat_list.py): 添加code_generate_before_signal和code_generate_after_signal信号
🔧 (chat_list.py): 重构code_generate_after方法以处理生成的代码展示方式
🔧 (chat_page.py): 删除未使用的delete_last_conversation方法
🔧 (chat_page.py): 删除未使用的run_button_clicked方法
2024-06-03 18:31:39 +08:00

27 lines
749 B
Python

from actions.action_util import ActionUtil
from agent.prompt import programmer_prompt
from self_utils.llm_util import LLM_Util
class ProgrammerAgent:
def __init__(self):
action_descriptions = ""
for action_class in ActionUtil.get_actions():
action = action_class()
action_descriptions += action.package_actions_description() + "\n"
self.messages = [{"content": programmer_prompt.substitute(python_code=action_descriptions), "role": "system"}]
self.content = ""
def run(self, question):
self.messages.append({"content": question, "role": "user"})
res = ""
for text in LLM_Util().invoke(self.messages):
res += text
return res