Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
userpj committed Nov 25, 2024
1 parent a96b1b2 commit f48c450
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 deletions cookbooks/end2end_application/agent/tool_call.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -754,7 +754,7 @@
}
],
"source": [
"print(json.dumps(appbuilder.Manifest.from_function(get_current_weather).model_dump(), indent=4, ensure_ascii=False))"
"print(json.dumps(appbuilder.Manifest.from_function(get_current_weather), indent=4, ensure_ascii=False))"
]
},
{
Expand All @@ -766,7 +766,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand All @@ -788,7 +788,7 @@
"msg = client.run(\n",
" conversation_id=conversation_id,\n",
" query=\"今天北京的天气怎么样?\",\n",
" tools = [appbuilder.Manifest.from_function(f).model_dump() for f in functions]\n",
" tools = [appbuilder.Manifest.from_function(f) for f in functions]\n",
" )\n",
"print(msg.model_dump_json(indent=4))\n",
"# 获取最后的事件和工具调用信息\n",
Expand Down Expand Up @@ -925,7 +925,7 @@
"# 将 model_dump() 的输出进行格式化打印\n",
"print(\n",
" json.dumps(\n",
" appbuilder.Manifest.from_function(get_current_weather).model_dump(), indent=4, ensure_ascii=False\n",
" appbuilder.Manifest.from_function(get_current_weather), indent=4, ensure_ascii=False\n",
" )\n",
")"
]
Expand Down Expand Up @@ -954,7 +954,7 @@
"msg = client.run(\n",
" conversation_id=conversation_id,\n",
" query=\"今天北京的天气怎么样?\",\n",
" tools=[appbuilder.Manifest.from_function(get_current_weather).model_dump()],\n",
" tools=[appbuilder.Manifest.from_function(get_current_weather)],\n",
")\n",
"print(msg.model_dump_json(indent=4))\n",
"# 获取最后的事件和工具调用信息\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/BasisModule/Platform/Application/appbuilder_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ function_map = {f.__name__: f for f in functions}
msg = client.run(
conversation_id=conversation_id,
query="今天北京的天气怎么样?",
tools = [appbuilder.Manifest.from_function(f).model_dump() for f in functions]
tools = [appbuilder.Manifest.from_function(f) for f in functions]
)
print(msg.model_dump_json(indent=4))
# 获取最后的事件和工具调用信息
Expand Down Expand Up @@ -373,15 +373,15 @@ conversation_id = client.create_conversation()
def get_current_weather(location: str, unit: str) -> str:
return "北京今天25度"

print(json.dumps(appbuilder.Manifest.from_function(get_current_weather).model_dump(), indent=4, ensure_ascii=False))
print(json.dumps(appbuilder.Manifest.from_function(get_current_weather), indent=4, ensure_ascii=False))
#定义函数列表
functions = [get_current_weather]
function_map = {f.__name__: f for f in functions}
#调用大模型
msg = client.run(
conversation_id=conversation_id,
query="今天北京的天气怎么样?",
tools = [appbuilder.Manifest.from_function(f).model_dump() for f in functions]
tools = [appbuilder.Manifest.from_function(f) for f in functions]
)
print(msg.model_dump_json(indent=4))
# 获取最后的事件和工具调用信息
Expand Down
3 changes: 2 additions & 1 deletion python/core/console/appbuilder_client/appbuilder_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import queue
from typing import Optional
from appbuilder.core.component import Message, Component
from appbuilder.core.manifest.models import Manifest
from appbuilder.core.console.appbuilder_client import data_class
from appbuilder.core._exception import AppBuilderServerException
from appbuilder.utils.sse_util import SSEClient
Expand Down Expand Up @@ -250,7 +251,7 @@ def run(self, conversation_id: str,
query: str = "",
file_ids: list = [],
stream: bool = False,
tools: list[data_class.Tool] = None,
tools: list[Manifest]= None,
tool_outputs: list[data_class.ToolOutput] = None,
tool_choice: data_class.ToolChoice = None,
end_user_id: str = None,
Expand Down
3 changes: 2 additions & 1 deletion python/core/console/appbuilder_client/data_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from pydantic import Field
from typing import Union
from typing import Optional
from appbuilder.core.manifest.models import Manifest


class Function(BaseModel):
Expand Down Expand Up @@ -112,7 +113,7 @@ class AppBuilderClientRequest(BaseModel):
conversation_id: str
file_ids: Optional[list[str]] = None
app_id: str
tools: Optional[list[Tool]] = None
tools: Optional[list[Manifest]] = None
tool_outputs: Optional[list[ToolOutput]] = None
tool_choice: Optional[ToolChoice] = None
end_user_id: Optional[str] = None
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_appbuilder_client_toolcall.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def get_current_weather(location: str, unit: str) -> str:
conversation_id=conversation_id,
query="今天北京的天气怎么样?",
tools=[
appbuilder.Manifest.from_function(f).model_dump() for f in functions
appbuilder.Manifest.from_function(f) for f in functions
],
)
print(msg.model_dump_json(indent=4))
Expand Down Expand Up @@ -144,7 +144,7 @@ def get_current_weather(location: str, unit: str) -> str:
conversation_id=conversation_id,
query="今天北京的天气怎么样?",
tools=[
appbuilder.Manifest.from_function(f).model_dump() for f in functions
appbuilder.Manifest.from_function(f) for f in functions
],
)
print(msg.model_dump_json(indent=4))
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ def test_manifest_decorator(self):
# 定义示例函数
def get_current_weather(location: str, unit) -> str:
return "北京今天25度"
func_manifest = appbuilder.Manifest.from_function(get_current_weather).model_dump()
assert func_manifest.get("function").get("description") is not None
func_manifest = appbuilder.Manifest.from_function(get_current_weather)
assert func_manifest.function.get("description") is not None


if __name__ == "__main__":
Expand Down

0 comments on commit f48c450

Please sign in to comment.