To clone repo along with submodules, run
git clone --recursive [email protected]:lopentu/lopetools.git
Make sure to create .env
in the root directory and add OPENAI_API_KEY
to .env
if you want to use OpenAI models:
OPENAI_API_KEY="<YOUR_KEY_HERE>"
To install backend requirements, run
pip install poetry==1.5.1
poetry install
To install frontend requirements, run
cd web
npm install
To just look at usage examples, check out notebooks/langchain.ipynb
The frontend is a React app in web/
and the backend is split into two parts in src/api/
.
- The frontend directly calls a FastAPI app that hosts a LangChain 🦜️🔗 agent in
api.main:app
- The SenseTagTool 🏷️ is hosted in a separate FastAPI app in
api.tagger.main:app
and is called by the LangChain agent.
Here's an unnecessarily detailed diagram of the flow:
sequenceDiagram
box Frontend
participant front as React App
end
box Backend
participant agent as LangChain Agent
participant tagger as SenseTagTool
end
front->>agent: POST /agent
agent->>tagger: GET /tagger
tagger->>agent: 200 OK
agent->>front: 200 OK
I tried combining the agent and tagger into one app, but the agent hangs when it calls the tagger. I must be doing something wrong. 🤷♂️
Use something like tmux
to start the frontend, agent, and tagger in separate terminals so they can run even when you close the terminal.
To start the frontend, run
cd web
npm run dev
To start the agent, run
cd src
uvicorn api.main:app --reload --port 8003 --host 0.0.0.0
To start the tagger, run
cd src
uvicorn api.tagger.main:app --reload --port 3001
Because of the way the host server is setup, I can't get docker-compose to work. So I have to run the app without Docker. 😭