Skip to content
Open
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: 0 additions & 3 deletions day-planner-agent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

Day Planner Agent is an AI-driven tool developed in Node.js, designed to assist in creating a professional daily schedule based on user tasks. It leverages the following core functionalities:

- Task Prioritization
- Schedule Optimization

## Features

- 📅 **Day Planning**
Expand Down
5 changes: 0 additions & 5 deletions email-agent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

Email Agent is an agent in Node.js built with Langbase, designed to assist in analyzing and managing email communications. It leverages the following core functionalities:

- Sentiment Analysis
- Content Summarization
- Response Decision Making
- Email Reply Generation

## Features

- 📧 **Email Analysis**
Expand Down
5 changes: 0 additions & 5 deletions feedback-agent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

Feedback Agent is an agent in Node.js built with Langbase, designed to assist in collecting and analyzing user feedback. It leverages the following core functionalities:

- Sentiment Analysis
- Content Summarization
- Response Decision Making
- Escalation Message Creation

## Features

- 📝 **Feedback Analysis**
Expand Down
4 changes: 0 additions & 4 deletions history-tutor-agent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

History Tutor Agent is an agent in Node.js built with Langbase, designed to assist in learning history by breaking down topics into smaller, distinct subtasks. It leverages the following core functionalities:

- Topic Analysis
- Subtask Generation
- Historical Synthesis

## Features

- 📚 **Historical Analysis**
Expand Down
3 changes: 3 additions & 0 deletions journalist-agent/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
LANGBASE_API_KEY= your-langbase-api-key
OPENAI_API_KEY= your-openai-api-key
EXA_API_KEY= your-exa-api-key
134 changes: 134 additions & 0 deletions journalist-agent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import { Langbase, Workflow } from 'langbase';
import dotenv from 'dotenv';

dotenv.config();

async function journalistWorkflow(input: string) {
const langbase = new Langbase({
apiKey: process.env.LANGBASE_API_KEY!
});

const { step } = new Workflow({
debug: true
});

// Step 1: Research the topic by searching the web
const searchResults = await step({
id: 'research_topic',
run: async () => {
return await langbase.tools.webSearch({
service: 'exa',
query: input,
totalResults: 5,
apiKey: process.env.EXA_API_KEY!
});
}
});

// Step 2: Retrieve journalism guidelines from memory
const journalismGuidelines = await step({
id: 'retrieve_guidelines',
run: async () => {
return await langbase.memories.retrieve({
query: 'journalism style guidelines and best practices',
memory: [{ name: 'journalism-guidelines-1747869545619' }]
});
}
});

// Step 3: Generate article outline
const articleOutline = await step({
id: 'generate_outline',
run: async () => {
const { output } = await langbase.agent.run({
model: 'openai:gpt-4.1-mini',
apiKey: process.env.OPENAI_API_KEY!,
instructions: `You are a professional journalist creating an article outline.
Based on the research provided, create a detailed outline for an article on the topic.
Include a compelling headline, introduction, 3-5 main sections, and conclusion.`,
input: [
{
role: 'user',
content: `Topic: ${input}\n\nResearch:\n${searchResults
.map(
result =>
`Source: ${result.url}\n${result.content}\n`
)
.join('\n')}`
}
],
stream: false
});
return output;
}
});

// Step 4: Write the full article
const draftArticle = await step({
id: 'write_article',
run: async () => {
const { output } = await langbase.agent.run({
model: 'openai:gpt-4.1-mini',
apiKey: process.env.OPENAI_API_KEY!,
instructions: `You are a professional journalist writing a high-quality article.
Follow the outline provided and incorporate information from the research.
Write in a clear, engaging, and informative style.
Include proper citations and quotes from sources where appropriate.
The article should be comprehensive, accurate, and well-structured.`,
input: [
{
role: 'user',
content: `Write a complete article based on this outline:\n${articleOutline}\n\nResearch sources:\n${searchResults
.map(
result =>
`Source: ${result.url}\n${result.content}\n`
)
.join('\n')}`
}
],
stream: false
});
return output;
}
});

// Step 5: Edit and refine the article
const finalArticle = await step({
id: 'edit_article',
run: async () => {
const { output } = await langbase.agent.run({
model: 'openai:gpt-4.1-mini',
apiKey: process.env.OPENAI_API_KEY!,
instructions: `You are a professional editor for the New York Times.
Review and refine the article to ensure it meets the highest journalistic standards.
Apply the journalism guidelines provided.
Check for accuracy, clarity, coherence, and proper citation of sources.
Improve the language, flow, and structure where needed.
Ensure the article is balanced, objective, and free of bias.
The final article should be publication-ready.`,
input: [
{
role: 'user',
content: `Edit and refine this article to meet New York Times standards:\n\n${draftArticle}\n\nJournalism Guidelines:\n${journalismGuidelines.map(item => item.text).join('\n')}`
}
],
stream: false
});
return output;
}
});

return {
article: finalArticle,
sources: searchResults.map(result => result.url)
};
}

