### Start DeepWiki Backend Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Installs project dependencies using Poetry and starts the DeepWiki backend server. Ensure Python and Poetry are installed. ```bash python -m pip install poetry==2.0.1 && poetry install python -m api.main ``` -------------------------------- ### Start DeepWiki Frontend Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Installs frontend dependencies using npm and starts the DeepWiki development server. Ensure Node.js and npm are installed. ```bash npm install npm run dev ``` -------------------------------- ### Start FastAPI Server for API Tests Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/tests/README.md Command to start the FastAPI server, which is required for running API tests. Navigate to the 'api' directory before executing this command. ```bash cd api python main.py ``` -------------------------------- ### Install Dependencies with Poetry Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Installs project dependencies using Poetry. Ensure you are in the project root directory. ```bash python -m pip install poetry==2.0.1 && poetry install -C api ``` -------------------------------- ### Start the DeepWiki API Server Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Launches the DeepWiki API server. The API will be accessible at http://localhost:8001 by default. ```bash python -m api.main ``` -------------------------------- ### Install Ollama on Linux Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Installs Ollama on Linux systems using a curl command to download and execute the official installation script. Ensure you have curl installed. ```bash curl -fsSL https://ollama.com/install.sh | sh ``` -------------------------------- ### GET / Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Returns basic API information and available endpoints. ```APIDOC ## GET / ### Description Returns basic API information and available endpoints. ### Method GET ### Endpoint / ### Parameters None ### Request Example None ### Response #### Success Response (200) - **info** (object) - Basic API information. - **endpoints** (array) - List of available endpoints. #### Response Example { "info": { "name": "DeepWiki Open API", "version": "1.0.0" }, "endpoints": [ "GET /", "POST /chat/completions/stream" ] } ``` -------------------------------- ### Download Ollama Models Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Downloads the necessary AI models for DeepWiki: 'nomic-embed-text' for code embeddings and 'qwen3:1.7b' for documentation generation. Ensure Ollama is installed and running. ```bash ollama pull nomic-embed-text ollama pull qwen3:1.7b ``` -------------------------------- ### Python Example for Streaming Chat Completions Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md This Python script demonstrates how to make a streaming request to the chat completions API and process the response in real-time. Ensure the API is running locally on port 8001. ```python import requests # API endpoint url = "http://localhost:8001/chat/completions/stream" # Request data payload = { "repo_url": "https://github.com/AsyncFuncAI/deepwiki-open", "messages": [ { "role": "user", "content": "Explain how React components work" } ] } # Make streaming request response = requests.post(url, json=payload, stream=True) # Process the streaming response for chunk in response.iter_content(chunk_size=None): if chunk: print(chunk.decode('utf-8'), end='', flush=True) ``` -------------------------------- ### Custom OpenAI API Endpoint Example Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Specifies a custom base URL for the OpenAI API. Useful for private channels, self-hosted LLMs, or third-party compatible services. ```bash OPENAI_BASE_URL=https://custom-openai-endpoint.com/v1 ``` -------------------------------- ### Build DeepWiki Docker Image for Ollama Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Builds a Docker image specifically configured for local Ollama model usage. This command assumes you are in the DeepWiki project directory and have Docker installed. ```bash docker build -f Dockerfile-ollama-local -t deepwiki:ollama-local . ``` -------------------------------- ### Clone DeepWiki Repository Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Clones the DeepWiki open-source repository from GitHub and navigates into the project directory. Requires Git to be installed. ```bash git clone https://github.com/AsyncFuncAI/deepwiki-open.git cd deepwiki-open ``` -------------------------------- ### Configure Environment Variables for Tests Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/tests/README.md Example of a .env file used to store sensitive information and configuration settings required for running tests, such as API keys and embedder types. Place this file in the project root. ```dotenv GOOGLE_API_KEY=your_google_api_key_here OPENAI_API_KEY=your_openai_api_key_here DEEPWIKI_EMBEDDER_TYPE=google ``` -------------------------------- ### Run DeepWiki Docker Container (Regular Use) Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Runs the DeepWiki Docker container, mapping ports for the frontend and backend, and setting the Ollama host. Mounts a volume for persistent data. ```bash # For regular use docker run -p 3000:3000 -p 8001:8001 --name deepwiki \ -v ~/.adalflow:/root/.adalflow \ -e OLLAMA_HOST=your_ollama_host \ deepwiki:ollama-local ``` -------------------------------- ### Run DeepWiki Docker Container (Local Repository Analysis) Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Runs the DeepWiki Docker container, mapping ports, setting Ollama host, and mounting a volume for local repositories. Use this for analyzing code directly from your local machine. ```bash # For local repository analysis docker run -p 3000:3000 -p 8001:8001 --name deepwiki \ -v ~/.adalflow:/root/.adalflow \ -e OLLAMA_HOST=your_ollama_host \ -v /path/to/your/repo:/app/local-repos/repo-name \ deepwiki:ollama-local ``` -------------------------------- ### Configuring OpenAI Compatible Embedding Models Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/README.zh.md Replace the default `embedder.json` with `embedder_openai_compatible.json` and set `OPENAI_API_KEY` and `OPENAI_BASE_URL` in your `.env` file to use OpenAI-compatible embedding services like Alibaba Qwen. ```bash OPENAI_API_KEY=你的_api_key OPENAI_BASE_URL=你的_openai_兼容接口地址 ``` -------------------------------- ### Run Individual DeepWiki Test Files Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/tests/README.md Execute a single test file directly. This is useful for debugging specific tests. Specify the path to the test file. ```bash # Unit tests python tests/unit/test_google_embedder.py python tests/unit/test_google_embedder_fix.py # Integration tests python tests/integration/test_full_integration.py # API tests python tests/api/test_api.py ``` -------------------------------- ### Environment Variables for API Keys and Configuration Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/README.zh.md Set these environment variables to configure API keys for different LLM providers and customize DeepWiki's behavior. Ensure keys are valid and correctly formatted. ```bash # API 密钥 GOOGLE_API_KEY=你的谷歌API密钥 # 使用 Google Gemini 模型必需 OPENAI_API_KEY=你的OpenAI密钥 # 使用 OpenAI 模型必需 OPENROUTER_API_KEY=你的OpenRouter密钥 # 使用 OpenRouter 模型必需 # OpenAI API 基础 URL 配置 OPENAI_BASE_URL=https://自定义API端点.com/v1 # 可选,用于自定义 OpenAI API 端点 ``` ```bash # API密钥 GOOGLE_API_KEY=your_google_api_key # Google Gemini模型必需 OPENAI_API_KEY=your_openai_api_key # OpenAI模型必需 OPENROUTER_API_KEY=your_openrouter_api_key # OpenRouter模型必需 # OpenAI API基础URL配置 OPENAI_BASE_URL=https://custom-api-endpoint.com/v1 # 可选,用于自定义OpenAI API端点 # 配置目录 DEEPWIKI_CONFIG_DIR=/path/to/custom/config/dir # 可选,用于自定义配置文件位置 # 授权模式 DEEPWIKI_AUTH_MODE=true # 设置为 true 或 1 以启用授权模式 DEEPWIKI_AUTH_CODE=your_secret_code # 当 DEEPWIKI_AUTH_MODE 启用时所需的授权码 ``` -------------------------------- ### Configure DeepWiki for Ollama Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Copies the Ollama embedder configuration file and overwrites the default configuration. This step is necessary to enable local Ollama model usage. ```bash cp api/config/embedder.ollama.json.bak api/config/embedder.json # overwrite api/config/embedder.json? (y/n [n]) y ``` -------------------------------- ### Run All DeepWiki Tests Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/tests/README.md Execute all tests in the DeepWiki project using the provided test runner script. Ensure you are in the project root directory. ```bash python tests/run_tests.py ``` -------------------------------- ### Custom Configuration Directory Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Sets a custom directory for DeepWiki configuration files (generator.json, embedder.json, repo.json). Allows for flexible environment-specific configurations. ```bash DEEPWIKI_CONFIG_DIR=/path/to/custom/config/dir # Optional, for custom config file location ``` -------------------------------- ### Enabling Authentication Mode Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/README.zh.md Configure authentication for DeepWiki by setting the `DEEPWIKI_AUTH_MODE` and `DEEPWIKI_AUTH_CODE` environment variables. This restricts access to generation features and protects cached pages. ```bash # 授权模式 DEEPWIKI_AUTH_MODE=true # 设置为 true 或 1 以启用授权模式 DEEPWIKI_AUTH_CODE=your_secret_code # 当 DEEPWIKI_AUTH_MODE 启用时所需的授权码 ``` -------------------------------- ### Environment Variables for API Keys and Configuration Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Sets up environment variables required for DeepWiki API functionality. This includes API keys for AI models, AWS, and server configuration. Customize these variables based on your chosen providers and deployment needs. ```dotenv # Required API Keys GOOGLE_API_KEY=your_google_api_key # Required for Google Gemini models OPENAI_API_KEY=your_openai_api_key # Required for embeddings and OpenAI models # Optional API Keys OPENROUTER_API_KEY=your_openrouter_api_key # Required only if using OpenRouter models # AWS Bedrock Configuration AWS_ACCESS_KEY_ID=your_aws_access_key_id # Required for AWS Bedrock models AWS_SECRET_ACCESS_KEY=your_aws_secret_key # Required for AWS Bedrock models AWS_REGION=us-east-1 # Optional, defaults to us-east-1 AWS_ROLE_ARN=your_aws_role_arn # Optional, for role-based authentication # OpenAI API Configuration OPENAI_BASE_URL=https://custom-api-endpoint.com/v1 # Optional, for custom OpenAI API endpoints # Ollama host OLLAMA_HOST=https://your_ollama_host" # Optional: Add Ollama host if not local. default: http://localhost:11434 # Server Configuration PORT=8001 # Optional, defaults to 8001 ``` -------------------------------- ### Add Project Root to Python Path Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/tests/README.md This Python code snippet is used to add the project's root directory to the Python path, which is necessary for correct imports in test files. Place this at the beginning of your test files. ```python from pathlib import Path import sys # Add the project root to the Python path project_root = Path(__file__).parent.parent.parent sys.path.insert(0, str(project_root)) ``` -------------------------------- ### Run Specific DeepWiki Test Categories Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/tests/README.md Execute tests for a specific category (unit, integration, or API) by passing the corresponding flag to the test runner script. ```bash python tests/run_tests.py --unit ``` ```bash python tests/run_tests.py --integration ``` ```bash python tests/run_tests.py --api ``` -------------------------------- ### POST /chat/completions/stream Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md Streams an AI-generated response about a GitHub repository, utilizing Smart Retrieval (RAG) and real-time streaming. ```APIDOC ## POST /chat/completions/stream ### Description Streams an AI-generated response about a GitHub repository. The API finds relevant code snippets, uses them as context for the AI, and streams the response in real-time. ### Method POST ### Endpoint /chat/completions/stream ### Parameters #### Request Body - **repo_url** (string) - Required - The URL of the GitHub repository. - **messages** (array) - Required - An array of message objects, where each object has a 'role' (e.g., 'user') and 'content' (the message text). - **filePath** (string) - Optional - The path to a specific file within the repository. ### Request Example ```json { "repo_url": "https://github.com/username/repo", "messages": [ { "role": "user", "content": "What does this repository do?" } ], "filePath": "optional/path/to/file.py" } ``` ### Response #### Success Response (200) A streaming response with the generated text. The content is streamed in real-time as it is generated by the AI. #### Response Example (Streaming output, example shown as concatenated text) ``` This repository provides a tool for... It uses a RAG approach to... ``` ``` -------------------------------- ### Configure Ollama Generator Model Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Python code snippet showing how to configure the Ollama generator model within DeepWiki's API configuration. Modify the 'model' key to use different Ollama models. ```python "generator_ollama": { "model_client": OllamaClient, "model_kwargs": { "model": "qwen3:1.7b", # Change this to another model "options": { "temperature": 0.7, "top_p": 0.8, } }, }, ``` -------------------------------- ### Configure Ollama Embedder Model Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/Ollama-instruction.md Python code snippet demonstrating how to configure the Ollama embedder model in DeepWiki's API configuration. Change the 'model' key to specify a different embedding model. ```python "embedder_ollama": { "model_client": OllamaClient, "model_kwargs": { "model": "nomic-embed-text" # Change this to another embedding model }, }, ``` -------------------------------- ### POST /chat/completions/stream Request Body Source: https://github.com/asyncfuncai/deepwiki-open/blob/main/api/README.md This JSON structure is used to send a request to the streaming chat completions endpoint. It includes the repository URL, a list of messages for the AI, and an optional file path. ```json { "repo_url": "https://github.com/username/repo", "messages": [ { "role": "user", "content": "What does this repository do?" } ], "filePath": "optional/path/to/file.py" // Optional } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.