GithubHelp home page GithubHelp logo

bcg-x-official / agentkit Goto Github PK

View Code? Open in Web Editor NEW
1.5K 23.0 202.0 35.99 MB

Starter-kit to build constrained agents with Nextjs, FastAPI and Langchain

Home Page: https://agentkit.infra.x.bcg.com/

License: MIT License

Makefile 1.22% Dockerfile 0.54% Python 45.73% Mako 0.14% JavaScript 1.65% Shell 0.23% TypeScript 49.06% Gherkin 0.59% CSS 0.83%
fastapi full-stack genai genai-chatbot genai-poc langchain langchain-python nextjs openai react

agentkit's Issues

Update calls of `arun` to `ainvoke` for langchain chat models

Using the arun methods to call a chat model -- which is what we currently do -- gives the following warning: LangChainDeprecationWarning: The function arun was deprecated in LangChain 0.1.0 and will be removed in 0.2.0. Use ainvoke instead.

arun will be removed in langchain==0.2.0 (currently at 0.1.14) so we should update this sooner rather than later

Warning: Beware of the risks of running SQL queries from frontend in public-facing apps, especially with LLMs

Beware of the risks of using running SQL queries directly from client side in public-facing applications, especially with LLMs, due to SQL & prompt injection risks. The SQL Tool in the tool library is not recommended to be used in public-facing applications due to these risks. PR 55 introduces more filters for malignant SQL queries / script injections, but do not guarantee protection against all attacks, as there are inherent risks in executing unparametrized SQL queries.

See LangChain's note on a similar topic (link):
"Building Q&A systems of SQL databases requires executing model-generated SQL queries. There are inherent risks in doing this. Make sure that your database connection permissions are always scoped as narrowly as possible for your chain/agent's needs. This will mitigate though not eliminate the risks of building a model-driven system. For more on general security best practices, see here

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Describe the bug
Error message, when starting:
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Seems Next/Node memory parameter is too small, in the Docker container.
I tried adding some NODE_OPTIONS to increase memory up to 4096M.
Got a different error, but still does not work.
At exact same place.

I expect it works out of the box.

Steps To Reproduce
When running command, as described in the documentation:
docker-compose -f docker-compose.yml up -d

Desktop (please complete the following information):

  • OS: MacOS
  • MacBook Air (Intel), last one before M1.
  • Browser: Brave
  • Python 3.11.5

