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
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: voltagent
8 changes: 2 additions & 6 deletions examples/base/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "voltagent-example-base",
"private": true,
"keywords": [
"voltagent",
"ai",
"agent"
],
"keywords": ["voltagent", "ai", "agent"],
"license": "MIT",
"author": "",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx watch --env-file=.env ./src -- --trace-warnings",
"dev": "tsx watch --env-file=.env ./src",
"start": "node dist/index.js",
"volt": "volt"
},
Expand Down
1 change: 1 addition & 0 deletions examples/with-rag-chatbot/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OPENAI_API_KEY=sk-proj-
4 changes: 4 additions & 0 deletions examples/with-rag-chatbot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.env
.voltagent
28 changes: 28 additions & 0 deletions examples/with-rag-chatbot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "with-rag-chatbot",
"version": "0.0.1",
"private": true,
"description": "VoltAgent RAG Chatbot Example",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx watch --env-file=.env ./src",
"start": "node dist/index.js",
"volt": "volt"
},
"dependencies": {
"@ai-sdk/openai": "^1.3.10",
"@voltagent/cli": "^0.1.2",
"@voltagent/core": "^0.1.4",
"@voltagent/vercel-ai": "^0.1.2",
"zod": "^3.24.2"
},
"devDependencies": {
"@types/node": "^22.13.5",
"tsx": "^4.19.3",
"typescript": "^5.8.2"
},
"engines": {
"node": ">=18"
}
}
71 changes: 71 additions & 0 deletions examples/with-rag-chatbot/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { VoltAgent, Agent, BaseRetriever, type BaseMessage } from "@voltagent/core";
import { VercelAIProvider } from "@voltagent/vercel-ai";
import { openai } from "@ai-sdk/openai";

// --- Simple Knowledge Base Retriever ---

class KnowledgeBaseRetriever extends BaseRetriever {
// Our tiny "knowledge base"
private documents = [
{
id: "doc1",
content: "What is VoltAgent? VoltAgent is a TypeScript framework for building AI agents.",
},
{
id: "doc2",
content:
"What features does VoltAgent support? VoltAgent supports tools, memory, sub-agents, and retrievers for RAG.",
},
{ id: "doc3", content: "What is RAG? RAG stands for Retrieval-Augmented Generation." },
{
id: "doc4",
content:
"How can I test my agent? You can test VoltAgent agents using the VoltAgent Console.",
},
];

// Reverting to simple retrieve logic
async retrieve(input: string | BaseMessage[]): Promise<string> {
const query = typeof input === "string" ? input : (input[input.length - 1].content as string);
const queryLower = query.toLowerCase();
console.log(`[KnowledgeBaseRetriever] Searching for context related to: "${query}"`);

// Simple includes check
const relevantDocs = this.documents.filter((doc) =>
doc.content.toLowerCase().includes(queryLower),
);

if (relevantDocs.length > 0) {
const contextString = relevantDocs.map((doc) => `- ${doc.content}`).join("\n");
console.log(`[KnowledgeBaseRetriever] Found context:\n${contextString}`);
return `Relevant Information Found:\n${contextString}`;
}

console.log("[KnowledgeBaseRetriever] No relevant context found.");
return "No relevant information found in the knowledge base.";
}
}

// --- Agent Definition ---

// Instantiate the retriever
const knowledgeRetriever = new KnowledgeBaseRetriever();

// Define the agent that uses the retriever directly
const ragAgent = new Agent({
name: "RAG Chatbot",
description: "A chatbot that answers questions based on its internal knowledge base.",
llm: new VercelAIProvider(), // Using Vercel AI SDK Provider
model: openai("gpt-4o-mini"), // Using OpenAI model via Vercel
// Attach the retriever directly
retriever: knowledgeRetriever,
});

// --- VoltAgent Initialization ---

new VoltAgent({
agents: {
// Make the agent available under the key 'ragAgent'
ragAgent,
},
});
12 changes: 12 additions & 0 deletions examples/with-rag-chatbot/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"outDir": "dist",
"strict": true,
"skipLibCheck": true
},
"include": ["src"]
}
8 changes: 2 additions & 6 deletions examples/with-supabase/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
{
"name": "voltagent-example-with-supabase",
"private": true,
"keywords": [
"voltagent",
"ai",
"agent"
],
"keywords": ["voltagent", "ai", "agent"],
"license": "MIT",
"author": "",
"type": "module",
"scripts": {
"build": "tsc",
"dev": "tsx watch --env-file=.env ./src -- --trace-warnings",
"dev": "tsx watch --env-file=.env ./src",
"start": "node dist/index.js",
"volt": "volt"
},
Expand Down
28 changes: 28 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading