Skip to content

Commit

Permalink
Fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
billytrend-cohere committed Sep 19, 2024
1 parent bc4fc1e commit e85fe57
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/test_client_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def test_chat_documents(self) -> None:
{"title": "widget sales 2021", "text": "4 million"},
]
response = co.chat(
messages=cohere.UserMessage(
message=cohere.TextContent(text="how many widges were sold in 2020?"),
messages=cohere.UserV2ChatMessage(
content=cohere.TextContent(text="how many widges were sold in 2020?"),
documents=documents,
),
)
Expand All @@ -68,16 +68,16 @@ def test_chat_tools(self) -> None:
},
}
tools = [cohere.V2Tool(type="function", function=get_weather_tool)]
messages: typing.List[typing.Union[UserMessage, AssistantMessage, None, cohere.V2ToolMessage]] = [
UserMessage(message="what is the weather in Toronto?")
messages: cohere.ChatMessages = [
cohere.UserV2ChatMessage(content="what is the weather in Toronto?")
]
res = co.chat(model="command-r-plus", tools=tools, messages=messages)

# call the get_weather tool
tool_result = {"temperature": "30C"}
tool_content = [cohere.Content(output=tool_result, text="The weather in Toronto is 30C")]
messages.append(res.message)
messages.append(cohere.V2ToolMessage(tool_call_id=res.message.tool_calls[0].id, tool_content=tool_content))
messages.append(cohere.ToolV2ChatMessage(tool_call_id=res.message.tool_calls[0].id, tool_content=tool_content))

res = co.chat(tools=tools, messages=messages)
print(res.message)

0 comments on commit e85fe57

Please sign in to comment.