Skip to content

Developer Document

Shoichi Ishida edited this page Dec 18, 2024 · 9 revisions

Under Construction.

Basic Information

Customize ChatChemTS

Customize Reward Generator Tool

Customize Config Generator Tool

Change OpenAI's LLM to Another

Note

A GUI feature to switch between LLM models from different providers is planned for future implementation.
As such, the method described here is intended as a temporary solution.

To switch the LLM used in ChatChemTS to another provider's LLM, you will need to make modifications to at least two functions:

  1. start() in chatbot_app/app.py
  2. prepare_chat_model() in chatbot_app/util.py

Modify start() Function

In the start() function, you define the settings passed to the LLM model that can be adjusted via the GUI. Update these settings to match the requirements of the LLM you wish to use.

Note

Ensure that the setting with id="NumConversationMemory" is retained, as it is a shared requirement across all LLMs.

Modify prepare_chat_model() Function

In the prepare_chat_model() function, update the section where ChatOpenAI() is called. Modify it to align with the specifications of the chat model you intended to implement. The settings argument passed to this function contains the configurations defined in start(). For a list of chat models supported by LangChain, refer to the following documentation: https://python.langchain.com/docs/integrations/chat/

Update Dependencies

If additional Python packages are required for the new LLM, you must update the following files:

  • pyproject.toml and poetry.lock in chatbot_app/

Add the required package to chatbot_app/pyproject.toml, then run the command poetry lock to update the chatbot_app/poetry.lock file. Refer to the Poetry CLI documentation for more details.

Configure Environment Variables

If the new LLM requires API keys or other credentials to be defined as environment variables, you need to update the relevant sections in the following files to suit your requirements:

  • manage_app.sh
  • docker-compose.yaml

Replace the references to OPENAI_API_KEY with the corresponding keys or environment variables for your chosen LLM.

Debug

How to Retrieve Logs from Docker Containers

You can inspect the raw logs using the docker logs command if you encounter errors or unexpected behaviors.

docker container ls  # List running containers to find the container names related to ChatChemTS
docker logs [CONTAINER_NAME]  # Example: chatchemts-chatbot-1 or chatchemts-api_chemtsv2-1

Clone this wiki locally