Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python ToolCall新增函数、注解解析 #589

Closed
wants to merge 74 commits into from

Conversation

jundaix
Copy link
Contributor

@jundaix jundaix commented Nov 11, 2024

更新tool call简化,添加了BaseModel,参数类型/注释缺失验证、参数描述提取,优先级等功能,补充了相关单测

@jundaix jundaix changed the title Dj feature toolcall toolcall简化 Nov 11, 2024
@jundaix jundaix changed the title toolcall简化 Python TooolCall新增函数、注解解析 Nov 21, 2024
@jundaix jundaix changed the title Python TooolCall新增函数、注解解析 Python ToolCall新增函数、注解解析 Nov 21, 2024

# Update parameter view lists for function_parameter decorator.
# This will be merged into ManifestView if function decorator runs last like:
# @function
Copy link
Contributor

@userpj userpj Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manifest
@manifest_parameter
@manifest_parameter


from appbuilder.core.manifest.validate import validate_function_param_name, validate_function_name

class BaseModel(DataClassJsonMixin):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no BaseModel is appbuilder sdk now, remove it. If we were to define a BaseModel, it would be it core, not core/manifest

description: str = None
default_value: str = None
type_: str = None
type_object: Optional[Any] = Field(default=None, metadata = config(exclude=lambda value: True))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove type_object

msg = client.run(
conversation_id=conversation_id,
query="今天北京的天气怎么样?",
tools = [appbuilder.function_to_manifest(f).model_dump() for f in functions]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tools = [Manifest.from(f) for f in functions]

from appbuilder.core.manifest.manifest_signature import get_signature
from appbuilder.core.manifest.manifest_decorator import ManifestView

def function_to_manifest(func) -> Manifest:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to Manifest class

@userpj userpj closed this Nov 21, 2024
@userpj userpj reopened this Nov 21, 2024
@userpj userpj force-pushed the dj-feature-toolcall branch from d728fb3 to 09c55ff Compare November 21, 2024 12:27
@jundaix jundaix closed this Nov 21, 2024
@jundaix jundaix reopened this Nov 21, 2024
@userpj userpj closed this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants