set default tool calls and function call

This commit is contained in:
alisalim17 2024-05-01 17:01:45 +04:00
parent 20a796bacb
commit 81ad331d92

View file

@ -364,8 +364,6 @@ class ChatCompletionMessageToolCall(OpenAIObject):
class Message(OpenAIObject): class Message(OpenAIObject):
tool_calls: Optional[List[ChatCompletionMessageToolCall]]
def __init__( def __init__(
self, self,
content="default", content="default",
@ -378,13 +376,16 @@ class Message(OpenAIObject):
super(Message, self).__init__(**params) super(Message, self).__init__(**params)
self.content = content self.content = content
self.role = role self.role = role
self.tool_calls = []
self.function_call = None
if function_call is not None: if function_call is not None:
self.function_call = FunctionCall(**function_call) self.function_call = FunctionCall(**function_call)
if tool_calls is not None: if tool_calls is not None:
self.tool_calls = [] self.tool_calls = [
for tool_call in tool_calls: ChatCompletionMessageToolCall(**tool_call) for tool_call in tool_calls
self.tool_calls.append(ChatCompletionMessageToolCall(**tool_call)) ]
if logprobs is not None: if logprobs is not None:
self._logprobs = ChoiceLogprobs(**logprobs) self._logprobs = ChoiceLogprobs(**logprobs)
@ -407,8 +408,7 @@ class Message(OpenAIObject):
except: except:
# if using pydantic v1 # if using pydantic v1
return self.dict() return self.dict()
class Delta(OpenAIObject): class Delta(OpenAIObject):
tool_calls: Optional[List[ChatCompletionDeltaToolCall]] tool_calls: Optional[List[ChatCompletionDeltaToolCall]]