Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Create a multi-agent research workflow where different AI agents collaborate to
- [Hugging Face (MCP)](./with-hugging-face-mcp) — Access HF tools and models through MCP from agents.
- [JWT Auth](./with-jwt-auth) — Protect agent endpoints with JWT verification and helpers.
- [Langfuse](./with-langfuse) — Send traces and metrics to Langfuse for observability.
- [Feedback Templates](./with-feedback) — Configure per-agent feedback templates for thumbs, numeric, and categorical feedback.
- [Live Evals](./with-live-evals) — Run online evaluations against prompts/agents during development.
- [MCP Basics](./with-mcp) — Connect to MCP servers and call tools from an agent.
- [MCP Elicitation](./with-mcp-elicitation) — Handle `elicitation/create` requests from MCP tools with per-request handlers.
Expand Down
3 changes: 3 additions & 0 deletions examples/with-feedback/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
OPENAI_API_KEY=your_openai_api_key_here
VOLTAGENT_PUBLIC_KEY=pk_your_public_key_here
VOLTAGENT_SECRET_KEY=sk_your_secret_key_here
5 changes: 5 additions & 0 deletions examples/with-feedback/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
.DS_Store
.env
.voltagent/
57 changes: 57 additions & 0 deletions examples/with-feedback/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# VoltAgent Feedback Templates

This example shows how to configure different feedback templates per agent so the Console can render thumbs, numeric sliders, and categorical options.

## Agents

- `thumbs` - boolean satisfaction signal (thumbs up/down)
- `rating` - continuous 1-5 rating slider
- `issues` - categorical issue type selection

## Setup

1. Install dependencies:

```bash
pnpm install
```

2. Copy the env file and set your keys:

```bash
cp .env.example .env
```

Update `OPENAI_API_KEY`, `VOLTAGENT_PUBLIC_KEY`, and `VOLTAGENT_SECRET_KEY` in `.env`.

3. Start the server:

```bash
pnpm dev
```

The server runs on `http://localhost:3141` by default.

## Usage

Send a message to any agent:

```bash
curl -X POST http://localhost:3141/agents/thumbs/chat \
-H "Content-Type: application/json" \
-d '{"input":"Give me a quick summary of VoltAgent."}'
```

```bash
curl -X POST http://localhost:3141/agents/rating/chat \
-H "Content-Type: application/json" \
-d '{"input":"Explain vector search in two sentences."}'
```

```bash
curl -X POST http://localhost:3141/agents/issues/chat \
-H "Content-Type: application/json" \
-d '{"input":"Draft a short welcome email."}'
```

Open the Console Observability Playground to test the feedback UI on each agent response.
36 changes: 36 additions & 0 deletions examples/with-feedback/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "voltagent-example-with-feedback",
"author": "",
"dependencies": {
"@ai-sdk/openai": "^3.0.0",
"@voltagent/cli": "^0.1.21",
"@voltagent/core": "^2.0.10",
"@voltagent/logger": "^2.0.2",
"@voltagent/server-hono": "^2.0.3",
"ai": "^6.0.0"
},
"devDependencies": {
"@types/node": "^24.2.1",
"tsx": "^4.19.3",
"typescript": "^5.8.2"
},
"keywords": [
"agent",
"ai",
"voltagent"
],
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/VoltAgent/voltagent.git",
"directory": "examples/with-feedback"
},
"scripts": {
"build": "tsc",
"dev": "tsx watch --env-file=.env ./src",
"start": "node dist/index.js",
"volt": "volt"
},
"type": "module"
}
67 changes: 67 additions & 0 deletions examples/with-feedback/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { openai } from "@ai-sdk/openai";
import { Agent, VoltAgent } from "@voltagent/core";
import { createPinoLogger } from "@voltagent/logger";
import { honoServer } from "@voltagent/server-hono";

const logger = createPinoLogger({
name: "with-feedback",
level: "info",
});

const thumbsAgent = new Agent({
name: "Thumbs Feedback Agent",
instructions: "You are a helpful assistant. Keep replies short and clear.",
model: openai("gpt-4o-mini"),
feedback: {
key: "satisfaction",
feedbackConfig: {
type: "categorical",
categories: [
{ value: 1, label: "Helpful" },
{ value: 0, label: "Not helpful" },
],
},
},
});

const ratingAgent = new Agent({
name: "Rating Feedback Agent",
instructions: "Respond in concise bullet points.",
model: openai("gpt-4o-mini"),
feedback: {
key: "relevance_score",
feedbackConfig: {
type: "continuous",
min: 1,
max: 5,
},
},
});

const issuesAgent = new Agent({
name: "Issue Tagging Agent",
instructions: "Answer clearly and include a short summary.",
model: openai("gpt-4o-mini"),
feedback: {
key: "issue_type",
feedbackConfig: {
type: "categorical",
categories: [
{ value: 1, label: "Incorrect" },
{ value: 2, label: "Incomplete" },
{ value: 3, label: "Unsafe" },
{ value: 4, label: "Other" },
],
},
},
});

new VoltAgent({
agents: {
thumbs: thumbsAgent,
rating: ratingAgent,
issues: issuesAgent,
},
server: honoServer(),
logger,
});
14 changes: 14 additions & 0 deletions examples/with-feedback/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"outDir": "dist",
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
Loading