Skip to content

clean-up and basic function call

Laurian Gridinoc requested to merge function-call into main

How to run:

  1. create an .env.local based on .env.example, remove/comment-out API_KEY unless you need authentication
  2. in your .env.local add your OpenAI key like OPENAI_API_KEY=sk-aaa...bbb
  3. run make run -- this will create .venv and install required modules, then run the api/server.py
  4. use a browser to see the generated API docs at http://0.0.0.0:8889/docs
  5. invoke /filter with a query

To iterate faster on function_call_chain.py you can run it in cli: in ./api folder run source ../.venv/bin/activate; OPENAI_API_KEY="sk-aaa...bbb" python ./function_call_chain.py

To test that the same code works with Hermes 2 model:

  1. run Hermes first as: docker run -ti -p 8080:8080 localai/localai:v2.11.0-ffmpeg-core hermes-2-pro-mistral
  2. change in function_call_chain.py from llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0.7) to llm = ChatOpenAI(model="hermes-2-pro-mistral", temperature=0.7)
  3. test in cli in ./api source ../.venv/bin/activate; OPENAI_API_KEY="sk-aaa...bbb" OPENAI_API_BASE=http://localhost:8080/v1 python ./function_call_chain.py
  4. add OPENAI_API_BASE=http://localhost:8080/v1 to .env.local to test via the endpoint created by server.py
Edited by Laurian Gridinoc

Merge request reports