Move openai.py to beyond_the_loop module

This commit is contained in:
Phil Szalay 2025-02-17 18:32:05 +01:00
parent 057d063d81
commit 0ce3584516
5 changed files with 8 additions and 39 deletions

View File

@ -1,36 +1,25 @@
import asyncio
import inspect
import json
import logging
import mimetypes
import os
import shutil
import sys
import time
import random
from contextlib import asynccontextmanager
from urllib.parse import urlencode, parse_qs, urlparse
from pydantic import BaseModel
from sqlalchemy import text
from typing import Optional
from aiocache import cached
import aiohttp
import requests
from fastapi import (
Depends,
FastAPI,
File,
Form,
HTTPException,
Request,
UploadFile,
status,
applications,
BackgroundTasks,
)
from fastapi.openapi.docs import get_swagger_ui_html
@ -42,8 +31,7 @@ from fastapi.staticfiles import StaticFiles
from starlette.exceptions import HTTPException as StarletteHTTPException
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.middleware.sessions import SessionMiddleware
from starlette.responses import Response, StreamingResponse
from starlette.responses import Response
from open_webui.socket.main import (
app as socket_app,
@ -53,7 +41,6 @@ from open_webui.routers import (
audio,
images,
ollama,
openai,
retrieval,
pipelines,
tasks,
@ -73,6 +60,7 @@ from open_webui.routers import (
users,
utils,
)
from beyond_the_loop.routers import openai
from open_webui.routers.retrieval import (
get_embedding_function,
@ -130,17 +118,12 @@ from open_webui.config import (
AUDIO_TTS_AZURE_SPEECH_REGION,
AUDIO_TTS_AZURE_SPEECH_OUTPUT_FORMAT,
WHISPER_MODEL,
WHISPER_MODEL_AUTO_UPDATE,
WHISPER_MODEL_DIR,
# Retrieval
RAG_TEMPLATE,
DEFAULT_RAG_TEMPLATE,
RAG_EMBEDDING_MODEL,
RAG_EMBEDDING_MODEL_AUTO_UPDATE,
RAG_EMBEDDING_MODEL_TRUST_REMOTE_CODE,
RAG_RERANKING_MODEL,
RAG_RERANKING_MODEL_AUTO_UPDATE,
RAG_RERANKING_MODEL_TRUST_REMOTE_CODE,
RAG_EMBEDDING_ENGINE,
RAG_EMBEDDING_BATCH_SIZE,
RAG_RELEVANCE_THRESHOLD,
@ -185,11 +168,9 @@ from open_webui.config import (
GOOGLE_DRIVE_CLIENT_ID,
GOOGLE_DRIVE_API_KEY,
ENABLE_RAG_HYBRID_SEARCH,
ENABLE_RAG_LOCAL_WEB_FETCH,
ENABLE_RAG_WEB_LOADER_SSL_VERIFICATION,
ENABLE_RAG_WEB_SEARCH,
ENABLE_GOOGLE_DRIVE_INTEGRATION,
UPLOAD_DIR,
# WebUI
WEBUI_AUTH,
WEBUI_NAME,
@ -211,7 +192,6 @@ from open_webui.config import (
DEFAULT_USER_ROLE,
DEFAULT_PROMPT_SUGGESTIONS,
DEFAULT_MODELS,
DEFAULT_ARENA_MODEL,
MODEL_ORDER_LIST,
EVALUATION_ARENA_MODELS,
# WebUI (OAuth)

View File

@ -1,6 +1,5 @@
from fastapi import (
Depends,
FastAPI,
File,
Form,
HTTPException,
@ -14,15 +13,12 @@ import logging
import shutil
import requests
from pydantic import BaseModel
from starlette.responses import FileResponse
from typing import Optional
from open_webui.env import SRC_LOG_LEVELS
from open_webui.config import CACHE_DIR
from open_webui.constants import ERROR_MESSAGES
from open_webui.routers.openai import get_all_models_responses
from beyond_the_loop.routers.openai import get_all_models_responses
from open_webui.utils.auth import get_admin_user

View File

@ -1,18 +1,13 @@
import time
import logging
import sys
from aiocache import cached
from typing import Any, Optional
from typing import Any
import random
import json
import inspect
from fastapi import Request
from starlette.responses import Response, StreamingResponse
from beyond_the_loop.models.users import UserModel
from starlette.responses import StreamingResponse
from open_webui.socket.main import (
get_event_call,
@ -20,7 +15,7 @@ from open_webui.socket.main import (
)
from open_webui.functions import generate_function_chat_completion
from open_webui.routers.openai import (
from beyond_the_loop.routers.openai import (
generate_chat_completion as generate_openai_chat_completion,
)
@ -34,8 +29,6 @@ from open_webui.routers.pipelines import (
)
from open_webui.models.functions import Functions
from beyond_the_loop.models.models import Models
from open_webui.utils.plugin import load_function_module_by_id
from open_webui.utils.models import get_all_models, check_model_access

View File

@ -2,10 +2,10 @@ import time
import logging
import sys
from aiocache import cached
from fastapi import Request
from open_webui.routers import openai, ollama
from open_webui.routers import ollama
from beyond_the_loop.routers import openai
from open_webui.functions import get_function_models