mirror of
https://github.com/open-webui/docs
synced 2025-05-20 03:08:56 +00:00
Update index.mdx
This commit is contained in:
parent
e9d5e59e55
commit
385d38b6ce
@ -122,7 +122,7 @@ Let’s 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)
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user