async function main() {
const topic = 'The latest news on the stock market';
console.log('📰 Topic:', topic);
const result = await journalistWorkflow(topic);
return result;
}

main();
17 changes: 17 additions & 0 deletions journalist-agent/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "journalist-agent",
"version": "1.0.0",
"main": "index.js",
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"dotenv": "^16.4.7",
"langbase": "^1.1.55"
},
"devDependencies": {
"@types/node": "^22.15.2",
"tsx": "^4.19.1"
}
}
68 changes: 68 additions & 0 deletions journalist-agent/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
## Journalist Agent

Journalist Agent is a Node.js tool using [CHAI](https://chai.new) OpenAI and Exa to create high-quality articles. It automates research, writing, and editing, ensuring content meets New York Times standards.

## Features

- 📰 **Web Research**: Searches the web for relevant information with Exa.
- 📝 **Writing**: Writes an engaging article.
- 📝 **Editing**: Refines the article to New York Times standards.

## Get started

Let's get started with the project:

1. To get started with Langbase, you'll need to [create a free personal account on Langbase.com][signup] and verify your email address. Done? Cool, cool!

2. Download and setup the project

The following command:

- Downloads the example project folder from [here](https://download-directory.github.io/?url=https://github.com/LangbaseInc/awesome-agents/tree/main/journalist-agent)
- Renames the folder to journalist-agent
- Changes the directory to the project folder
- Copies the .env.example file to .env in the project folder

```bash
npx degit LangbaseInc/awesome-agents/journalist-agent journalist-agent &&
cd journalist-agent &&
cp .env.example .env
```

3. Add the values of these environment variables to the .env file:

```plaintext
# Get your org or user API key that can be used to access everything with Langbase.
# https://langbase.com/docs/api-reference/api-keys
LANGBASE_API_KEY="your-langbase-api-key"
OPENAI_API_KEY="your-openai-api-key"
```

4. Install dependencies:

```bash
pnpm install

# OR
npm install
```

5. Run the journalist-agent:

```bash
pnpm dlx tsx index.ts

# OR
npx tsx index.ts
```

## Project Structure

```
journalist-agent/
├── .env.example # Environment variables example
├── .gitignore # Git ignore
├── index.ts # Journalist agent implementation
├── package.json # Node.js package configuration and dependencies
└── readme.md # Project documentation
```
12 changes: 12 additions & 0 deletions journalist-agent/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"rootDir": "./",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
2 changes: 2 additions & 0 deletions maths-solver-agent/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LANGBASE_API_KEY= your-langbase-api-key
OPENAI_API_KEY= your-openai-api-key
94 changes: 94 additions & 0 deletions maths-solver-agent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { Langbase, Workflow } from 'langbase';
import { z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import dotenv from 'dotenv';

dotenv.config();

// Define schema for structured output
const mathSolutionSchema = z.object({
problem: z.string().describe('The original math problem'),
steps: z.array(
z.object({
step: z.number().describe('Step number'),
description: z.string().describe('Description of this step'),
calculation: z
.string()
.describe('The calculation or mathematical work for this step'),
explanation: z
.string()
.describe('Explanation of the reasoning behind this step')
})
),
finalAnswer: z.string().describe('The final answer to the problem'),
additionalNotes: z
.string()
.describe('Any additional notes or alternative approaches')
});

// Convert zod schema to JSON schema
const mathSolutionJsonSchema = zodToJsonSchema(mathSolutionSchema, {
target: 'openAi'
});

async function mathSolverWorkflow(input: string) {
const langbase = new Langbase({
apiKey: process.env.LANGBASE_API_KEY!
});

const { step } = new Workflow({
debug: true
});

// Step 2: Solve the math problem with structured output
const solution = await step({
id: 'solve_problem',
run: async () => {
const response = await langbase.agent.run({
model: 'openai:gpt-4.1-mini',
apiKey: process.env.OPENAI_API_KEY!,
instructions: `You are an expert math tutor. Solve the given math problem step by step, showing all your work clearly.
Break down complex problems into manageable steps. Explain your reasoning at each step.
For algebraic problems, show each transformation of the equation.
For calculus problems, explain the concepts and techniques you're using.
For geometry problems, include relevant theorems and properties.
For word problems, explain how you translate the problem into mathematical form.
Always verify your answer by checking if it satisfies the original problem.`,
input: [{ role: 'user', content: input }],
stream: false,
response_format: {
type: 'json_schema',
json_schema: {
name: 'MathSolution',
schema: mathSolutionJsonSchema,
strict: true
}
}
});

return JSON.parse(response.output);
}
});

return solution;
}

async function main() {
try {
// Handle both direct input and file uploads
let question =
'There are 49 dogs signed up for a dog show. There are 36 more small dogs than large dogs. How many small dogs have signed up to compete?';
console.log('🔢 Question:', question);
const result = await mathSolverWorkflow(question);
return result;
} catch (error) {
console.error('Error in math solver workflow:', error);
return {
error:
error || 'An error occurred while processing the math problem',
status: 500
};
}
}

main();
Loading