Skip to content

Latest commit

 

History

History

simple-chatbot

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Simple Chatbot Example

A basic conversational agent using RunMesh.

Features

  • Basic conversation flow
  • No external dependencies
  • Demonstrates core agent functionality

Setup

npm install
cp .env.example .env
# Add your API key to .env

Run

npm start

Code Walkthrough

import { createAgent } from "@runmesh/agent";
import { createOpenRouterConfig, createFromProvider } from "@runmesh/core";

// Create client with OpenRouter (or use OpenAI, Anthropic)
const client = createFromProvider(
  createOpenRouterConfig(process.env.OPENROUTER_API_KEY!, "claude-3.5-sonnet")
);

// Create agent
const agent = createAgent({
  name: "chatbot",
  client,
  model: "anthropic/claude-3.5-sonnet",
  systemPrompt: "You are a friendly chatbot. Be concise and helpful."
});

// Run a query
const result = await agent.run("Hello! What can you do?");
console.log(result.response.choices[0]?.message?.content);

Customization

Change the Model

// Use GPT-4
const client = createFromProvider(createOpenRouterConfig(key, "gpt-4o"));

// Use Gemini
const client = createFromProvider(createOpenRouterConfig(key, "gemini-pro"));

Adjust System Prompt

const agent = createAgent({
  name: "chatbot",
  client,
  systemPrompt: "You are a pirate. Speak like one! Arr!"
});

Next Steps