From 385d38b6ceba17b51c99def04e9822a32e559967 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sat, 28 Dec 2024 13:56:27 -0800 Subject: [PATCH] Update index.mdx --- docs/features/plugin/migration/index.mdx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/features/plugin/migration/index.mdx b/docs/features/plugin/migration/index.mdx index 7543aeb..c1dc02e 100644 --- a/docs/features/plugin/migration/index.mdx +++ b/docs/features/plugin/migration/index.mdx @@ -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 @@ -160,11 +163,12 @@ class Pipe: async def pipe( self, body: dict, - __user__: dict, + __user__: dict, __request__: Request, ) -> str: # Uses the unified endpoint with updated signature user = User(**__user__) + body["model"] = "llama3.2:latest" return await chat_completion(__request__, body, user) ```