Update index.mdx

This commit is contained in:
Timothy Jaeryang Baek 2024-12-28 17:03:48 -08:00
parent 36e5db0572
commit 320076333c

View File

@ -123,6 +123,7 @@ Depending on your use case, you can choose between:
2. **`open_webui.utils.chat.generate_chat_completion`:** 2. **`open_webui.utils.chat.generate_chat_completion`:**
- Directly makes a POST request without handling extra parsing or tasks. - Directly makes a POST request without handling extra parsing or tasks.
- This is the **direct successor** to the previous `ollama.generate_chat_completion` and `openai.generate_chat_completion` functions in Open WebUI 0.4.
- Best for simplified and more lightweight scenarios. - Best for simplified and more lightweight scenarios.
#### Example: #### Example:
@ -138,12 +139,16 @@ from open_webui.utils.chat import generate_chat_completion
### 📋 3. Adapting to Updated Function Signatures ### 📋 3. Adapting to Updated Function Signatures
Weve updated the **function signatures** to better fit the new architecture. Weve updated the **function signatures** to better fit the new architecture. If you're looking for a direct replacement, start with the lightweight utility function `generate_chat_completion` from `open_webui.utils.chat`. For the full API flow, use the new unified `chat_completion` function in `open_webui.main`.
#### Function Signature Changes: #### Function Signature Changes:
| **Old** | **New** |
|-----------------------------------------|-----------------------------------------| | **Old** | **Direct Successor (New)** | **Unified Option (New)** |
| `openai.generate_chat_completion(form_data: dict, user: UserModel)` | `chat_completion(request: Request, form_data: dict, user: UserModel)` | |-----------------------------------------|-----------------------------------------|-----------------------------------------|
| `openai.generate_chat_completion(form_data: dict, user: UserModel)` | `generate_chat_completion(request: Request, form_data: dict, user: UserModel)` | `chat_completion(request: Request, form_data: dict, user: UserModel)` |
- **Direct Successor (`generate_chat_completion`)**: A lightweight, 1:1 replacement for previous `ollama`/`openai` methods.
- **Unified Option (`chat_completion`)**: Use this for the complete API flow, including file parsing and additional functionality.
#### Example: #### Example: