examples: add Tuning Engines OpenAI-compatible endpoint#1333
examples: add Tuning Engines OpenAI-compatible endpoint#1333cerebrixos wants to merge 2 commits into
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a new example project showing VoltAgent routed through Tuning Engines (OpenAI-compatible) with docs, env template, package/tsconfig, and a runnable TypeScript entrypoint that starts a Hono server, configures LibSQL memory, and performs a sample generateText call. ChangesTuning Engines Example
Sequence DiagramsequenceDiagram
participant Env as Environment
participant App as VoltAgent Example
participant OpenAI as TuningEngines OpenAI Client
participant Mem as LibSQL Memory
participant Server as Hono Server
Env->>App: TUNING_ENGINES_API_KEY / TUNING_ENGINES_MODEL (validation)
App->>OpenAI: instantiate client (baseURL=Tuning Engines)
App->>Mem: initialize LibSQLMemoryAdapter
App->>Server: start honoServer() with VoltAgent
App->>OpenAI: generateText() sample request
OpenAI->>App: response (text + usage)
App->>App: log results / handle error (set exit code)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
examples/with-tuning-engines/package.json (1)
1-39: ⚡ Quick winAdd a Node engine constraint to match the documented prerequisite.
Line 11 in the README requires Node.js v20+, but this package doesn’t enforce it. Adding
enginesprevents accidental installs/runs on unsupported Node versions.Suggested patch
{ "name": "voltagent-example-with-tuning-engines", "author": "", + "engines": { + "node": ">=20" + }, "dependencies": { "`@ai-sdk/openai`": "^3.0.0",🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/with-tuning-engines/package.json` around lines 1 - 39, Add an "engines" field to package.json to enforce the documented Node.js prerequisite (v20+); update the root JSON object (the same level as "type", "scripts", "dependencies") to include "engines": { "node": ">=20.0.0" } so installs on older Node versions fail with a clear constraint message and prevent accidental runs on unsupported Node versions.examples/with-tuning-engines/src/index.ts (1)
39-48: ⚡ Quick winHandle request failures in the demo IIFE.
Line 39 starts an async IIFE with no error handling; transient API/network errors can fail noisily and obscure what happened. Wrap it in
try/catchand log the error.Suggested patch
(async () => { - const result = await agent.generateText( - "Explain how policy, traces, and usage reporting help production AI agents.", - ); - - logger.info("Tuning Engines example request completed", { - text: result.text, - usage: result.usage, - }); + try { + const result = await agent.generateText( + "Explain how policy, traces, and usage reporting help production AI agents.", + ); + + logger.info("Tuning Engines example request completed", { + text: result.text, + usage: result.usage, + }); + } catch (error) { + logger.error("Tuning Engines example request failed", { error }); + process.exitCode = 1; + } })();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@examples/with-tuning-engines/src/index.ts` around lines 39 - 48, The async IIFE that calls agent.generateText and then logger.info should be wrapped in a try/catch to handle transient API/network failures: surround the await agent.generateText(...) and subsequent logger.info(...) with try { ... } catch (err) { logger.error("Tuning Engines example request failed", { error: err }) } so failures are logged instead of crashing; reference the existing async IIFE, agent.generateText, and logger.info to find where to add the try/catch.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@examples/with-tuning-engines/package.json`:
- Around line 1-39: Add an "engines" field to package.json to enforce the
documented Node.js prerequisite (v20+); update the root JSON object (the same
level as "type", "scripts", "dependencies") to include "engines": { "node":
">=20.0.0" } so installs on older Node versions fail with a clear constraint
message and prevent accidental runs on unsupported Node versions.
In `@examples/with-tuning-engines/src/index.ts`:
- Around line 39-48: The async IIFE that calls agent.generateText and then
logger.info should be wrapped in a try/catch to handle transient API/network
failures: surround the await agent.generateText(...) and subsequent
logger.info(...) with try { ... } catch (err) { logger.error("Tuning Engines
example request failed", { error: err }) } so failures are logged instead of
crashing; reference the existing async IIFE, agent.generateText, and logger.info
to find where to add the try/catch.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8fe86834-8fd0-49a3-81a5-25dd41677456
📒 Files selected for processing (6)
examples/README.mdexamples/with-tuning-engines/.env.exampleexamples/with-tuning-engines/README.mdexamples/with-tuning-engines/package.jsonexamples/with-tuning-engines/src/index.tsexamples/with-tuning-engines/tsconfig.json
|
Thanks for the review notes. I pushed
Validation:
Both passed. |
Summary
Why
We are an AI infrastructure team using VoltAgent with Tuning Engines. VoltAgent remains the agent runtime for tools, memory, and server behavior; Tuning Engines provides a governed OpenAI-compatible endpoint for model access, policy checks, audit logs, traces, and usage/cost reporting. Since the examples already include provider/gateway setups such as OpenRouter, this gives teams using Tuning Engines a starter that matches the existing examples structure. It would mean a lot to us if this is useful, and I am happy to adjust the example to fit your conventions.
Validation
Summary by cubic
Adds a runnable
with-tuning-enginesexample that routes VoltAgent model calls through a governed OpenAI-compatible endpoint, with startup validation and logging. This enables policy checks, traces, and usage/cost reporting without changing agent code.examples/with-tuning-enginesusing@ai-sdk/openaiwith custombaseURLandTUNING_ENGINES_API_KEY; optionalTUNING_ENGINES_MODEL(defaultgpt-4o);.env.exampleadded; linked in the examples index.@voltagent/server-honowith LibSQL memory (@voltagent/libsql) and structured logging via@voltagent/logger.TUNING_ENGINES_API_KEYis missing; dev script usestsxwith.env.Written for commit 38f7fff. Summary will update on new commits.
Summary by CodeRabbit
New Features
Documentation