Chainlit / cookbook

Chainlit's cookbook repo
https://github.com/Chainlit/chainlit
713 stars 270 forks source link

OpenAI Assistants - can't access the assistant_id #61

Closed wodecki closed 7 months ago

wodecki commented 7 months ago

I run the OpenAI Assistance cookbook with:

  1. python create_assistant.py > correctly generates assistants.json with {"math_tutor_and_weather_bot": "asst_uhU...Z3"}
  2. chainlit run app.py

The WebUI generates the following error:

1

It works after adding a snippet that directly reads the assistant_id from json at the top of app.py:

with open('assistants.json') as f:
    assistant_id = json.load(f)["math_tutor_and_weather_bot"]
print("assistant_id = ", assistant_id)

My question: How should I set it up to make it possible to deploy the app as the docker on Google Cloud Run? I mean: how to set up the sequence: 1. create_assistant.py > 2. chainlit run app.py?

wodecki commented 7 months ago

Solved with the following Dockerfile:

FROM python:3.11

# Copy the entire project directory
COPY . /app

WORKDIR /app

RUN pip install chainlit langchain openai

# Use a shell form to execute a sequence of commands
# Using `sh -c` to ensure the pipe works correctly
ENTRYPOINT sh -c "python create_assistant.py | chainlit run app.py --host=0.0.0.0 --port=$PORT --headless"