99import logging
1010from openai .types import chat
1111
12- from pydantic_ai .models .openai import OpenAIModel
13- from pydantic_ai .providers .openai import OpenAIProvider
14- from pydantic_ai .models .openai import OpenAIModelSettings
12+ from pydantic_ai .models .openai import OpenAIChatModel , OpenAIChatModelSettings
1513from pydantic_ai .models .fallback import FallbackModel
14+ from pydantic_ai .providers .openai import OpenAIProvider
1615from openai import OpenAI , BadRequestError
1716
1817from codewiki .src .config import Config
@@ -38,14 +37,14 @@ def _should_use_max_completion_tokens(model_name: str, base_url: str) -> bool:
3837 return False
3938
4039
41- def _build_model_settings (config : Config , model_name : str ) -> OpenAIModelSettings :
40+ def _build_model_settings (config : Config , model_name : str ) -> OpenAIChatModelSettings :
4241 """Build model settings with the correct token parameter."""
4342 if _should_use_max_completion_tokens (model_name , config .llm_base_url ):
44- return OpenAIModelSettings (
43+ return OpenAIChatModelSettings (
4544 temperature = 0.0 ,
4645 max_completion_tokens = config .max_tokens
4746 )
48- return OpenAIModelSettings (
47+ return OpenAIChatModelSettings (
4948 temperature = 0.0 ,
5049 max_tokens = config .max_tokens
5150 )
@@ -67,8 +66,8 @@ def _get_litellm_model_name(model_name: str, provider: str) -> str:
6766 return model_name
6867
6968
70- class CompatibleOpenAIModel (OpenAIModel ):
71- """OpenAIModel subclass that patches non-standard API proxy responses.
69+ class CompatibleOpenAIModel (OpenAIChatModel ):
70+ """OpenAIChatModel subclass that patches non-standard API proxy responses.
7271
7372 Some OpenAI-compatible proxies return responses with fields like
7473 choices[].index set to None instead of an integer. This subclass
@@ -90,7 +89,6 @@ def _create_litellm_openai_client(config: Config) -> OpenAI:
9089
9190 litellm translates OpenAI API calls to Bedrock, Anthropic, etc.
9291 """
93- import litellm
9492 # Configure litellm for the provider
9593 if config .provider == "bedrock" :
9694 import os
0 commit comments