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
30 changes: 14 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Cairo Coder is an intelligent code generation service that makes writing Cairo s
- **Multiple LLM Support**: Works with OpenAI, Anthropic, and Google models
- **Source-Informed Generation**: Code is generated based on Cairo documentation, ensuring correctness


## Installation

There are mainly 2 ways of installing Cairo Coder - With Docker, Without Docker. Using Docker is highly recommended.
Expand All @@ -68,7 +67,6 @@ There are mainly 2 ways of installing Cairo Coder - With Docker, Without Docker.
pnpm install
```


5. Inside the packages/agents package, copy the `sample.config.toml` file to a `config.toml`. For development setups, you need only fill in the following fields:

- `OPENAI`: Your OpenAI API key. **You only need to fill this if you wish to use OpenAI's models**.
Expand Down Expand Up @@ -115,45 +113,45 @@ There are mainly 2 ways of installing Cairo Coder - With Docker, Without Docker.
```

This configuration is used by the backend and ingester services to connect to the database.
Note that `POSTGRES_HOST` is set to ```"postgres"``` and `POSTGRES_PORT` to ```"5432"```, which are the container's name and port in docker-compose.yml.
Note that `POSTGRES_HOST` is set to `"postgres"` and `POSTGRES_PORT` to `"5432"`, which are the container's name and port in docker-compose.yml.

**Important:** Make sure to use the same password, username and db's name in both files. The first file initializes the database, while the second is used by your application to connect to it.


7. **Configure LangSmith (Optional)**

Cairo Coder can use LangSmith to record and monitor LLM calls. This step is optional but recommended for development and debugging.

- Create an account at [LangSmith](https://smith.langchain.com/)
- Create a new project in the LangSmith dashboard
- Retrieve your API credentials
- Create a `.env` file in the `packages/backend` directory with the following variables:

```
LANGSMITH_TRACING=true
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
LANGSMITH_API_KEY="<your-api-key>"
LANGCHAIN_TRACING=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY="<your-api-key>"
LANGCHAIN_PROJECT="<your-project-name>"
```
- Add the `.env` in an env_file section in the backend service of the docker-compose.yml

With this configuration, all LLM calls and chain executions will be logged to your LangSmith project, allowing you to debug, analyze, and improve the system's performance.
- Add the `packages/backend/.env` in an env_file section in the backend service of the docker-compose.yml

With this configuration, all LLM calls and chain executions will be logged to your LangSmith project, allowing you to debug, analyze, and improve the system's performance.

9. Run the application using one of the following methods:
8. Run the application using one of the following methods:

```bash
docker compose up postgres backend
```

8. The API will be available at http://localhost:3001/v1/chat/completions
9. The API will be available at http://localhost:3001/v1/chat/completions

## Running the Ingester

After you have the main application running, you might need to run the ingester to process and embed documentation from various sources. The ingester is configured as a separate profile in the docker-compose file and can be executed as follows:

```bash
docker compose up ingester
```
```bash
docker compose up ingester
```

Once the ingester completes its task, the vector database will be populated with embeddings from all the supported documentation sources, making them available for RAG-based code generation requests to the API.

Expand Down Expand Up @@ -188,6 +186,7 @@ curl -X POST http://localhost:3001/v1/chat/completions \
The API accepts all standard OpenAI Chat Completions parameters.

**Supported Parameters:**

- `model`: Model identifier (string)
- `messages`: Array of message objects with `role` and `content`
- `temperature`: Controls randomness (0-2, default: 0.7)
Expand All @@ -202,7 +201,6 @@ The API accepts all standard OpenAI Chat Completions parameters.
- `user`: User identifier
- `response_format`: Response format specification


### Response Format

#### Standard Mode Response
Expand Down
4 changes: 4 additions & 0 deletions packages/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LANGCHAIN_TRACING_V2=true
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_API_KEY=API_KEY
LANGCHAIN_PROJECT="cairocoder"
7 changes: 2 additions & 5 deletions packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import * as fs from 'fs';
import * as fsPromises from 'fs/promises';
import * as path from 'path';
import { Document } from '@langchain/core/documents';
import {
BookChunk,
DocumentSource,
} from '@cairo-coder/agents/types/index';
import { BookChunk, DocumentSource } from '@cairo-coder/agents/types/index';
import { BookConfig, BookPageDto } from '../utils/types';
import { logger } from '@cairo-coder/agents/utils/index';
import { AsciiDocIngesterConfig } from './AsciiDocIngester';
Expand Down Expand Up @@ -125,6 +122,6 @@ export class OpenZeppelinDocsIngester extends AsciiDocIngester {
protected async createChunks(
pages: BookPageDto[],
): Promise<Document<BookChunk>[]> {
return super.createChunks(pages, false);
return super.createChunks(pages, true);
}
}