From aaecf52c9997b33a4f3002bfcb9a1b3d68a11c8c Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 11 Jun 2025 12:30:34 +0100 Subject: [PATCH] refactor: update docs LLM_NAME and MODEL_NAME to LLM_PROVIDER and LLM_NAME --- deployment/docker-compose-dev.yaml | 1 + deployment/docker-compose.yaml | 4 ++- deployment/k8s/docsgpt-secrets.yaml | 2 +- docs/pages/Deploying/Docker-Deploying.mdx | 10 +++--- docs/pages/Deploying/DocsGPT-Settings.mdx | 24 +++++++------- .../pages/Guides/How-to-use-different-LLM.mdx | 4 +-- docs/pages/Models/cloud-providers.mdx | 14 ++++----- docs/pages/Models/embeddings.md | 2 +- docs/pages/Models/local-inference.mdx | 24 +++++++------- setup.sh | 31 +++++++++---------- 10 files changed, 59 insertions(+), 57 deletions(-) diff --git a/deployment/docker-compose-dev.yaml b/deployment/docker-compose-dev.yaml index 8a3e75c4..a1658bd2 100644 --- a/deployment/docker-compose-dev.yaml +++ b/deployment/docker-compose-dev.yaml @@ -1,3 +1,4 @@ +name: docsgpt-oss services: redis: diff --git a/deployment/docker-compose.yaml b/deployment/docker-compose.yaml index c4b81a08..da9249ea 100644 --- a/deployment/docker-compose.yaml +++ b/deployment/docker-compose.yaml @@ -1,3 +1,4 @@ +name: docsgpt-oss services: frontend: build: ../frontend @@ -17,13 +18,13 @@ services: environment: - API_KEY=$API_KEY - EMBEDDINGS_KEY=$API_KEY + - LLM_PROVIDER=$LLM_PROVIDER - LLM_NAME=$LLM_NAME - CELERY_BROKER_URL=redis://redis:6379/0 - CELERY_RESULT_BACKEND=redis://redis:6379/1 - MONGO_URI=mongodb://mongo:27017/docsgpt - CACHE_REDIS_URL=redis://redis:6379/2 - OPENAI_BASE_URL=$OPENAI_BASE_URL - - MODEL_NAME=$MODEL_NAME ports: - "7091:7091" volumes: @@ -41,6 +42,7 @@ services: environment: - API_KEY=$API_KEY - EMBEDDINGS_KEY=$API_KEY + - LLM_PROVIDER=$LLM_PROVIDER - LLM_NAME=$LLM_NAME - CELERY_BROKER_URL=redis://redis:6379/0 - CELERY_RESULT_BACKEND=redis://redis:6379/1 diff --git a/deployment/k8s/docsgpt-secrets.yaml b/deployment/k8s/docsgpt-secrets.yaml index 45a00973..2d494e8e 100644 --- a/deployment/k8s/docsgpt-secrets.yaml +++ b/deployment/k8s/docsgpt-secrets.yaml @@ -4,7 +4,7 @@ metadata: name: docsgpt-secrets type: Opaque data: - LLM_NAME: ZG9jc2dwdA== + LLM_PROVIDER: ZG9jc2dwdA== INTERNAL_KEY: aW50ZXJuYWw= CELERY_BROKER_URL: cmVkaXM6Ly9yZWRpcy1zZXJ2aWNlOjYzNzkvMA== CELERY_RESULT_BACKEND: cmVkaXM6Ly9yZWRpcy1zZXJ2aWNlOjYzNzkvMA== diff --git a/docs/pages/Deploying/Docker-Deploying.mdx b/docs/pages/Deploying/Docker-Deploying.mdx index 7bb70729..382db5fb 100644 --- a/docs/pages/Deploying/Docker-Deploying.mdx +++ b/docs/pages/Deploying/Docker-Deploying.mdx @@ -37,7 +37,7 @@ The fastest way to try out DocsGPT is by using the public API endpoint. This req Open the `.env` file and add the following lines: ``` - LLM_NAME=docsgpt + LLM_PROVIDER=docsgpt VITE_API_STREAMING=true ``` @@ -93,16 +93,16 @@ There are two Ollama optional files: 3. **Pull the Ollama Model:** - **Crucially, after launching with Ollama, you need to pull the desired model into the Ollama container.** Find the `MODEL_NAME` you configured in your `.env` file (e.g., `llama3.2:1b`). Then execute the following command to pull the model *inside* the running Ollama container: + **Crucially, after launching with Ollama, you need to pull the desired model into the Ollama container.** Find the `LLM_NAME` you configured in your `.env` file (e.g., `llama3.2:1b`). Then execute the following command to pull the model *inside* the running Ollama container: ```bash - docker compose -f deployment/docker-compose.yaml -f deployment/optional/docker-compose.optional.ollama-cpu.yaml exec -it ollama ollama pull + docker compose -f deployment/docker-compose.yaml -f deployment/optional/docker-compose.optional.ollama-cpu.yaml exec -it ollama ollama pull ``` or (for GPU): ```bash - docker compose -f deployment/docker-compose.yaml -f deployment/optional/docker-compose.optional.ollama-gpu.yaml exec -it ollama ollama pull + docker compose -f deployment/docker-compose.yaml -f deployment/optional/docker-compose.optional.ollama-gpu.yaml exec -it ollama ollama pull ``` - Replace `` with the actual model name from your `.env` file. + Replace `` with the actual model name from your `.env` file. 4. **Access DocsGPT in your browser:** diff --git a/docs/pages/Deploying/DocsGPT-Settings.mdx b/docs/pages/Deploying/DocsGPT-Settings.mdx index 239b35d7..92537934 100644 --- a/docs/pages/Deploying/DocsGPT-Settings.mdx +++ b/docs/pages/Deploying/DocsGPT-Settings.mdx @@ -20,9 +20,9 @@ The easiest and recommended way to configure basic settings is by using a `.env` **Example `.env` file structure:** ``` -LLM_NAME=openai +LLM_PROVIDER=openai API_KEY=YOUR_OPENAI_API_KEY -MODEL_NAME=gpt-4o +LLM_NAME=gpt-4o ``` ### 2. Configuration via `settings.py` file (Advanced) @@ -37,7 +37,7 @@ While modifying `settings.py` offers more flexibility, it's generally recommende Here are some of the most fundamental settings you'll likely want to configure: -- **`LLM_NAME`**: This setting determines which Large Language Model (LLM) provider DocsGPT will use. It tells DocsGPT which API to interact with. +- **`LLM_PROVIDER`**: This setting determines which Large Language Model (LLM) provider DocsGPT will use. It tells DocsGPT which API to interact with. - **Common values:** - `docsgpt`: Use the DocsGPT Public API Endpoint (simple and free, as offered in `setup.sh` option 1). @@ -49,11 +49,11 @@ Here are some of the most fundamental settings you'll likely want to configure: - `azure_openai`: Use Azure OpenAI Service. - `openai` (when using local inference engines like Ollama, Llama.cpp, TGI, etc.): This signals DocsGPT to use an OpenAI-compatible API format, even if the actual LLM is running locally. -- **`MODEL_NAME`**: Specifies the specific model to use from the chosen LLM provider. The available models depend on the `LLM_NAME` you've selected. +- **`LLM_NAME`**: Specifies the specific model to use from the chosen LLM provider. The available models depend on the `LLM_PROVIDER` you've selected. - **Examples:** - - For `LLM_NAME=openai`: `gpt-4o` - - For `LLM_NAME=google`: `gemini-2.0-flash` + - For `LLM_PROVIDER=openai`: `gpt-4o` + - For `LLM_PROVIDER=google`: `gemini-2.0-flash` - For local models (e.g., Ollama): `llama3.2:1b` (or any model name available in your setup). - **`EMBEDDINGS_NAME`**: This setting defines which embedding model DocsGPT will use to generate vector embeddings for your documents. Embeddings are numerical representations of text that allow DocsGPT to understand the semantic meaning of your documents for efficient search and retrieval. @@ -63,7 +63,7 @@ Here are some of the most fundamental settings you'll likely want to configure: - **`API_KEY`**: Required for most cloud-based LLM providers. This is your authentication key to access the LLM provider's API. You'll need to obtain this key from your chosen provider's platform. -- **`OPENAI_BASE_URL`**: Specifically used when `LLM_NAME` is set to `openai` but you are connecting to a local inference engine (like Ollama, Llama.cpp, etc.) that exposes an OpenAI-compatible API. This setting tells DocsGPT where to find your local LLM server. +- **`OPENAI_BASE_URL`**: Specifically used when `LLM_PROVIDER` is set to `openai` but you are connecting to a local inference engine (like Ollama, Llama.cpp, etc.) that exposes an OpenAI-compatible API. This setting tells DocsGPT where to find your local LLM server. ## Configuration Examples @@ -74,9 +74,9 @@ Let's look at some concrete examples of how to configure these settings in your To use OpenAI's `gpt-4o` model, you would configure your `.env` file like this: ``` -LLM_NAME=openai +LLM_PROVIDER=openai API_KEY=YOUR_OPENAI_API_KEY # Replace with your actual OpenAI API key -MODEL_NAME=gpt-4o +LLM_NAME=gpt-4o ``` Make sure to replace `YOUR_OPENAI_API_KEY` with your actual OpenAI API key. @@ -86,14 +86,14 @@ Make sure to replace `YOUR_OPENAI_API_KEY` with your actual OpenAI API key. To use a local Ollama server with the `llama3.2:1b` model, you would configure your `.env` file like this: ``` -LLM_NAME=openai # Using OpenAI compatible API format for local models +LLM_PROVIDER=openai # Using OpenAI compatible API format for local models API_KEY=None # API Key is not needed for local Ollama -MODEL_NAME=llama3.2:1b +LLM_NAME=llama3.2:1b OPENAI_BASE_URL=http://host.docker.internal:11434/v1 # Default Ollama API URL within Docker EMBEDDINGS_NAME=huggingface_sentence-transformers/all-mpnet-base-v2 # You can also run embeddings locally if needed ``` -In this case, even though you are using Ollama locally, `LLM_NAME` is set to `openai` because Ollama (and many other local inference engines) are designed to be API-compatible with OpenAI. `OPENAI_BASE_URL` points DocsGPT to the local Ollama server. +In this case, even though you are using Ollama locally, `LLM_PROVIDER` is set to `openai` because Ollama (and many other local inference engines) are designed to be API-compatible with OpenAI. `OPENAI_BASE_URL` points DocsGPT to the local Ollama server. ## Authentication Settings diff --git a/docs/pages/Guides/How-to-use-different-LLM.mdx b/docs/pages/Guides/How-to-use-different-LLM.mdx index 3bc8477d..217bc690 100644 --- a/docs/pages/Guides/How-to-use-different-LLM.mdx +++ b/docs/pages/Guides/How-to-use-different-LLM.mdx @@ -32,9 +32,9 @@ Choose the LLM of your choice. ### For Open source llm change: ### Step 1 -For open source version please edit `LLM_NAME`, `MODEL_NAME` and others in the .env file. Refer to [⚙️ App Configuration](/Deploying/DocsGPT-Settings) for more information. +For open source version please edit `LLM_PROVIDER`, `LLM_NAME` and others in the .env file. Refer to [⚙️ App Configuration](/Deploying/DocsGPT-Settings) for more information. ### Step 2 -Visit [☁️ Cloud Providers](/Models/cloud-providers) for the updated list of online models. Make sure you have the right API_KEY and correct LLM_NAME. +Visit [☁️ Cloud Providers](/Models/cloud-providers) for the updated list of online models. Make sure you have the right API_KEY and correct LLM_PROVIDER. For self-hosted please visit [🖥️ Local Inference](/Models/local-inference). diff --git a/docs/pages/Models/cloud-providers.mdx b/docs/pages/Models/cloud-providers.mdx index 86f2d132..36e737fa 100644 --- a/docs/pages/Models/cloud-providers.mdx +++ b/docs/pages/Models/cloud-providers.mdx @@ -13,15 +13,15 @@ The primary method for configuring your LLM provider in DocsGPT is through the ` To connect to a cloud LLM provider, you will typically need to configure the following basic settings in your `.env` file: -* **`LLM_NAME`**: This setting is essential and identifies the specific cloud provider you wish to use (e.g., `openai`, `google`, `anthropic`). -* **`MODEL_NAME`**: Specifies the exact model you want to utilize from your chosen provider (e.g., `gpt-4o`, `gemini-2.0-flash`, `claude-3-5-sonnet-latest`). Refer to your provider's documentation for a list of available models. +* **`LLM_PROVIDER`**: This setting is essential and identifies the specific cloud provider you wish to use (e.g., `openai`, `google`, `anthropic`). +* **`LLM_NAME`**: Specifies the exact model you want to utilize from your chosen provider (e.g., `gpt-4o`, `gemini-2.0-flash`, `claude-3-5-sonnet-latest`). Refer to your provider's documentation for a list of available models. * **`API_KEY`**: Almost all cloud LLM providers require an API key for authentication. Obtain your API key from your chosen provider's platform and securely store it in your `.env` file. ## Explicitly Supported Cloud Providers -DocsGPT offers direct, streamlined support for the following cloud LLM providers, making configuration straightforward. The table below outlines the `LLM_NAME` and example `MODEL_NAME` values to use for each provider in your `.env` file. +DocsGPT offers direct, streamlined support for the following cloud LLM providers, making configuration straightforward. The table below outlines the `LLM_PROVIDER` and example `LLM_NAME` values to use for each provider in your `.env` file. -| Provider | `LLM_NAME` | Example `MODEL_NAME` | +| Provider | `LLM_PROVIDER` | Example `LLM_NAME` | | :--------------------------- | :------------- | :-------------------------- | | DocsGPT Public API | `docsgpt` | `None` | | OpenAI | `openai` | `gpt-4o` | @@ -35,16 +35,16 @@ DocsGPT offers direct, streamlined support for the following cloud LLM providers DocsGPT's flexible architecture allows you to connect to any cloud provider that offers an API compatible with the OpenAI API standard. This opens up a vast ecosystem of LLM services. -To connect to an OpenAI-compatible cloud provider, you will still use `LLM_NAME=openai` in your `.env` file. However, you will also need to specify the API endpoint of your chosen provider using the `OPENAI_BASE_URL` setting. You will also likely need to provide an `API_KEY` and `MODEL_NAME` as required by that provider. +To connect to an OpenAI-compatible cloud provider, you will still use `LLM_PROVIDER=openai` in your `.env` file. However, you will also need to specify the API endpoint of your chosen provider using the `OPENAI_BASE_URL` setting. You will also likely need to provide an `API_KEY` and `LLM_NAME` as required by that provider. **Example for DeepSeek (OpenAI-Compatible API):** To connect to DeepSeek, which offers an OpenAI-compatible API, your `.env` file could be configured as follows: ``` -LLM_NAME=openai +LLM_PROVIDER=openai API_KEY=YOUR_API_KEY # Your DeepSeek API key -MODEL_NAME=deepseek-chat # Or your desired DeepSeek model name +LLM_NAME=deepseek-chat # Or your desired DeepSeek model name OPENAI_BASE_URL=https://api.deepseek.com/v1 # DeepSeek's OpenAI API URL ``` diff --git a/docs/pages/Models/embeddings.md b/docs/pages/Models/embeddings.md index 6dfb89b6..68015db7 100644 --- a/docs/pages/Models/embeddings.md +++ b/docs/pages/Models/embeddings.md @@ -60,7 +60,7 @@ To use OpenAI's `text-embedding-ada-002` embedding model, you need to set `EMBED **Example `.env` configuration for OpenAI Embeddings:** ``` -LLM_NAME=openai +LLM_PROVIDER=openai API_KEY=YOUR_OPENAI_API_KEY # Your OpenAI API Key EMBEDDINGS_NAME=openai_text-embedding-ada-002 ``` diff --git a/docs/pages/Models/local-inference.mdx b/docs/pages/Models/local-inference.mdx index 4aa6bca2..0bba907b 100644 --- a/docs/pages/Models/local-inference.mdx +++ b/docs/pages/Models/local-inference.mdx @@ -15,8 +15,8 @@ Setting up a local inference engine with DocsGPT is configured through environme To connect to a local inference engine, you will generally need to configure these settings in your `.env` file: -* **`LLM_NAME`**: Crucially set this to `openai`. This tells DocsGPT to use the OpenAI-compatible API format for communication, even though the LLM is local. -* **`MODEL_NAME`**: Specify the model name as recognized by your local inference engine. This might be a model identifier or left as `None` if the engine doesn't require explicit model naming in the API request. +* **`LLM_PROVIDER`**: Crucially set this to `openai`. This tells DocsGPT to use the OpenAI-compatible API format for communication, even though the LLM is local. +* **`LLM_NAME`**: Specify the model name as recognized by your local inference engine. This might be a model identifier or left as `None` if the engine doesn't require explicit model naming in the API request. * **`OPENAI_BASE_URL`**: This is essential. Set this to the base URL of your local inference engine's API endpoint. This tells DocsGPT where to find your local LLM server. * **`API_KEY`**: Generally, for local inference engines, you can set `API_KEY=None` as authentication is usually not required in local setups. @@ -24,16 +24,16 @@ To connect to a local inference engine, you will generally need to configure the DocsGPT is readily configurable to work with the following local inference engines, all communicating via the OpenAI API format. Here are example `OPENAI_BASE_URL` values for each, based on default setups: -| Inference Engine | `LLM_NAME` | `OPENAI_BASE_URL` | -| :---------------------------- | :--------- | :------------------------- | -| LLaMa.cpp | `openai` | `http://localhost:8000/v1` | -| Ollama | `openai` | `http://localhost:11434/v1` | -| Text Generation Inference (TGI)| `openai` | `http://localhost:8080/v1` | -| SGLang | `openai` | `http://localhost:30000/v1` | -| vLLM | `openai` | `http://localhost:8000/v1` | -| Aphrodite | `openai` | `http://localhost:2242/v1` | -| FriendliAI | `openai` | `http://localhost:8997/v1` | -| LMDeploy | `openai` | `http://localhost:23333/v1` | +| Inference Engine | `LLM_PROVIDER` | `OPENAI_BASE_URL` | +| :---------------------------- | :------------- | :------------------------- | +| LLaMa.cpp | `openai` | `http://localhost:8000/v1` | +| Ollama | `openai` | `http://localhost:11434/v1` | +| Text Generation Inference (TGI)| `openai` | `http://localhost:8080/v1` | +| SGLang | `openai` | `http://localhost:30000/v1` | +| vLLM | `openai` | `http://localhost:8000/v1` | +| Aphrodite | `openai` | `http://localhost:2242/v1` | +| FriendliAI | `openai` | `http://localhost:8997/v1` | +| LMDeploy | `openai` | `http://localhost:23333/v1` | **Important Note on `localhost` vs `host.docker.internal`:** diff --git a/setup.sh b/setup.sh index 5cf013fc..b072d546 100755 --- a/setup.sh +++ b/setup.sh @@ -169,7 +169,7 @@ prompt_ollama_options() { # 1) Use DocsGPT Public API Endpoint (simple and free) use_docs_public_api_endpoint() { echo -e "\n${NC}Setting up DocsGPT Public API Endpoint...${NC}" - echo "LLM_NAME=docsgpt" > .env + echo "LLM_PROVIDER=docsgpt" > .env echo "VITE_API_STREAMING=true" >> .env echo -e "${GREEN}.env file configured for DocsGPT Public API.${NC}" @@ -237,13 +237,12 @@ serve_local_ollama() { echo -e "\n${NC}Configuring for Ollama ($(echo "$docker_compose_file_suffix" | tr '[:lower:]' '[:upper:]'))...${NC}" # Using tr for uppercase - more compatible echo "API_KEY=xxxx" > .env # Placeholder API Key - echo "LLM_NAME=openai" >> .env - echo "MODEL_NAME=$model_name" >> .env + echo "LLM_PROVIDER=openai" >> .env + echo "LLM_NAME=$model_name" >> .env echo "VITE_API_STREAMING=true" >> .env echo "OPENAI_BASE_URL=http://ollama:11434/v1" >> .env echo "EMBEDDINGS_NAME=huggingface_sentence-transformers/all-mpnet-base-v2" >> .env echo -e "${GREEN}.env file configured for Ollama ($(echo "$docker_compose_file_suffix" | tr '[:lower:]' '[:upper:]')${NC}${GREEN}).${NC}" - echo -e "${YELLOW}Note: MODEL_NAME is set to '${BOLD}$model_name${NC}${YELLOW}'. You can change it later in the .env file.${NC}" check_and_start_docker @@ -350,8 +349,8 @@ connect_local_inference_engine() { echo -e "\n${NC}Configuring for Local Inference Engine: ${BOLD}${engine_name}...${NC}" echo "API_KEY=None" > .env - echo "LLM_NAME=openai" >> .env - echo "MODEL_NAME=$model_name" >> .env + echo "LLM_PROVIDER=openai" >> .env + echo "LLM_NAME=$model_name" >> .env echo "VITE_API_STREAMING=true" >> .env echo "OPENAI_BASE_URL=$openai_base_url" >> .env echo "EMBEDDINGS_NAME=huggingface_sentence-transformers/all-mpnet-base-v2" >> .env @@ -381,7 +380,7 @@ connect_local_inference_engine() { # 4) Connect Cloud API Provider connect_cloud_api_provider() { - local provider_choice api_key llm_name + local provider_choice api_key llm_provider local setup_result # Variable to store the return status get_api_key() { @@ -395,43 +394,43 @@ connect_cloud_api_provider() { case "$provider_choice" in 1) # OpenAI provider_name="OpenAI" - llm_name="openai" + llm_provider="openai" model_name="gpt-4o" get_api_key break ;; 2) # Google provider_name="Google (Vertex AI, Gemini)" - llm_name="google" + llm_provider="google" model_name="gemini-2.0-flash" get_api_key break ;; 3) # Anthropic provider_name="Anthropic (Claude)" - llm_name="anthropic" + llm_provider="anthropic" model_name="claude-3-5-sonnet-latest" get_api_key break ;; 4) # Groq provider_name="Groq" - llm_name="groq" + llm_provider="groq" model_name="llama-3.1-8b-instant" get_api_key break ;; 5) # HuggingFace Inference API provider_name="HuggingFace Inference API" - llm_name="huggingface" + llm_provider="huggingface" model_name="meta-llama/Llama-3.1-8B-Instruct" get_api_key break ;; 6) # Azure OpenAI provider_name="Azure OpenAI" - llm_name="azure_openai" + llm_provider="azure_openai" model_name="gpt-4o" get_api_key break ;; 7) # Novita provider_name="Novita" - llm_name="novita" + llm_provider="novita" model_name="deepseek/deepseek-r1" get_api_key break ;; @@ -442,8 +441,8 @@ connect_cloud_api_provider() { echo -e "\n${NC}Configuring for Cloud API Provider: ${BOLD}${provider_name}...${NC}" echo "API_KEY=$api_key" > .env - echo "LLM_NAME=$llm_name" >> .env - echo "MODEL_NAME=$model_name" >> .env + echo "LLM_PROVIDER=$llm_provider" >> .env + echo "LLM_NAME=$model_name" >> .env echo "VITE_API_STREAMING=true" >> .env echo -e "${GREEN}.env file configured for ${BOLD}${provider_name}${NC}${GREEN}.${NC}"