From f993bbeeae703b96b5438902b9e50a65baa9f052 Mon Sep 17 00:00:00 2001 From: alvinouille Date: Fri, 20 Jun 2025 12:04:02 +0200 Subject: [PATCH 1/2] fix: temporary fix OZ ingester, and langmisth supportn doc --- README.md | 8 ++++---- packages/backend/.env.example | 4 ++++ .../ingester/src/ingesters/OpenZeppelinDocsIngester.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 packages/backend/.env.example diff --git a/README.md b/README.md index 21cfd635..e7e5934e 100644 --- a/README.md +++ b/README.md @@ -129,12 +129,12 @@ There are mainly 2 ways of installing Cairo Coder - With Docker, Without Docker. - 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 + - 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. 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..2982a240 100644 --- a/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts +++ b/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts @@ -125,6 +125,6 @@ export class OpenZeppelinDocsIngester extends AsciiDocIngester { protected async createChunks( pages: BookPageDto[], ): Promise[]> { - return super.createChunks(pages, false); + return super.createChunks(pages, true); } } From cbfd500368c454dced0aa28a1057638e3654a2a5 Mon Sep 17 00:00:00 2001 From: alvinouille Date: Fri, 20 Jun 2025 12:07:42 +0200 Subject: [PATCH 2/2] fix: trunk format --- README.md | 24 +++++++++---------- .../src/ingesters/OpenZeppelinDocsIngester.ts | 5 +--- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index e7e5934e..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: + ``` LANGCHAIN_TRACING=true LANGCHAIN_ENDPOINT="https://api.smith.langchain.com" LANGCHAIN_API_KEY="" LANGCHAIN_PROJECT="" ``` - - 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. + - 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/ingester/src/ingesters/OpenZeppelinDocsIngester.ts b/packages/ingester/src/ingesters/OpenZeppelinDocsIngester.ts index 2982a240..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';