genkit
genkit copied to clipboard
[Py][Bug] compat-oai plugin has some pydantic validation errors
2 validation errors for OpenAIConfig topK Extra inputs are not permitted [type=extra_forbidden, input_value=32, input_type=int] For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden topP Extra inputs are not permitted [type=extra_forbidden, input_value=0.95, input_type=float] For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden
File "/Users/yesudeep/code/github.com/firebase/genkit/py/packages/genkit/src/genkit/core/action/_action.py", line 186, in async_tracing_wrapper
output = await afn(input, ctx)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/yesudeep/code/github.com/firebase/genkit/py/packages/genkit/src/genkit/aio/_util.py", line 46, in async_wrapper
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "/Users/yesudeep/code/github.com/firebase/genkit/py/plugins/compat-oai/src/genkit/plugins/compat_oai/models/handler.py", line 103, in generate
request.config = OpenAIConfig(**request.config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yesudeep/code/github.com/firebase/genkit/py/.venv/lib/python3.12/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is when I run the compat-oai-hello sample and chat with a model.
Hi @yesudeep , top_k wasn't added because, as far as I understand, support for this parameter is not currently available. Only top_p allowed to be added:
result = await ai.generate(
prompt=f'generate an RPG character named {name}',
output_schema=RpgCharacter,
config={'model': 'model version', 'temperature': 1, 'top_p': 0.9},
tools=['toolName'],
)
Can we make a note of this in the code? @timere-nemo do you think we should prevent this from becoming a validation error somehow?