Fix story maker bug
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
instance_id = "fairy_tale_writer"
|
||||
fullname = "tracy wang"
|
||||
llm_model_name = "gpt-3.5-turbo-16k-0613"
|
||||
enable_function = []
|
||||
|
||||
[[prompt]]
|
||||
role = "system"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
instance_id = "agent:xxxxxxabcde"
|
||||
fullname = "musk"
|
||||
enable_function = []
|
||||
|
||||
[[prompt]]
|
||||
role = "system"
|
||||
content = "你有丰富的管理技能,擅长将复杂工作拆解成简单的任务,让团队成员高效协作。"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
instance_id = "studio_director"
|
||||
fullname = "tracy wang"
|
||||
llm_model_name = "gpt-3.5-turbo-16k-0613"
|
||||
enable_function = ["text_to_speech"]
|
||||
|
||||
[[prompt]]
|
||||
role = "system"
|
||||
content = "你是一个演播导演,请将下面故事改编成朗读剧本,提取旁白和角色台词,每个角色需要有性别、年龄、以及每句台词的语气。并调用text_to_speech function生成音频数据。"
|
||||
content = "你是一个故事播音员,请将下面故事改编成播音剧本,提取旁白和角色台词,以及每个角色需要有性别、年龄、以及每句台词的语气,最后生成音频文件。"
|
||||
|
||||
@@ -8,10 +8,12 @@ name = "story_maker"
|
||||
name = "manager"
|
||||
fullname = "总导演"
|
||||
agent="manager"
|
||||
enable_function = []
|
||||
|
||||
[[roles.manager.prompt]]
|
||||
role="system"
|
||||
content="""
|
||||
你是一个语音故事制作总导演,与客户对接并向团队下达指令。你的团队分为下面几个成员:writer,studio_director。一个故事制作分成两个阶段:让writer写出故事,再交由studio_director演播故事。你的基本工作模式是:
|
||||
你是一个语音故事制作总导演,与客户对接并向团队下达指令。你的团队分为下面几个成员:writer,studio_director。一个故事制作分成两个阶段:让writer写出故事,再交由studio_director演播故事生成音频文件。你的基本工作模式是:
|
||||
1. 收到客户的明确的指令后,让writer写出故事
|
||||
2. 将writer写出的故事交给studio_director演播
|
||||
3. 当你决定要和成员通信时,请使用下面形式输出需要通信的消息
|
||||
@@ -25,6 +27,7 @@ content="""
|
||||
name = "writer"
|
||||
agent = "fairy_tale_writer"
|
||||
fullname = "作家"
|
||||
enable_function = []
|
||||
[[roles.writer.prompt]]
|
||||
role="system"
|
||||
content=""
|
||||
@@ -32,6 +35,7 @@ content=""
|
||||
[roles.studio_director]
|
||||
name = "studio_director"
|
||||
agent = "studio_director"
|
||||
enable_function = ["text_to_speech"]
|
||||
[[roles.studio_director.prompt]]
|
||||
role="system"
|
||||
content=""
|
||||
|
||||
@@ -288,12 +288,13 @@ class AIAgent:
|
||||
result_len = 0
|
||||
for inner_func in all_inner_function:
|
||||
func_name = inner_func.get_name()
|
||||
if self.enable_function_list:
|
||||
if self.enable_function_list is not None:
|
||||
if len(self.enable_function_list) > 0:
|
||||
if func_name not in self.enable_function_list:
|
||||
logger.debug(f"ageint {self.agent_id} ignore inner func:{func_name}")
|
||||
continue
|
||||
|
||||
else:
|
||||
continue
|
||||
this_func = {}
|
||||
this_func["name"] = func_name
|
||||
this_func["description"] = inner_func.get_description()
|
||||
@@ -322,6 +323,7 @@ class AIAgent:
|
||||
logger.error(f"llm execute inner func:{func_name} error:{e}")
|
||||
|
||||
|
||||
logger.info("llm execute inner func result:" + result_str)
|
||||
inner_functions,inner_function_len = self._get_inner_functions()
|
||||
prompt.messages.append({"role":"function","content":result_str,"name":func_name})
|
||||
task_result:ComputeTaskResult = await ComputeKernel.get_instance().do_llm_completion(prompt,self.llm_model_name,self.max_token_size,inner_functions)
|
||||
|
||||
@@ -87,7 +87,7 @@ class AIBus:
|
||||
|
||||
await asyncio.sleep(0.2)
|
||||
retry_times += 1
|
||||
if retry_times > 5*120: # default timeout is 120 sec
|
||||
if retry_times > 5*240: # default timeout is 240 sec
|
||||
msg.status = AgentMsgStatus.ERROR
|
||||
return None
|
||||
|
||||
@@ -107,12 +107,14 @@ class AIBus:
|
||||
# Wait for a message
|
||||
message = await handler.queue.get()
|
||||
|
||||
#try:
|
||||
try:
|
||||
# Try to handle the message
|
||||
await handler.handle_message(message)
|
||||
#except Exception as e:
|
||||
await handler.handle_message(message)
|
||||
except Exception as e:
|
||||
# If an error occurs, put the message back into the queue
|
||||
# logger.error(f"handle message {message.msg_id} failed! {e}")
|
||||
logger.error(f"handle message {message.msg_id} failed! {e}")
|
||||
logger.exception(e)
|
||||
raise e
|
||||
#self.queues[name].put_nowait(message)
|
||||
|
||||
return
|
||||
|
||||
@@ -118,7 +118,7 @@ class ComputeKernel:
|
||||
if task_req.state == ComputeTaskState.ERROR:
|
||||
break
|
||||
|
||||
if check_times >= 20:
|
||||
if check_times >= 120:
|
||||
task_req.state = ComputeTaskState.ERROR
|
||||
break
|
||||
|
||||
@@ -129,7 +129,7 @@ class ComputeKernel:
|
||||
if task_req.state == ComputeTaskState.DONE:
|
||||
return task_req.result
|
||||
|
||||
return "error!"
|
||||
raise Exception("error!")
|
||||
|
||||
|
||||
def text_embedding(self,input:str,model_name:Optional[str] = None):
|
||||
|
||||
@@ -100,16 +100,16 @@ class OpenAI_ComputeNode(ComputeNode):
|
||||
if max_token_size is None:
|
||||
max_token_size = 4000
|
||||
|
||||
result_token = int(max_token_size * 0.4)
|
||||
|
||||
logger.info(f"call openai {mode_name} prompts: {prompts}")
|
||||
result_token = max_token_size
|
||||
|
||||
if llm_inner_functions is None:
|
||||
logger.info(f"call openai {mode_name} prompts: {prompts}")
|
||||
resp = openai.ChatCompletion.create(model=mode_name,
|
||||
messages=prompts,
|
||||
max_tokens=result_token,
|
||||
temperature=0.7)
|
||||
else:
|
||||
logger.info(f"call openai {mode_name} prompts: {prompts} functions: {json.dumps(llm_inner_functions)}")
|
||||
resp = openai.ChatCompletion.create(model=mode_name,
|
||||
messages=prompts,
|
||||
functions=llm_inner_functions,
|
||||
@@ -139,6 +139,7 @@ class OpenAI_ComputeNode(ComputeNode):
|
||||
result.result_message = resp["choices"][0]["message"]
|
||||
if token_usage:
|
||||
result.result_refers["token_usage"] = token_usage
|
||||
logger.info(f"openai success response: {result.result_str}")
|
||||
return result
|
||||
case _:
|
||||
task.state = ComputeTaskState.ERROR
|
||||
|
||||
@@ -83,9 +83,9 @@ class TextToSpeechFunction(AIFunction):
|
||||
continue
|
||||
|
||||
if audio is not None:
|
||||
path = os.path.join(os.curdir, "{}.mp3".format(random.sample('zyxwvutsrqponmlkjihgfedcba', 10)))
|
||||
path = os.path.join(os.path.realpath(os.curdir), "{}.mp3".format(''.join(random.sample('zyxwvutsrqponmlkjihgfedcba', 10))))
|
||||
audio.export(path, format="mp3")
|
||||
return "complete.file path:{}".format(path)
|
||||
return "已经生成音频文件, 文件路径为{}".format(path)
|
||||
else:
|
||||
return "failed"
|
||||
|
||||
|
||||
@@ -376,11 +376,13 @@ class Workflow:
|
||||
result_func = []
|
||||
for inner_func in all_inner_function:
|
||||
func_name = inner_func.get_name()
|
||||
if the_role.enable_function_list:
|
||||
if the_role.enable_function_list is not None:
|
||||
if len(the_role.enable_function_list) > 0:
|
||||
if func_name not in the_role.enable_function_list:
|
||||
logger.debug(f"ageint {self.agent_id} ignore inner func:{func_name}")
|
||||
logger.debug(f"agent {self.agent_id} ignore inner func:{func_name}")
|
||||
continue
|
||||
else:
|
||||
continue
|
||||
this_func = {}
|
||||
this_func["name"] = func_name
|
||||
this_func["description"] = inner_func.get_description()
|
||||
@@ -404,7 +406,7 @@ class Workflow:
|
||||
|
||||
result_str:str = await func_node.execute(**arguments)
|
||||
|
||||
inner_functions = self._get_inner_functions()
|
||||
inner_functions = self._get_inner_functions(the_role)
|
||||
prompt.messages.append({"role":"function","content":result_str,"name":func_name})
|
||||
task_result:ComputeTaskResult = await ComputeKernel.get_instance().do_llm_completion(prompt,
|
||||
the_role.agent.llm_model_name,the_role.agent.max_token_size,
|
||||
|
||||
Reference in New Issue
Block a user