Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
suluyana committed Nov 25, 2024
1 parent 50d63af commit a221e9e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
7 changes: 6 additions & 1 deletion apps/agentfabric/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,16 @@ def preview_send_message(chatbot, input, _state, uuid_str, _user_token):

# get chat history from memory
history = user_memory.get_history()
# skip
filtered_files = [
item for item in append_files
if not item.lower().endswith(('.jpeg', '.png', '.jpg', '.wav', '.gif', '.mp3'))
]

use_llm = True if len(user_agent.function_list) else False
ref_doc = user_memory.run(
query=input.text,
url=append_files,
url=filtered_files,
max_token=4000,
top_k=2,
checked=True,
Expand Down
8 changes: 7 additions & 1 deletion apps/agentfabric/appBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,15 @@ def send_message(chatbot, input, _state, _user_token):
# get short term memory history
history = user_memory.get_history()

# skip
filtered_files = [
item for item in append_files
if not item.lower().endswith(('.jpeg', '.png', '.jpg', '.wav', '.gif', '.mp3'))
]

use_llm = True if len(user_agent.function_list) else False
ref_doc = user_memory.run(
query=input.text, url=append_files, checked=True, use_llm=use_llm)
query=input.text, url=filtered_files, checked=True, use_llm=use_llm)

response = ''
try:
Expand Down
4 changes: 2 additions & 2 deletions apps/agentfabric/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,10 @@ def generate():
f'load history method: time consumed {time.time() - start_time}'
)

# skip image upsert
# skip
filtered_files = [
item for item in file_paths
if not item.lower().endswith(('.jpeg', '.png', '.jpg'))
if not item.lower().endswith(('.jpeg', '.png', '.jpg', '.wav', '.gif', '.mp3'))
]

use_llm = True if len(user_agent.function_list) else False
Expand Down
7 changes: 3 additions & 4 deletions modelscope_agent/agents/multi_role_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Action: 工具的名称,必须是[{tool_names}]之一
Action Input: 工具的输入
Observation: <result>工具返回的结果</result>
Answer: 根据Observation总结本次工具调用返回的结果,如果结果中出现url,请使用如下格式展示出来:![图片](url)
Answer: 根据Observation总结本次工具调用返回的结果
"""

Expand Down Expand Up @@ -59,10 +59,9 @@
Action: The name of the tool, must be one of [{tool_names}]
Action Input: Tool input
Observation: <result>Tool returns result</result>
Answer: Summarize the results of this tool call based on Observation. If the result contains url, %s
Answer: Summarize the results of this tool call based on Observation.
""" % ('You can call zero or more times according to your needs:',
'please display it in the following format:![Image](URL)')
""" % ('You can call zero or more times according to your needs:')

PROMPT_TEMPLATE_EN = """{role_prompt}"""

Expand Down
14 changes: 6 additions & 8 deletions modelscope_agent/llm/utils/function_call_with_raw_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Action: 工具的名称,必须是[{tool_names}]之一
Action Input: 工具的输入
Observation: <result>工具返回的结果</result>
Answer: 根据Observation总结本次工具调用返回的结果,如果结果中出现url,请使用如下格式展示出来:![图片](url)
Answer: 根据Observation总结本次工具调用返回的结果
"""

Expand All @@ -47,7 +47,7 @@
...
Observation: <result>工具N返回的结果</result>
Answer: 根据Observation总结本次工具调用返回的结果,如果结果中出现url,请使用如下格式展示出来:![图片](url)
Answer: 根据Observation总结本次工具调用返回的结果
"""

Expand All @@ -64,10 +64,9 @@
Action: The name of the tool, must be one of [{tool_names}]
Action Input: Tool input
Observation: <result>Tool returns result</result>
Answer: Summarize the results of this tool call based on Observation. If the result contains url, %s
Answer: Summarize the results of this tool call based on Observation.
""" % ('You can call zero or more times according to your needs:',
'please display it in the following format:![Image](URL)')
""" % ('You can call zero or more times according to your needs:')

TOOL_TEMPLATE_EN_PARALLEL = """
# Tools
Expand All @@ -90,10 +89,9 @@
Observation: <result>Tool 1 returns result</result>
...
Observation: <result>Tool N returns result</result>
Answer: Summarize the results of this tool call based on Observation. If the result contains url, %s
Answer: Summarize the results of this tool call based on Observation.
""" % ('You can call zero or more times according to your needs:',
'please display it in the following format:![Image](URL)')
""" % ('You can call zero or more times according to your needs:')

TOOL_TEMPLATE = {
'zh': TOOL_TEMPLATE_ZH,
Expand Down
2 changes: 1 addition & 1 deletion modelscope_agent/tools/utils/output_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def __init__(self, video, **kwargs) -> None:

self._raw_data = video

if self._path.endswith('.gif'):
if self._path.split('?')[0].endswith('.gif'):
self._repr = f'![IMAGEGEN]({self._path})'
else:
self._repr = f'<video src="{self._path}"/>'
Expand Down

0 comments on commit a221e9e

Please sign in to comment.