/**
* Agentic chat using Mastra
*/
import { Agent } from '@mastra/core/agent';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { Memory } from '@mastra/memory'
import { LibSQLStore } from "@mastra/libsql";
const memory = new Memory({
storage: new LibSQLStore({
url: ':memory:',
}),
});
/**
* Create agentic chat agent
*/
export function createAgenticChatAgent(): Agent {
const openaiCompatible = createOpenAICompatible({
name: 'custom',
baseURL: process.env.OPENAI_BASE_URL!,
apiKey: process.env.OPENAI_API_KEY!,
includeUsage: true, // Include usage information in streaming responses
});
const agent = new Agent({
name: 'agentic-chat-agent',
description: 'A helpful AI assistant',
model: openaiCompatible(process.env.OPENAI_MODEL!),
instructions: 'You are a helpful assistant.',
memory
});
return agent;
}