Update index.mdx

This commit is contained in:
Timothy Jaeryang Baek 2024-12-28 13:56:27 -08:00
parent e9d5e59e55
commit 385d38b6ce

View File

@ -122,7 +122,7 @@ Lets rewrite a sample function to match the new structure:
#### Before (0.4):
```python
from pydantic import BaseModel
from open_webui.apps.openai import generate_chat_completion
from open_webui.apps.ollama import generate_chat_completion
class User(BaseModel):
id: str
@ -137,7 +137,8 @@ class Pipe:
async def pipe(self, body: dict, __user__: dict) -> str:
# Calls OpenAI endpoint
user = User(**__user__)
return await openai.generate_chat_completion(body, user)
body["model"] = "llama3.2:latest"
return await ollama.generate_chat_completion(body, user)
```
#### After (0.5):
@ -147,12 +148,14 @@ from fastapi import Request
from open_webui.main import chat_completion
class User(BaseModel):
id: str
email: str
name: str
role: str
class Pipe:
def __init__(self):
pass
@ -165,6 +168,7 @@ class Pipe:
) -> str:
# Uses the unified endpoint with updated signature
user = User(**__user__)
body["model"] = "llama3.2:latest"
return await chat_completion(__request__, body, user)
```