diff --git a/README.md b/README.md index db00951a..f7f7132f 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,25 @@ There are mainly 2 ways of installing Cairo Coder - With Docker, Without Docker. database, while the second is used by your application to connect to it. -7. Run the application using one of the following methods: +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_PROJECT="" + ``` + + 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: ```bash docker-compose up --build diff --git a/docker-compose.yml b/docker-compose.yml index 5db2513c..03ac6b06 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,8 @@ services: - 3001:3001 extra_hosts: - host.docker.internal:host-gateway + env_file: + - packages/backend/.env depends_on: postgres: condition: service_started diff --git a/packages/backend/package.json b/packages/backend/package.json index 8d7ebaaf..40024caf 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -12,15 +12,16 @@ "check-types": "tsc --noEmit" }, "dependencies": { + "@cairo-coder/agents": "workspace:*", "@iarna/toml": "^2.2.5", "@langchain/anthropic": "^0.2.18", "@langchain/community": "^0.3.32", "@langchain/core": "^0.2.36", "@langchain/google-genai": "^0.1.8", "@langchain/openai": "^0.0.25", - "@cairo-coder/agents": "workspace:*", "@types/node": "^20", "cors": "^2.8.5", + "dotenv": "^16.4.7", "express": "^4.21.2", "node-fetch": "2.7.0", "uuid": "^11.1.0", diff --git a/packages/backend/src/app.ts b/packages/backend/src/app.ts index 41492e3e..65a2aa1c 100644 --- a/packages/backend/src/app.ts +++ b/packages/backend/src/app.ts @@ -1,5 +1,8 @@ import { createApplication } from './server'; import { logger } from '@cairo-coder/agents/utils/index'; +import dotenv from 'dotenv'; + +dotenv.config(); // Error handling for uncaught exceptions process.on('uncaughtException', (err, origin) => { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16117a5b..f761bb3c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: devDependencies: turbo: specifier: latest - version: 2.5.0 + version: 2.5.2 typescript: specifier: ^5.7.2 version: 5.7.3 @@ -22,19 +22,19 @@ importers: version: 2.2.5 '@langchain/anthropic': specifier: ^0.2.18 - version: 0.2.18(openai@4.85.3(ws@8.18.1)(zod@3.24.2)) + version: 0.2.18(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) '@langchain/community': specifier: ^0.3.32 - version: 0.3.32(@browserbasehq/sdk@2.3.0)(@browserbasehq/stagehand@1.13.0(@playwright/test@1.50.1)(deepmerge@4.3.1)(dotenv@16.4.7)(openai@4.85.3(ws@8.18.1)(zod@3.24.2))(zod@3.24.2))(@ibm-cloud/watsonx-ai@1.5.0(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2))))(@langchain/anthropic@0.2.18(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(@langchain/google-genai@0.1.8(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2))(axios@1.7.9)(fast-xml-parser@4.5.3)(handlebars@4.7.8)(html-to-text@9.0.5)(ibm-cloud-sdk-core@5.1.3)(ignore@5.3.2)(jsonwebtoken@9.0.2)(mongodb@6.13.1)(openai@4.85.3(ws@8.18.1)(zod@3.24.2))(pg@8.14.1)(playwright@1.50.1)(ws@8.18.1) + version: 0.3.32(@browserbasehq/sdk@2.3.0)(@browserbasehq/stagehand@1.13.0(@playwright/test@1.50.1)(deepmerge@4.3.1)(dotenv@16.4.7)(openai@4.85.4(ws@8.18.1)(zod@3.24.2))(zod@3.24.2))(@ibm-cloud/watsonx-ai@1.5.0(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2))))(@langchain/anthropic@0.2.18(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(@langchain/google-genai@0.1.8(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2))(axios@1.7.9)(fast-xml-parser@4.5.3)(handlebars@4.7.8)(html-to-text@9.0.5)(ibm-cloud-sdk-core@5.1.3)(ignore@5.3.2)(jsonwebtoken@9.0.2)(mongodb@6.13.1)(openai@4.85.4(ws@8.18.1)(zod@3.24.2))(pg@8.14.1)(playwright@1.50.1)(ws@8.18.1) '@langchain/core': specifier: ^0.2.36 - version: 0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)) + version: 0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) '@langchain/google-genai': specifier: ^0.1.8 - version: 0.1.8(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2) + version: 0.1.8(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2) '@langchain/mongodb': specifier: ^0.0.5 - version: 0.0.5(openai@4.85.3(ws@8.18.1)(zod@3.24.2)) + version: 0.0.5(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) '@langchain/openai': specifier: ^0.0.25 version: 0.0.25(ws@8.18.1) @@ -102,33 +102,36 @@ importers: packages/backend: dependencies: + '@cairo-coder/agents': + specifier: workspace:* + version: link:../agents '@iarna/toml': specifier: ^2.2.5 version: 2.2.5 '@langchain/anthropic': specifier: ^0.2.18 - version: 0.2.18(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) + version: 0.2.18(openai@4.85.3(ws@8.18.1)(zod@3.24.2)) '@langchain/community': specifier: ^0.3.32 - version: 0.3.32(@browserbasehq/sdk@2.3.0)(@browserbasehq/stagehand@1.13.0(@playwright/test@1.50.1)(deepmerge@4.3.1)(dotenv@16.4.7)(openai@4.85.4(ws@8.18.1)(zod@3.24.2))(zod@3.24.2))(@ibm-cloud/watsonx-ai@1.5.0(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2))))(@langchain/anthropic@0.2.18(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(@langchain/google-genai@0.1.8(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2))(axios@1.7.9)(fast-xml-parser@4.5.3)(handlebars@4.7.8)(html-to-text@9.0.5)(ibm-cloud-sdk-core@5.1.3)(ignore@5.3.2)(jsonwebtoken@9.0.2)(mongodb@6.13.1)(openai@4.85.4(ws@8.18.1)(zod@3.24.2))(pg@8.14.1)(playwright@1.50.1)(ws@8.18.1) + version: 0.3.32(@browserbasehq/sdk@2.3.0)(@browserbasehq/stagehand@1.13.0(@playwright/test@1.50.1)(deepmerge@4.3.1)(dotenv@16.4.7)(openai@4.85.3(ws@8.18.1)(zod@3.24.2))(zod@3.24.2))(@ibm-cloud/watsonx-ai@1.5.0(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2))))(@langchain/anthropic@0.2.18(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(@langchain/google-genai@0.1.8(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2))(axios@1.7.9)(fast-xml-parser@4.5.3)(handlebars@4.7.8)(html-to-text@9.0.5)(ibm-cloud-sdk-core@5.1.3)(ignore@5.3.2)(jsonwebtoken@9.0.2)(mongodb@6.13.1)(openai@4.85.3(ws@8.18.1)(zod@3.24.2))(pg@8.14.1)(playwright@1.50.1)(ws@8.18.1) '@langchain/core': specifier: ^0.2.36 - version: 0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) + version: 0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)) '@langchain/google-genai': specifier: ^0.1.8 - version: 0.1.8(@langchain/core@0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2) + version: 0.1.8(@langchain/core@0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)))(zod@3.24.2) '@langchain/openai': specifier: ^0.0.25 version: 0.0.25(ws@8.18.1) - '@cairo-coder/agents': - specifier: workspace:* - version: link:../agents '@types/node': specifier: ^20 version: 20.0.0 cors: specifier: ^2.8.5 version: 2.8.5 + dotenv: + specifier: ^16.4.7 + version: 16.4.7 express: specifier: ^4.21.2 version: 4.21.2 @@ -193,18 +196,18 @@ importers: '@asciidoctor/tabs': specifier: 1.0.0-beta.6 version: 1.0.0-beta.6 - '@iarna/toml': - specifier: ^2.2.5 - version: 2.2.5 - '@langchain/core': - specifier: ^0.2.36 - version: 0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) '@cairo-coder/agents': specifier: workspace:* version: link:../agents '@cairo-coder/backend': specifier: workspace:* version: link:../backend + '@iarna/toml': + specifier: ^2.2.5 + version: 2.2.5 + '@langchain/core': + specifier: ^0.2.36 + version: 0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) adm-zip: specifier: ^0.5.16 version: 0.5.16 @@ -3209,38 +3212,38 @@ packages: '@swc/wasm': optional: true - turbo-darwin-64@2.5.0: - resolution: {integrity: sha512-fP1hhI9zY8hv0idym3hAaXdPi80TLovmGmgZFocVAykFtOxF+GlfIgM/l4iLAV9ObIO4SUXPVWHeBZQQ+Hpjag==} + turbo-darwin-64@2.5.2: + resolution: {integrity: sha512-2aIl0Sx230nLk+Cg2qSVxvPOBWCZpwKNuAMKoROTvWKif6VMpkWWiR9XEPoz7sHeLmCOed4GYGMjL1bqAiIS/g==} cpu: [x64] os: [darwin] - turbo-darwin-arm64@2.5.0: - resolution: {integrity: sha512-p9sYq7kXH7qeJwIQE86cOWv/xNqvow846l6c/qWc26Ib1ci5W7V0sI5thsrP3eH+VA0d+SHalTKg5SQXgNQBWA==} + turbo-darwin-arm64@2.5.2: + resolution: {integrity: sha512-MrFYhK/jYu8N6QlqZtqSHi3e4QVxlzqU3ANHTKn3/tThuwTLbNHEvzBPWSj5W7nZcM58dCqi6gYrfRz6bJZyAA==} cpu: [arm64] os: [darwin] - turbo-linux-64@2.5.0: - resolution: {integrity: sha512-1iEln2GWiF3iPPPS1HQJT6ZCFXynJPd89gs9SkggH2EJsj3eRUSVMmMC8y6d7bBbhBFsiGGazwFIYrI12zs6uQ==} + turbo-linux-64@2.5.2: + resolution: {integrity: sha512-LxNqUE2HmAJQ/8deoLgMUDzKxd5bKxqH0UBogWa+DF+JcXhtze3UTMr6lEr0dEofdsEUYK1zg8FRjglmwlN5YA==} cpu: [x64] os: [linux] - turbo-linux-arm64@2.5.0: - resolution: {integrity: sha512-bKBcbvuQHmsX116KcxHJuAcppiiBOfivOObh2O5aXNER6mce7YDDQJy00xQQNp1DhEfcSV2uOsvb3O3nN2cbcA==} + turbo-linux-arm64@2.5.2: + resolution: {integrity: sha512-0MI1Ao1q8zhd+UUbIEsrM+yLq1BsrcJQRGZkxIsHFlGp7WQQH1oR3laBgfnUCNdCotCMD6w4moc9pUbXdOR3bg==} cpu: [arm64] os: [linux] - turbo-windows-64@2.5.0: - resolution: {integrity: sha512-9BCo8oQ7BO7J0K913Czbc3tw8QwLqn2nTe4E47k6aVYkM12ASTScweXPTuaPFP5iYXAT6z5Dsniw704Ixa5eGg==} + turbo-windows-64@2.5.2: + resolution: {integrity: sha512-hOLcbgZzE5ttACHHyc1ajmWYq4zKT42IC3G6XqgiXxMbS+4eyVYTL+7UvCZBd3Kca1u4TLQdLQjeO76zyDJc2A==} cpu: [x64] os: [win32] - turbo-windows-arm64@2.5.0: - resolution: {integrity: sha512-OUHCV+ueXa3UzfZ4co/ueIHgeq9B2K48pZwIxKSm5VaLVuv8M13MhM7unukW09g++dpdrrE1w4IOVgxKZ0/exg==} + turbo-windows-arm64@2.5.2: + resolution: {integrity: sha512-fMU41ABhSLa18H8V3Z7BMCGynQ8x+wj9WyBMvWm1jeyRKgkvUYJsO2vkIsy8m0vrwnIeVXKOIn6eSe1ddlBVqw==} cpu: [arm64] os: [win32] - turbo@2.5.0: - resolution: {integrity: sha512-PvSRruOsitjy6qdqwIIyolv99+fEn57gP6gn4zhsHTEcCYgXPhv6BAxzAjleS8XKpo+Y582vTTA9nuqYDmbRuA==} + turbo@2.5.2: + resolution: {integrity: sha512-Qo5lfuStr6LQh3sPQl7kIi243bGU4aHGDQJUf6ylAdGwks30jJFloc9NYHP7Y373+gGU9OS0faA4Mb5Sy8X9Xw==} hasBin: true type-detect@4.0.8: @@ -4138,9 +4141,9 @@ snapshots: transitivePeerDependencies: - zod - '@langchain/mongodb@0.0.5(openai@4.85.3(ws@8.18.1)(zod@3.24.2))': + '@langchain/mongodb@0.0.5(openai@4.85.4(ws@8.18.1)(zod@3.24.2))': dependencies: - '@langchain/core': 0.2.36(openai@4.85.3(ws@8.18.1)(zod@3.24.2)) + '@langchain/core': 0.2.36(openai@4.85.4(ws@8.18.1)(zod@3.24.2)) mongodb: 6.13.1 transitivePeerDependencies: - '@aws-sdk/credential-providers' @@ -6581,32 +6584,32 @@ snapshots: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 - turbo-darwin-64@2.5.0: + turbo-darwin-64@2.5.2: optional: true - turbo-darwin-arm64@2.5.0: + turbo-darwin-arm64@2.5.2: optional: true - turbo-linux-64@2.5.0: + turbo-linux-64@2.5.2: optional: true - turbo-linux-arm64@2.5.0: + turbo-linux-arm64@2.5.2: optional: true - turbo-windows-64@2.5.0: + turbo-windows-64@2.5.2: optional: true - turbo-windows-arm64@2.5.0: + turbo-windows-arm64@2.5.2: optional: true - turbo@2.5.0: + turbo@2.5.2: optionalDependencies: - turbo-darwin-64: 2.5.0 - turbo-darwin-arm64: 2.5.0 - turbo-linux-64: 2.5.0 - turbo-linux-arm64: 2.5.0 - turbo-windows-64: 2.5.0 - turbo-windows-arm64: 2.5.0 + turbo-darwin-64: 2.5.2 + turbo-darwin-arm64: 2.5.2 + turbo-linux-64: 2.5.2 + turbo-linux-arm64: 2.5.2 + turbo-windows-64: 2.5.2 + turbo-windows-arm64: 2.5.2 type-detect@4.0.8: {}