Skip to content

refactor: Replace interface{} with any and add multimodal type support#232

Merged
edenreich merged 8 commits intomainfrom
refactor/multimodal-types-any-refactor
Jan 23, 2026
Merged

refactor: Replace interface{} with any and add multimodal type support#232
edenreich merged 8 commits intomainfrom
refactor/multimodal-types-any-refactor

Conversation

@edenreich
Copy link
Copy Markdown
Contributor

Updates Go type definitions from interface{} to any for Go 1.18+ compatibility. Adds support for multimodal message content with new types for text and image content parts. Includes spelling dictionary updates for new AI providers.

Changes

Type Modernization

  • Go 1.18+ compatibility: Replaces all interface{} occurrences with any throughout the codebase
  • Code generation: Updated internal/codegen/codegen.go to handle any type properly
  • OpenAPI schema: Enhanced schema definitions in internal/openapi/openapi.go

Multimodal Support

  • New types: Added MessageContent, ContentPart, TextContentPart, ImageContentPart, and ImageURL types in providers/common_types.go
  • OpenAPI schema: Added support for oneOf schemas to handle polymorphic message content
  • Enhanced message handling: Updated OpenAPI specification in openapi.yaml to support multimodal message formats

Spelling Updates

  • New AI providers: Added "Deepseek", "providersmocks", and "qwen" to .cspell.json

Benefits

  1. Modern Go syntax: Uses Go 1.18+ any type for better readability and type safety
  2. Multimodal capabilities: Enables support for text and image content in messages
  3. Improved schema validation: Better OpenAPI schema definitions with oneOf support
  4. Developer experience: Updated spelling dictionary for new AI provider names

Technical Details

  • Files modified: 5 files with 61 insertions and 45 deletions
  • Backward compatibility: Maintains existing API compatibility while adding new features
  • Type safety: All changes maintain type safety and compile-time checking

…ckages

Reorganized the providers package to improve code organization and maintainability:

- Created providers/constants/ package for all constants (breaks import cycles)
- Created providers/types/ for generated types and message helpers
- Created providers/registry/ for provider configuration and registry
- Created providers/core/ for provider implementation infrastructure
- Created providers/client/ for HTTP client abstraction
- Created providers/routing/ for model routing logic
- Created providers/transformers/ for provider-specific response transformers

This structure provides clear separation of concerns and makes the codebase
easier to navigate. The constants package has no dependencies, which breaks
the circular import dependencies that existed previously.

Updated all imports across 17+ files including tests, API routes, middleware,
config, and code generation templates.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
Use naming imports for non-builtin packages and group them for clarity - from library down to internal packages

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
- Add named imports to constants, transformers, and registry templates
- Add generation comment to client and transformer templates
- Regenerate all provider files with consistent import style

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Remove unused code generation functions that were replaced by oapi-codegen:
- Remove GenerateCommonTypes() function (178 lines)
- Remove ProvidersCommonTypes CLI case handler
- Remove unused helper functions generateType() and generateTag()

These functions were used to generate providers/common_types.go with custom
templates, but this has been completely replaced by oapi-codegen which now
generates providers/types/common_types.go from the OpenAPI spec.

Verification:
- task generate completes successfully
- All tests pass
- No change in generated output

Signed-off-by: Eden Reich <eden.reich@gmail.com>
@edenreich edenreich merged commit bfae43d into main Jan 23, 2026
1 check passed
@edenreich edenreich deleted the refactor/multimodal-types-any-refactor branch January 23, 2026 19:50
ig-semantic-release-bot bot added a commit that referenced this pull request Jan 23, 2026
## [0.23.1](v0.23.0...v0.23.1) (2026-01-23)

### ♻️ Improvements

* Replace interface{} with any and add multimodal type support ([#232](#232)) ([bfae43d](bfae43d))
@ig-semantic-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.23.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant