Skip to content

Commit d56eaf4

Browse files
authored
πŸ“¦ NEW: Readme writer agent (#90)
* πŸ“¦ NEW: Initial commit * πŸ‘Œ IMPROVE: Readme writer agent * πŸ‘Œ IMPROVE: Code * πŸ‘Œ IMPROVE: Code * πŸ‘Œ IMPROVE: Code * πŸ‘Œ IMPROVE: Readme
1 parent 716d8f4 commit d56eaf4

24 files changed

+654
-4
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# !! SERVER SIDE ONLY !!
2+
# Keep all your API keys secret β€” use only on the server side.
3+
4+
# TODO: ADD: Both in your production and local env files.
5+
# Langbase API key for your User or Org account.
6+
# How to get this API key https://langbase.com/docs/api-reference/api-keys
7+
LANGBASE_API_KEY=
8+
9+
# TODO: ADD: LOCAL ONLY. Add only to local env files.
10+
# Following keys are needed for local pipe runs. For providers you are using.
11+
# For Langbase, please add the key to your LLM keysets.
12+
# Read more: Langbase LLM Keysets https://langbase.com/docs/features/keysets
13+
OPENAI_API_KEY=
14+
ANTHROPIC_API_KEY=
15+
COHERE_API_KEY=
16+
FIREWORKS_API_KEY=
17+
GOOGLE_API_KEY=
18+
GROQ_API_KEY=
19+
MISTRAL_API_KEY=
20+
PERPLEXITY_API_KEY=
21+
TOGETHER_API_KEY=
22+
XAI_API_KEY=
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# baseai
2+
**/.baseai/
3+
# env file
4+
.env
5+
/baseai/memory/code-files/documents
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type {BaseAIConfig} from 'baseai';
2+
3+
export const config: BaseAIConfig = {
4+
log: {
5+
isEnabled: false,
6+
logSensitiveData: false,
7+
pipe: true,
8+
'pipe.completion': true,
9+
'pipe.request': true,
10+
'pipe.response': true,
11+
tool: true,
12+
memory: true,
13+
},
14+
memory: {
15+
useLocalEmbeddings: false,
16+
},
17+
envFilePath: '.env',
18+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import {MemoryI} from '@baseai/core';
2+
import path from 'path';
3+
4+
const memoryCodeFiles = (): MemoryI => ({
5+
name: 'code-files',
6+
description: 'Memory that contains project files',
7+
config: {
8+
useGitRepo: false,
9+
dirToTrack: path.posix.join('.'),
10+
extToTrack: ['*'],
11+
},
12+
});
13+
14+
export default memoryCodeFiles;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {PipeI} from '@baseai/core';
2+
import memoryCodeFiles from '../memory/code-files';
3+
4+
const pipeReadmeWriter = (): PipeI => ({
5+
// Replace with your API key https://langbase.com/docs/api-reference/api-keys
6+
apiKey: process.env.LANGBASE_API_KEY!,
7+
name: `readme-writer`,
8+
description: ``,
9+
status: `public`,
10+
model: `openai:gpt-4o-mini`,
11+
stream: true,
12+
json: false,
13+
store: true,
14+
moderate: true,
15+
top_p: 1,
16+
max_tokens: 1000,
17+
temperature: 0.7,
18+
presence_penalty: 0,
19+
frequency_penalty: 0,
20+
stop: [],
21+
tool_choice: 'auto',
22+
parallel_tool_calls: true,
23+
messages: [
24+
{
25+
role: 'system',
26+
content:
27+
'Write a {{level}} README file for an open-source project that effectively communicates its purpose, usage, installation instructions, and contribution guidelines.\n\nThe README should include the following sections:\n\n- **Project Title**: A clear and concise title of the project.\n- **Description**: A brief overview of what the project does and its significance.\n- **Installation Instructions**: Step-by-step guidance on how to install the project.\n- **Usage**: Examples demonstrating how to use the project.\n- **Contributing**: Guidelines for contributing to the project, including how to report issues and submit pull requests.\n- **License**: Information about the project\'s license.\n\n# Output Format\n\nThe output should be structured as a Markdown document with the appropriate headings for each section. Aim for a length of approximately 500-800 words.\n\n# Examples\n\n**Example 1:**\n\n**Input:** Project Title: "WeatherApp"\n**Output:**\n\n# WeatherApp\n\n## Description\nWeatherApp is a simple application that provides real-time weather updates for any location. It uses data from various weather APIs to fetch and display the latest weather information.\n\n## Installation Instructions\n1. Clone the repository: \\`git clone https://github.com/user/weatherapp.git\\`\n2. Navigate to the project directory: \\`cd weatherapp\\`\n3. Install dependencies: \\`npm install\\`\n\n## Usage\nTo run the application, use the command: \\`npm start\\`. Open your browser and go to \\`http://localhost:3000\\`.\n\n## Contributing\nWe welcome contributions! Please fork the repository and submit a pull request for any changes.\n\n## License\nThis project is licensed under the MIT License.\n\n**Example 2:**\n\n**Input:** Project Title: "TaskTracker"\n**Output:**\n\n# TaskTracker\n\n## Description\nTaskTracker is a web application designed to help users manage their tasks efficiently. It offers features like task creation, categorization, and progress tracking.\n\n## Installation Instructions\n1. Clone the repository: \\`git clone https://github.com/user/tasktracker.git\\`\n2. Install the required packages: \\`pip install -r requirements.txt\\`\n3. Run the application: \\`python app.py\\`\n\n## Usage\nOnce the application is running, navigate to \\`http://localhost:5000\\` to access the TaskTracker interface.\n\n## Contributing\nTo contribute, please read our contribution guidelines in the \\`CONTRIBUTING.md\\` file.\n\n## License\nThis project is licensed under the GPL-3.0 License.\n\n(Examples should include detailed project descriptions, installation steps, and usage instructions as they would appear for real open-source projects, using appropriate placeholders for project-specific details.)',
28+
},
29+
{name: 'json', role: 'system', content: ''},
30+
{name: 'safety', role: 'system', content: ''},
31+
{
32+
name: 'opening',
33+
role: 'system',
34+
content: 'Welcome to Langbase. Prompt away!',
35+
},
36+
{
37+
name: 'rag',
38+
role: 'system',
39+
content: `Below is some CONTEXT for you to answer the questions. ONLY generate readme from the CONTEXT. CONTEXT consists of multiple information chunks. `,
40+
},
41+
],
42+
variables: [{name: 'level', value: ''}],
43+
tools: [],
44+
memory: [memoryCodeFiles()],
45+
});
46+
47+
export default pipeReadmeWriter;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { PipeI } from '@baseai/core';
2+
3+
const pipeTest = (): PipeI => ({
4+
// Replace with your API key https://langbase.com/docs/api-reference/api-keys
5+
apiKey: process.env.LANGBASE_API_KEY!,
6+
name: 'test',
7+
description: '',
8+
status: 'public',
9+
model: 'openai:gpt-4o-mini',
10+
stream: true,
11+
json: false,
12+
store: true,
13+
moderate: true,
14+
top_p: 1,
15+
max_tokens: 1000,
16+
temperature: 0.7,
17+
presence_penalty: 1,
18+
frequency_penalty: 1,
19+
stop: [],
20+
tool_choice: 'auto',
21+
parallel_tool_calls: true,
22+
messages: [{ role: 'system', content: `You are a helpful AI assistant.` }],
23+
variables: [],
24+
memory: [],
25+
tools: []
26+
});
27+
28+
export default pipeTest;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env node
2+
import 'dotenv/config';
3+
import {init} from './utils/init';
4+
import {questions} from './utils/questions';
5+
import {startBaseAIDevServer} from './utils/start-baseai-server';
6+
import {copyProjectFiles} from './utils/copy-project-files';
7+
import {generateReadme} from './utils/generate-readme';
8+
import {exitServer} from './utils/exit-server';
9+
import {exit} from './utils/exit';
10+
import {generateEmbeddings} from './utils/generate-embeddings';
11+
import {dirName} from './utils/get-dirname';
12+
import {askOpenAIKey} from './utils/ask-openai-key';
13+
14+
(async function () {
15+
// Show the welcome message
16+
init({
17+
title: `readme-writer-agent`,
18+
tagLine: `by Saad Irfan`,
19+
description: `An AI agent to help you write README files for open-source projects.`,
20+
version: `0.1.0`,
21+
clear: true,
22+
});
23+
24+
// Ask for the OpenAI key if it doesn't exist
25+
await askOpenAIKey({dirName});
26+
27+
// Ask for the readme level
28+
const {level} = await questions();
29+
30+
// Start the baseAI server
31+
await startBaseAIDevServer();
32+
33+
// Copy project files in the memory
34+
await copyProjectFiles({dirName});
35+
36+
// Generate embeddings
37+
await generateEmbeddings({dirName});
38+
39+
// Generate the readme
40+
const {path} = await generateReadme({level});
41+
42+
// Exit the baseAI server
43+
await exitServer();
44+
45+
// Exit the process
46+
exit({path});
47+
})();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "readme-writer-agent",
3+
"version": "0.1.0",
4+
"description": "An AI agent to help you write README files for open-source projects.",
5+
"type": "module",
6+
"main": "./dist/index.js",
7+
"module": "./dist/index.mjs",
8+
"types": "./dist/index.d.ts",
9+
"bin": {
10+
"write-readme": "dist/index.js"
11+
},
12+
"files": [
13+
"dist/**",
14+
"baseai"
15+
],
16+
"scripts": {
17+
"build": "tsup",
18+
"dev": "tsup --watch",
19+
"write-readme": "NODE_NO_WARNINGS=1 npx tsx index.ts",
20+
"baseai": "baseai"
21+
},
22+
"repository": {
23+
"type": "git",
24+
"url": "git+https://github.com/LangbaseInc/baseai.git"
25+
},
26+
"keywords": [],
27+
"author": {
28+
"name": "Saad Irfan",
29+
"url": "https://github.com/msaaddev"
30+
},
31+
"license": "MIT",
32+
"dependencies": {
33+
"@baseai/core": "^0.9.20",
34+
"@clack/prompts": "^0.7.0",
35+
"chalk": "^5.3.0",
36+
"clear-any-console": "^1.16.2",
37+
"figures": "^6.1.0",
38+
"picocolors": "^1.1.0",
39+
"tsup": "^8.3.0"
40+
},
41+
"devDependencies": {
42+
"baseai": "^0.9.20"
43+
}
44+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
![IT Systems Triage Agent by ⌘ BaseAI][cover]
2+
3+
![License: MIT][mit] [![Fork on ⌘ Langbase][fork]][pipe]
4+
5+
## Description
6+
The `readme-writer-agent` is an AI-powered tool designed to assist developers in creating comprehensive README files for their open-source projects. This tool simplifies the process of structuring and writing documentation, ensuring that important information is communicated effectively.
7+
8+
This AI Agent is built using the BaseAI framework. It leverages an agentic pipe that integrates over 30+ LLMs (including OpenAI, Gemini, Mistral, Llama, Gemma, etc.) and can handle any data, with context sizes of up to 10M+ tokens, supported by memory. The framework is compatible with any front-end framework (such as React, Remix, Astro, Next.js), giving you, as a developer, the freedom to tailor your AI application exactly as you envision.
9+
10+
## How to use
11+
12+
Navigate to `examples/agents/readme-writer-agent` and run the following commands:
13+
14+
```sh
15+
# Navigate to baseai/examples/agents/readme-writer-agent
16+
cd examples/agents/readme-writer-agent
17+
18+
# Install the dependencies
19+
npm install
20+
21+
# Run the agent
22+
npm run write-readme
23+
```
24+
## Learn more
25+
26+
1. Check the [Learning path to build an agentic AI pipe with ⌘ BaseAI][learn]
27+
2. Read the [source code on GitHub][gh] for this agent example
28+
3. Go through Documentaion: [Pipe Quick Start][qs]
29+
4. Learn more about [Memory features in ⌘ BaseAI][memory]
30+
5. Learn more about [Tool calls support in ⌘ BaseAI][toolcalls]
31+
32+
33+
> NOTE:
34+
> This is a BaseAI project, you can deploy BaseAI pipes, memory and tool calls on Langbase.
35+
36+
---
37+
38+
## Authors
39+
40+
This project is created by [Langbase][lb] team members, with contributions from:
41+
42+
- [Saad Irfan](https://x.com/mrsaadirfan) - Founding Engineer, [Langbase][lb] <br>
43+
44+
45+
46+
47+
[lb]: https://langbase.com
48+
[pipe]: https://langbase.com/saadirfan/readme-writer
49+
[gh]: https://github.com/LangbaseInc/baseai/tree/main/examples/agents/readme-writer-agent
50+
[cover]:https://raw.githubusercontent.com/LangbaseInc/docs-images/main/baseai/baseai-cover.png
51+
[learn]:https://baseai.dev/learn
52+
[memory]:https://baseai.dev/docs/memory/quickstart
53+
[toolcalls]:https://baseai.dev/docs/tools/quickstart
54+
[deploy]:https://baseai.dev/docs/deployment/authentication
55+
[signup]: https://langbase.fyi/io
56+
[qs]:https://baseai.dev/docs/pipe/quickstart
57+
[docs]:https://baseai.dev/docs
58+
[mit]: https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&color=%23000000
59+
[fork]: https://img.shields.io/badge/FORK%20ON-%E2%8C%98%20Langbase-000000.svg?style=for-the-badge&logo=%E2%8C%98%20Langbase&logoColor=000000
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {defineConfig} from 'tsup';
2+
3+
export default defineConfig({
4+
clean: true,
5+
dts: true,
6+
entry: ['index.ts'],
7+
format: ['esm'],
8+
sourcemap: true,
9+
// target: 'esnext',
10+
target: 'node16',
11+
outDir: 'dist',
12+
splitting: false,
13+
bundle: true,
14+
minify: true,
15+
external: ['react', 'svelte', 'vue'],
16+
});

0 commit comments

Comments
Β (0)