Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors and extends the configuration and provider logic for the assistant. The main changes include:
• Moving type definitions: The AssistantConfig definition has been removed from assistant.py and redefined in config.py. Additionally, a new ModelConfig type is introduced in config.py to support model-specific configuration (API key, base URL, and pricing overrides).
• Updating provider selection logic: The get_completion_provider function now prioritizes the “oai-azure:” prefix and, for models that don’t match any specific prefix, defaults to the OpenAICompletionProvider instead of raising an error. This simplifies the model selection logic.
• Enhancing the Assistant class: – The constructor and the from_config classmethod now accept an optional model_configs dictionary. – In complete_chat, the code checks if a model configuration override exists for the requested model, and if so, it uses the override values for the API key, base URL, and pricing. Pricing information is later passed to the completion provider.
• Propagating model configuration: The init_assistant function and main entry point in gpt.py have been updated to pass the optional model_configs, ensuring that the new model-specific settings are used throughout.
• Adjusting OpenAICompletionProvider behavior: In the streaming completion process, pricing is now determined from the provided args (using an override if available) before emitting UsageEvent objects, ensuring that pricing overrides are consistently applied.
Overall, the changes streamline configuration management, allow model-specific overrides for API connection parameters and pricing, and simplify provider selection without breaking backward compatibility.