diff --git a/README.md b/README.md index 21cfd635..34ea010f 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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**. @@ -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="" + LANGCHAIN_TRACING=true + LANGCHAIN_ENDPOINT="https://api.smith.langchain.com" + LANGCHAIN_API_KEY="" LANGCHAIN_PROJECT="" ``` - - 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. @@ -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) @@ -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 diff --git a/packages/backend/.env.example b/packages/backend/.env.example new file mode 100644 index 00000000..352d411b --- /dev/null +++ b/packages/backend/.env.example @@ -0,0 +1,4 @@ +LANGCHAIN_TRACING_V2=true +LANGCHAIN_ENDPOINT="https://api.smith.langchain.com" +LANGCHAIN_API_KEY=API_KEY +LANGCHAIN_PROJECT="cairocoder" \ No newline at end of file diff --git a/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts b/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts index 75ada29f..0c790fd0 100644 --- a/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts +++ b/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts @@ -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'; @@ -125,6 +122,6 @@ export class OpenZeppelinDocsIngester extends AsciiDocIngester { protected async createChunks( pages: BookPageDto[], ): Promise[]> { - return super.createChunks(pages, false); + return super.createChunks(pages, true); } }