Skip to content

feat(google-ai): Add support for structed object generation and streaming#52

Merged
omeraplak merged 12 commits intoVoltAgent:mainfrom
foxy17:feat/google-ai-structed-data
Apr 28, 2025
Merged

feat(google-ai): Add support for structed object generation and streaming#52
omeraplak merged 12 commits intoVoltAgent:mainfrom
foxy17:feat/google-ai-structed-data

Conversation

@foxy17
Copy link
Copy Markdown
Contributor

@foxy17 foxy17 commented Apr 26, 2025

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

What is the new behavior?

  • Added support for object generation based of schema in google-ai provider
  • Bumped @voltagent/core package from 0.1.6 to 0.1.7
  • Bumped @google/genai package to 0.10.0

Notes for reviewers

I had to copy over and modify a zod to json schema utility from official SDK package since that was not exported.

@omeraplak
Copy link
Copy Markdown
Member

Hey @foxy17 ,
Thanks so much for the PR! 🙌 I’ll review it shortly and get back to you soon. ⚡

@foxy17
Copy link
Copy Markdown
Contributor Author

foxy17 commented Apr 26, 2025

Thanks, still working on it. Will make it ready for review after adding the object streaming, example and changeset!

@foxy17 foxy17 force-pushed the feat/google-ai-structed-data branch from ef2a561 to 43fe280 Compare April 27, 2025 05:08
@foxy17 foxy17 marked this pull request as ready for review April 27, 2025 05:11
@foxy17
Copy link
Copy Markdown
Contributor Author

foxy17 commented Apr 27, 2025

Improvement upon #12

@foxy17
Copy link
Copy Markdown
Contributor Author

foxy17 commented Apr 27, 2025

@omeraplak this PR is ready, not sure why the build is failing, can you help me with that!

@omeraplak
Copy link
Copy Markdown
Member

Hey @foxy17 ,
When you run pnpm build locally, you might see these type errors:

@voltagent/groq-ai: src/index.ts(46,5): error TS2322: Type 'GroqMessage' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:   Property 'name' is missing in type 'GroqMessage' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai: src/index.ts(207,17): error TS2353: Object literal may only specify known properties, and 'usage' does not exist in type '{ text: string; }'.
@voltagent/groq-ai: src/index.ts(273,20): error TS2769: No overload matches this call.
@voltagent/groq-ai:   Overload 1 of 3, '(body: ChatCompletionCreateParamsNonStreaming, options?: RequestOptions<unknown> | undefined): APIPromise<ChatCompletion>', gave the following error.
@voltagent/groq-ai:     Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:       Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai:   Overload 2 of 3, '(body: ChatCompletionCreateParamsStreaming, options?: RequestOptions<unknown> | undefined): APIPromise<Stream<ChatCompletionChunk>>', gave the following error.
@voltagent/groq-ai:     Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:       Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai:   Overload 3 of 3, '(body: ChatCompletionCreateParamsBase, options?: RequestOptions<unknown> | undefined): APIPromise<Stream<ChatCompletionChunk> | ChatCompletion>', gave the following error.
@voltagent/groq-ai:     Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:       Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai: src/index.ts(326,5): error TS6133: 'options' is declared but its value is never read.
@voltagent/groq-ai: Error: error occured in dts build

These issues are related to type mismatches mainly because some required properties like name are missing when building the messages.

You can follow this guide to set up your local environment and fix the type errors:
👉 https://voltagent.dev/docs/community/contributing/

Please feel free to reach out if you need any help!
Happy to support you anytime.

@foxy17
Copy link
Copy Markdown
Contributor Author

foxy17 commented Apr 27, 2025

These issues stem from the Groq Provider

Hey @foxy17 , When you run pnpm build locally, you might see these type errors:

@voltagent/groq-ai: src/index.ts(46,5): error TS2322: Type 'GroqMessage' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:   Property 'name' is missing in type 'GroqMessage' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai: src/index.ts(207,17): error TS2353: Object literal may only specify known properties, and 'usage' does not exist in type '{ text: string; }'.
@voltagent/groq-ai: src/index.ts(273,20): error TS2769: No overload matches this call.
@voltagent/groq-ai:   Overload 1 of 3, '(body: ChatCompletionCreateParamsNonStreaming, options?: RequestOptions<unknown> | undefined): APIPromise<ChatCompletion>', gave the following error.
@voltagent/groq-ai:     Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:       Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai:   Overload 2 of 3, '(body: ChatCompletionCreateParamsStreaming, options?: RequestOptions<unknown> | undefined): APIPromise<Stream<ChatCompletionChunk>>', gave the following error.
@voltagent/groq-ai:     Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:       Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai:   Overload 3 of 3, '(body: ChatCompletionCreateParamsBase, options?: RequestOptions<unknown> | undefined): APIPromise<Stream<ChatCompletionChunk> | ChatCompletion>', gave the following error.
@voltagent/groq-ai:     Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'.
@voltagent/groq-ai:       Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'.
@voltagent/groq-ai: src/index.ts(326,5): error TS6133: 'options' is declared but its value is never read.
@voltagent/groq-ai: Error: error occured in dts build

These issues are related to type mismatches mainly because some required properties like name are missing when building the messages.

You can follow this guide to set up your local environment and fix the type errors: 👉 https://voltagent.dev/docs/community/contributing/

Please feel free to reach out if you need any help! Happy to support you anytime.

These errors stem from the Groq package is it okay if i make changes to that package?

@omeraplak
Copy link
Copy Markdown
Member

Oops, sorry about that.
Could you pull from the main branch?
These issues should be fixed there already.

@foxy17
Copy link
Copy Markdown
Contributor Author

foxy17 commented Apr 27, 2025

@omeraplak done ✅

@omeraplak omeraplak merged commit 96f2395 into VoltAgent:main Apr 28, 2025
4 checks passed
@omeraplak
Copy link
Copy Markdown
Member

Thank you so much again! 🙏

codegen-sh Bot referenced this pull request in Zeeeepa/voltagent May 28, 2025
…,82,86,87

- Consolidate all Codegen SDK and natural language processing PRs into single unified integration
- Merge natural language processing features into unified engine with sentiment analysis, entity extraction, and intent classification
- Consolidate automated PR creation logic for consistency with comprehensive GitHub automation
- Standardize SDK integration patterns across all components with zero duplication
- Eliminate duplicate NLP processing with unified UnifiedNLPEngine
- Unify Claude Code orchestration through AgentAPIMiddleware
- Add comprehensive example demonstrating all consolidated features
- Implement unified configuration system and health monitoring
- Provide complete workflows combining NLP → Code Generation → PR Creation
- Include security considerations and performance optimizations

Technical Implementation:
- @voltagent/codegen-sdk package with unified client interface
- UnifiedNLPEngine consolidating all natural language processing
- UnifiedPRCreator with automated GitHub PR creation and management
- ClaudeCodeOrchestrator for AgentAPI middleware and code orchestration
- AgentAPIMiddleware with caching, rate limiting, and metrics
- Comprehensive utility functions and validation schemas
- Zero duplication across all integrated components
- Consistent interfaces following VoltAgent patterns

Consolidation Objectives Achieved:
✅ Single unified Codegen integration PR
✅ Consolidated natural language processing
✅ Integrated automated PR creation
✅ Standardized SDK patterns
✅ Unified orchestration system
✅ Zero duplication in NLP processing logic
✅ Consistent SDK integration interfaces
✅ Removal of redundant PR creation functions
✅ Single cohesive Codegen integration
✅ Clear contracts for natural language processing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants