Welcome to the local development and debugging guide for the "opencopilot" Flask application. This guide will help you set up your environment and effectively utilize VS Code for debugging.
- Getting Started Guide: Debugging "opencopilot" with VS Code
- Use Open Source Model Environment Variables
This section guides you through setting up your environment and using VS Code for debugging the "opencopilot" Flask application.
Install Conda by following the official Conda installation guide, then check your Conda version with conda --version
.
For an enhanced development experience with Mypy (optional), activate your Conda environment and run pip install mypy
.
- Clone the "opencopilot" Flask App repository onto your local machine.
Configure the "llm_server" project environment as follows:
-
Create
.env
File: At the root of the "llm_server" directory, create a new.env
file to hold environmental configuration settings for local development.Example
.env
File:OPENAI_API_KEY=<YOUR OPEN AI KEY>
-
Set Additional Environment Variables (Optional) Set any desired optional environment variables for copilot customization within the
.env
file.Optional variable examples include:
- `MONGODB_URI`: MongoDB connection string. - `QDRANT_SERVER_URI`: QDRANT server URL. - `QDRANT_API_KEY`: Your QDRANT API key. - `QDRANT_PASS`: Base64-encoded string for QDRANT pass. - `ACTIONS_SCORE_THRESHOLD`: Threshold for actions score (default: 0.5). - `FLOWS_SCORE_THRESHOLD`: Threshold for flows score (default: 0.5). - `KB_SCORE_THRESHOLD`: Threshold for KB score (default: 0.5). - `TARGET`: Environment target (default: production).
Replace placeholders with appropriate configurations. For more information about these options, see the original documentation.
To install required packages, execute pip install -r requirements.txt
from the project directory.
- Select the 'Flask' debug configuration.
- Launch debug mode with F5.
With Docker and Docker Compose installed, perform the following tasks:
- In the Makefile, set
TARGET=development
. - Execute either
make install
ormake install-arm
, depending on your system architecture. - Within the "llm-server" directory, locate the Docker container for debugging purposes.
- Attach the VSCode debugger to the running container for debugging. Wait for the Flask process to begin before proceeding.
Benefit from convenient hot reloading while debugging inside Docker containers without needing to restart the container after every code modification.
Happy debugging! π
To use the open-source model, set the following environment variables, thanks to Justin van Grootveld:
OPENAI_API_KEY=unused
CHAT_MODEL=openchat
EMBEDDING_PROVIDER=openchat
LOCAL_IP=http://host.docker.internal
VECTOR_SIZE=4096
The following environment variables are used to configure the file storage for the application:
-
STORAGE_TYPE
: Specifies the type of file storage to be used. Currently, the supported options ares3
andlocal
. Set this variable tos3
if you want to use Amazon S3 for file storage, or set it tolocal
if you want to use the local file system. -
AWS_ACCESS_KEY_ID
(required ifSTORAGE_TYPE
is set tos3
): Specifies the access key ID for the AWS account that has access to the S3 bucket. This key is used to authenticate requests made to the S3 service. -
AWS_SECRET_ACCESS_KEY
(required ifSTORAGE_TYPE
is set tos3
): Specifies the secret access key for the AWS account that has access to the S3 bucket. This key is used to authenticate requests made to the S3 service.
Make sure to provide the appropriate values for these environment variables based on your desired file storage configuration.