Additional context
Logs:
[+] Building 110.8s (17/20) docker:desktop-linux
=> [nextjs_server internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 1.60kB 0.0s
=> [nextjs_server internal] load metadata for docker.io/library/node:18-alpine 1.7s
=> [nextjs_server auth] library/node:pull token for registry-1.docker.io 0.0s
=> [nextjs_server internal] load .dockerignore 0.0s
=> => transferring context: 113B 0.0s
=> [nextjs_server internal] load build context 0.2s
=> => transferring context: 471.94kB 0.1s
=> [nextjs_server base 1/1] FROM docker.io/library/node:18-alpine@sha256:ca9f6cb0466f9638e59e0c249d335a07c867cd50c429b5c7830dda1bed584649 0.0s
=> CACHED [nextjs_server runner 1/6] WORKDIR /app 0.0s
=> CACHED [nextjs_server runner 2/6] RUN addgroup --system --gid 1001 nodejs 0.0s
=> CACHED [nextjs_server runner 3/6] RUN adduser --system --uid 1001 nextjs 0.0s
=> CACHED [nextjs_server deps 1/4] RUN apk add --no-cache libc6-compat 0.0s
=> CACHED [nextjs_server deps 2/4] WORKDIR /app 0.0s
=> CACHED [nextjs_server deps 3/4] COPY package.json pnpm-lock.yaml* ./ 0.0s
=> CACHED [nextjs_server deps 4/4] RUN yarn global add pnpm && pnpm i --frozen-lockfile 0.0s
=> CACHED [nextjs_server builder 2/5] COPY --from=deps /app/node_modules ./node_modules 0.0s
=> [nextjs_server builder 3/5] COPY . . 0.2s
=> [nextjs_server builder 4/5] RUN yarn run prisma:generate 7.0s
=> ERROR [nextjs_server builder 5/5] RUN yarn run build 101.4s

[nextjs_server builder 5/5] RUN yarn run build:
0.837 yarn run v1.22.19
0.950 $ next build
3.208 Attention: Next.js now collects completely anonymous telemetry regarding usage.
3.208 This information is used to shape Next.js' roadmap and prioritize features.
3.208 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
3.209 https://nextjs.org/telemetry
3.209
3.463 Skipping validation of types
3.464 Linting ...
20.16
20.16 ./src/components/Common/Drawer/Drawer.tsx
20.16 4:1 Warning: @react-hookz/web import should occur before import of framer-motion import/order
20.16
20.16 ./src/components/ConversationView/MessageView/MessageEvents/MessageEvent/LLMResponse.tsx
20.16 4:1 Warning: ~/components/ConversationView/ConversationView.selectors import should occur before import of ../../../../CustomIcons/Icon import/order
20.16 52:17 Warning: Classnames 'mb-1, mt-1' could be replaced by the 'my-1' shorthand! tailwindcss/enforces-shorthand
20.16
20.16 info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
20.21 ▲ Next.js 14.0.4
20.21 - Environments: .env
20.21
20.21 Creating an optimized production build ...
68.59
68.60 ╭── 🌼 daisyUI 3.9.4 https://daisyui.com
69.33 │
69.33 ├── prefix is enabled, daisyUI classnames must use daisy prefix. like: daisybtn
69.33 │ https://daisyui.com/docs/config
69.33 │
69.33 ├── 2 themes are enabled. How to add more themes:
69.33 │ https://daisyui.com/docs/themes
69.33 │
69.33 ╰── ⭐️ Star daisyUI project on GitHub: https://github.com/saadeghi/daisyui
69.33
69.83
69.83 ╭── 🌼 daisyUI 3.9.4 https://daisyui.com
70.07 │
70.07 ├── prefix is enabled, daisyUI classnames must use daisy prefix. like: daisybtn
70.07 │ https://daisyui.com/docs/config
70.07 │
70.07 ├── 2 themes are enabled. How to add more themes:
70.07 │ https://daisyui.com/docs/themes
70.07 │
70.07 ╰── ⭐️ Star daisyUI project on GitHub: https://github.com/saadeghi/daisyui
70.07
70.51
70.51 ╭── 🌼 daisyUI 3.9.4 https://daisyui.com
70.73 │
70.73 ├── prefix is enabled, daisyUI classnames must use daisy prefix. like: daisybtn
70.73 │ https://daisyui.com/docs/config
70.73 │
70.73 ├── 2 themes are enabled. How to add more themes:
70.73 │ https://daisyui.com/docs/themes
70.73 │
70.73 ╰── ⭐️ Star daisyUI project on GitHub: https://github.com/saadeghi/daisyui
70.73
100.1
100.1 <--- Last few GCs --->
100.1
100.1 [27:0x7fc20fca8030] 98218 ms: Mark-sweep (reduce) 728.1 (749.7) -> 726.8 (745.2) MB, 472.2 / 0.0 ms (+ 213.5 ms in 49 steps since start of marking, biggest step 11.4 ms, walltime since start of marking 745 ms) (average mu = 0.414, current mu = 0.278) [27:0x7fc20fca8030] 99017 ms: Mark-sweep (reduce) 727.9 (745.2) -> 727.1 (745.7) MB, 793.5 / 0.0 ms (average mu = 0.245, current mu = 0.008) allocation failure; scavenge might not succeed
100.1
100.1
100.1 <--- JS stacktrace --->
100.1
100.1 FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
100.8 error Command failed with signal "SIGABRT".
100.8 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.


failed to solve: process "/bin/sh -c yarn run build" did not complete successfully: exit code: 1

Missing library when running tests

Describe the bug
When trying to launch the tests suite after a fresh install, I get the following error: ValueError: the greenlet library is required to use this function. No module named 'greenlet'

Steps To Reproduce
Steps to reproduce the behavior:

  1. cd backend/app
  2. poetry install --with-dev
  3. poetry shell
  4. pytest -c tests/pytest.ini

Expected behavior
The test suite should run with no error.

Screenshots
image

Desktop (please complete the following information):

  • OS: MacOS 14.3.1

Additional context

  • poetry add greenlet fixed the isssue

failed to solve: changes out of order: "app/poetry.lock" ""

Im trying to execute:
docker-compose -f docker-compose.yml up -d
and i have the error:
`[+] Building 0.0s (0/0) docker:default
[+] Building 1.1s (5/10) docker:default
=> [fastapi_server internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 768B 0.0s
=> [fastapi_server internal] load metadata for docker.io/tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim-2022-11-25 1.1s
=> [fastapi_server internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [fastapi_server 1/6] FROM docker.io/tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim-2022-11-25@sha256:22589c7d5ce3755fc43e78496744c57e322581cc05d0c15421cada291 0.0s
=> ERROR [fastapi_server internal] load build context 0.0s
=> => transferring context: 36B 0.0s

[fastapi_server internal] load build context:


failed to solve: changes out of order: "app/poetry.lock" ""`

Improve chat history handling

Chat history is silently truncated when going over max_token_limit, as we are using the LangChain class ConversationTokenBufferMemory for the chat_history object. The default max_token_limit in agent.yml is currently set to 4k, which is easily too little with current LLMs. Propose to:

  • Increase the limit to say 20k, and change default llm to gpt-4o
  • Add a logger if the limit is exceeded (maybe LangChain support this now?)

Docker compose doesn't go up

Describe the bug
After cloning the repository, updating the .env files, and adding my OpenAI key, the docker container doesn't load.

Steps To Reproduce
Steps to reproduce the behavior:
Follow the instructions in the readme using a new installation.

Expected behavior
Docker container loads without issues.

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot from 2024-04-04 03-14-31

Desktop (please complete the following information):

  • OS: Ubuntu
  • Python 3.11.6
  • Docker : version 24.0.5

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.