feat(provider): add support for azure openai provider#1422
feat(provider): add support for azure openai provider#1422yinwm merged 17 commits intosipeed:mainfrom
Conversation
…-azure-openai-support
…zure-openai-support
There was a problem hiding this comment.
Pull request overview
Adds a first-class Azure OpenAI provider implementation so PicoClaw can make LLM chat completion calls against Azure OpenAI deployments, while deduplicating shared OpenAI-compatible utilities.
Changes:
- Introduce
pkg/providers/azureprovider with Azure-specific URL construction,api-keyauth, andmax_completion_tokenshandling. - Extract shared OpenAI-compatible helpers into
pkg/providers/commonand refactoropenai_compatto use them. - Wire the provider into the factory/config + update example configs and README provider tables.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/providers/openai_compat/provider.go | Refactors OpenAI-compat provider to use new shared common helpers. |
| pkg/providers/openai_compat/provider_test.go | Updates serialization tests to use common.SerializeMessages. |
| pkg/providers/factory_provider.go | Adds azure / azure-openai protocol support and instantiates Azure provider. |
| pkg/providers/factory_provider_test.go | Adds protocol parsing + factory tests for Azure config cases. |
| pkg/providers/common/common.go | New shared utilities: HTTP client creation, message serialization, response/error parsing, numeric helpers. |
| pkg/providers/common/common_test.go | Unit tests for the new shared provider utilities. |
| pkg/providers/azure/provider.go | New Azure OpenAI provider implementation. |
| pkg/providers/azure/provider_test.go | Tests for Azure URL/auth/body behaviors and timeout options. |
| pkg/config/defaults.go | Adds an Azure model entry to the default config template. |
| config/config.example.json | Adds an Azure model example configuration. |
| README.md | Documents azure as a supported provider and adds it to the provider table. |
| README.zh.md / README.vi.md / README.pt-br.md / README.ja.md / README.fr.md | Adds Azure OpenAI entry to localized provider tables. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <[email protected]>
…zure-openai-support
…zure-openai-support
…zure-openai-support
…zure-openai-support
…zure-openai-support
…zure-openai-support
…zure-openai-support
|
@yinwm / @wj-xiao / @lxowalle / @imguoguo / @alexhoshina Would really appreciate if you could could review this PR. Testing is complete, all PR review comments addressed. |
|
@alexhoshina I have fixed the linting issues, please could you re-trigger the CI workflow? |
yinwm
left a comment
There was a problem hiding this comment.
Code Review: Azure OpenAI Provider Support
Overall
The implementation is well-structured with good separation of concerns. The extraction of common utilities into pkg/providers/common is a solid approach for code reuse.
Findings
1. API Version Hardcoded (provider.go:25)
azureAPIVersion = "2024-10-21"The API version is hardcoded. Consider documenting the upgrade process or making it configurable.
2. Deployment Name Validation (provider.go:89)
While url.JoinPath provides protection against path traversal, there's no validation on the deployment name itself. Users could pass invalid characters that would cause the request to fail.
Suggestion: Add validation to ensure deployment names only contain allowed characters (alphanumeric, hyphen, underscore).
3. Redundant Empty Check (provider.go:84-86)
The apiBase == "" check in Chat() is redundant since factory_provider.go already validates this. However, it doesn't hurt as a safety measure for direct Provider usage.
4. Error Handling
Consider handling Azure-specific error codes (429 rate limiting, 503 unavailable) for better user experience, though the current generic handling works.
5. Documentation: config.example.json
The example could include the proxy field since many users need it:
{
"model_name": "azure-gpt5",
"model": "azure/my-gpt5-deployment",
"api_key": "your-azure-api-key",
"api_base": "https://your-resource.openai.azure.com",
"proxy": "" // optional
}6. defaults.go Default Value
APIBase: "https://your-resource.openai.azure.com",This default is not a valid URL. Consider leaving it empty or using a clearer placeholder like https://<your-resource>.openai.azure.com.
Summary
| Category | Status |
|---|---|
| Functionality | ✅ Complete |
| Code Quality | ✅ Clean and secure |
| Security | ✅ Path injection protection in place |
| Maintainability | ✅ Good common abstraction |
| Documentation |
Overall: Approve - Ready to merge with minor documentation suggestions above.
* Add support for azure openai provider * Add checks for deployment model name * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Addressing @Copilot suggestion to remove the init() function which seemed redundant * Fix readme * Fix linting checks --------- Co-authored-by: Copilot <[email protected]>
fix(provider/azure): lint err
|
@kunalk16 Great addition bringing Azure OpenAI provider support to PicoClaw. Users with Azure subscriptions will appreciate being able to use their deployed models directly. Clean implementation with proper test coverage. We have a PicoClaw Dev Group on Discord for contributors to connect and collaborate. Interested? Send an email to |
* Add support for azure openai provider * Add checks for deployment model name * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Addressing @Copilot suggestion to remove the init() function which seemed redundant * Fix readme * Fix linting checks --------- Co-authored-by: Copilot <[email protected]>
* Add support for azure openai provider * Add checks for deployment model name * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Addressing @Copilot suggestion to remove the init() function which seemed redundant * Fix readme * Fix linting checks --------- Co-authored-by: Copilot <[email protected]>
* Add support for azure openai provider * Add checks for deployment model name * Apply suggestion from @Copilot Co-authored-by: Copilot <[email protected]> * Addressing @Copilot suggestion to remove the init() function which seemed redundant * Fix readme * Fix linting checks --------- Co-authored-by: Copilot <[email protected]>
fix(provider/azure): lint err
📝 Description
Adds support for LLM calls to Azure OpenAI provider so that users can consume LLM models from Azure subscriptions
🗣️ Type of Change
🤖 AI Code Generation
🔗 Related Issue
Closes #1424
📚 Technical Context (Skip for Docs)
🧪 Test Environment
📸 Evidence (Optional)
Screenshots
☑️ Checklist