Welcome to Portkey Forum

Updated last week

Exception Has Occurred: Validation Error

Exception has occurred: ValidationError
1 validation error for ChatCompletions
choices.0.message.tool_calls.1
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
File "C:\Users\shreyas\Music\Cenzex\CityInsider\proto_agent_portkey.py", line 301, in trigger
response: ChatCompletion = await self.async_client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\shreyas\Music\Cenzex\CityInsider\proto_agent_portkey.py", line 420, in ask_question
return await self.trigger()
File "C:\Users\shreyas\Music\Cenzex\CityInsider\interface.py", line 80, in websocket_endpoint
response = await instance.ask_question(message["data"])
File "C:\Users\shreyas\Music\Cenzex\CityInsider\main.py", line 8, in <module>
uvicorn.run(app, port=7005, factory=False)
pydantic_core._pydantic_core.ValidationError: 1 validation error for ChatCompletions
choices.0.message.tool_calls.1
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type ...
G
s
b
49 comments
@b4s36t4 can you take a look at this?
also @s44002 reported that tools are not working with Amazon Nova models, can you take a look at that as well?
@b4s36t4 I'll give more context in DM
thanx for addressing it here, but yes, please do take a look, both are quite significant of issues
can you share your request body that is causing this exception?
@s44002, can you share the code snippet you're trying with?
I can't share the snippet of code, but I will give a description of events
But here is the thing
Implementation is not the problem because the same code works perfectly with other Google, anthropic, oai, and deepseek models
here the error is related to pydantic, sharing the pydantic object or related schema would help debug faster.
It's not a pydantic error at my code level, it's at your library level, when I called the chatcompletions create thing
The response to that was this
This is at a library level of portkey
I don't use OAI, I use your library
You just used portkey.chat.completions with tools params right?
Only tools defined no tool choice
Ok, thanks for clarifying the doubts. Will revert back to you soon.
Both requiring arguments to be sent in as inputs
Have sent you a friend request if you need any further help or data from me please do DM
i encountered this error - Exception has occurred: ValidationError
2 validation errors for ChatCompletions
choices.0.message.tool_calls.1
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
choices.0.message.tool_calls.3
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
File "C:\Users\shreyas\Music\Cenzex\CityInsider\playo\playo_agent.py", line 295, in trigger
response: ChatCompletion = await self.async_client.chat.completions.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\shreyas\Music\Cenzex\CityInsider\playo\playo_agent.py", line 452, in ask_question
return await self.trigger()
File "C:\Users\shreyas\Music\Cenzex\CityInsider\interfect_ae_agents.py", line 85, in websocket_endpoint
response = await instance.ask_question(message["data"])
File "C:\Users\shreyas\Music\Cenzex\CityInsider\main.py", line 8, in <module>
uvicorn.run(app, port=7005, factory=False)
pydantic_core._pydantic_core.ValidationError: 2 validation errors for ChatCompletions
choices.0.message.tool_calls.1
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
choices.0.message.tool_calls.3
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
but this time with gemini 1.5 flash 002
the chat history is perfect, the response parsing somethign has gone wrong
@Griphook | Portkey
can i directly get the raw response and not a chat completions object
currently we're not logging the raw response
I will look into this today
Fantastic, this is a very weird edge case, that i cannot debug.... more because i do not run an uncompiled version of your lib...
if possible, create a try except around the part that makes the response into a chatcompletions object, and if it goes into except then immediately log the response, without that idk how i can diagnose this
it does happen only on rare occasions, i do not have any idea how to reproduce, in the last 2 days, this error has not happned
@Griphook | Portkey @b4s36t4
Exception has occurred: ValidationError
1 validation error for ChatCompletions
choices.0.message.tool_calls.1
Input should be a valid dictionary or instance of ChatCompletionMessageToolCall [type=model_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.10/v/model_type
got the error again
common pattern
i have a retry mechanism
once the error happens, it goes into retry and then when the retry happens, then again same error, then again retry happens, but the third time the error does not come
Hi, @s44002. You're using which provider and can you share me the example tools object you're using (maybe a glimpse of it or so). I need that to replicate the error in my machine to debug further and provide a solution. You can DM me.
i am using google
not vertexai ..
the ai.google.dev
models - gemini 2.0 flash, gemini 1.5 flash
DMed @b4s36t4
PS, i have also enabled logging with mode debug, if i encounter that error again, we will atleast have something
Add a reply
Sign up and join the conversation on Discord