1) Do some rename refactor ,prepare for LLMProcess refactor
2) Fix merge bugs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import copy
|
||||
|
||||
from aios.agent.agent_base import CustomAIAgent, AgentPrompt
|
||||
from aios.agent.agent_base import CustomAIAgent, LLMPrompt
|
||||
from aios.knowledge.data.writer import split_text
|
||||
from aios.proto.agent_msg import AgentMsg, AgentMsgType
|
||||
from aios.proto.compute_task import ComputeTaskResultCode
|
||||
@@ -19,10 +19,10 @@ class TextSummaryAgent(CustomAIAgent):
|
||||
|
||||
chunks = split_text(msg.body, separators=["\n\n", "\n"], chunk_size=4000, chunk_overlap=200, length_function=len)
|
||||
|
||||
prompt = AgentPrompt()
|
||||
prompt.system_message = {"role":"system","content":"Your job is to generate a summary based on the input."}
|
||||
prompt = LLMPrompt()
|
||||
prompt.system_message = "Your job is to generate a summary based on the input."
|
||||
if len(chunks) == 1:
|
||||
prompt.append(AgentPrompt(chunks[0]))
|
||||
prompt.append(LLMPrompt(chunks[0]))
|
||||
resp = await self.do_llm_complection(prompt)
|
||||
if resp.result_code != ComputeTaskResultCode.OK:
|
||||
return msg.create_error_resp(resp.error_str)
|
||||
@@ -31,14 +31,14 @@ class TextSummaryAgent(CustomAIAgent):
|
||||
segments = []
|
||||
for i, chunk in enumerate(chunks):
|
||||
seg_prompt = copy.deepcopy(prompt)
|
||||
seg_prompt.append(AgentPrompt(chunk))
|
||||
seg_prompt.append(LLMPrompt(chunk))
|
||||
resp = await self.do_llm_complection(seg_prompt)
|
||||
if resp.result_code != ComputeTaskResultCode.OK:
|
||||
return msg.create_error_resp(resp.error_str)
|
||||
segments.append(resp.result_str)
|
||||
|
||||
segments_str = "\n".join(segments)
|
||||
prompt.append(AgentPrompt(f"以下文本分段之后的各段摘要,请合并生成一个完整摘要:\n{segments_str}"))
|
||||
prompt.append(LLMPrompt(f"以下文本分段之后的各段摘要,请合并生成一个完整摘要:\n{segments_str}"))
|
||||
resp = await self.do_llm_complection(prompt)
|
||||
if resp.result_code != ComputeTaskResultCode.OK:
|
||||
return msg.create_error_resp(resp.error_str)
|
||||
|
||||
Reference in New Issue
Block a user