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

feat: python 更新 V2 调用的传参列表 #882

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qianfan"
version = "0.4.12.1"
version = "0.4.12.2"
description = "文心千帆大模型平台 Python SDK"
authors = []
license = "Apache-2.0"
Expand Down
48 changes: 19 additions & 29 deletions python/qianfan/resources/typing_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
client typing
"""

from typing import Any, List, Optional
from typing import List, Optional

from typing_extensions import Literal

Expand All @@ -24,17 +24,15 @@
__all__ = ["Completion"]


class FunctionCall(BaseModel):
parameters: Any
"""
The arguments to call the function with, as generated by the model in JSON
format. Note that the model does not always generate valid JSON, and may
hallucinate parameters not defined by your function schema. Validate the
arguments in your code before calling your function.
"""

class Function(BaseModel):
name: str
"""The name of the function to call."""
arguments: str


class ToolCall(BaseModel):
id: str
type: str
function: Function


class SearchResult(BaseModel):
Expand All @@ -44,14 +42,6 @@ class SearchResult(BaseModel):
datasource_id: str


class SearchInfo(BaseModel):
is_beset: Optional[int] = None

rewrite_query: Optional[str] = None

search_results: Optional[List[SearchResult]] = None


class ChatCompletionMessage(BaseModel):
content: Optional[str] = None
"""The contents of the message."""
Expand All @@ -61,9 +51,9 @@ class ChatCompletionMessage(BaseModel):

name: Optional[str] = None

content_type: Optional[str] = None
tool_calls: Optional[List[ToolCall]] = None

function_call: Optional[FunctionCall] = None
tool_call_id: Optional[str] = None


class Choice(BaseModel):
Expand All @@ -78,18 +68,10 @@ class Choice(BaseModel):
message: ChatCompletionMessage
"""A chat completion message generated by the model."""

need_clear_history: Optional[bool] = None

ban_round: Optional[int] = None

function_call: Optional[FunctionCall] = None

search_info: Optional[SearchInfo] = None

flag: Optional[int] = None

tools_info: Optional[Any] = None


class CompletionUsage(BaseModel):
completion_tokens: int
Expand Down Expand Up @@ -151,6 +133,8 @@ class ChoiceDelta(BaseModel):
content: Optional[str] = None
"""The contents of the message."""

tool_calls: Optional[List[ToolCall]] = None


class CompletionChunkChoice(BaseModel):
delta: ChoiceDelta
Expand All @@ -166,6 +150,10 @@ class CompletionChunkChoice(BaseModel):
index: int
"""The index of the choice in the list of choices."""

ban_round: Optional[int] = None

flag: Optional[int] = None


class CompletionChunk(BaseModel):
id: str
Expand Down Expand Up @@ -195,3 +183,5 @@ class CompletionChunk(BaseModel):
"""

statistic: Optional[CompletionStatistic] = None

web_search: Optional[SearchResult] = None
Loading