27 lines
669 B
Python
27 lines
669 B
Python
from flask import Blueprint
|
|
|
|
from ..request_handler import before_request
|
|
from ..server_error import handle_server_error
|
|
from ... import opts
|
|
|
|
openai_bp = Blueprint('openai/v1/', __name__)
|
|
|
|
|
|
@openai_bp.before_request
|
|
def before_oai_request():
|
|
if not opts.enable_openi_compatible_backend:
|
|
return 'The OpenAI-compatible backend is disabled.', 401
|
|
return before_request()
|
|
|
|
|
|
@openai_bp.errorhandler(500)
|
|
def handle_error(e):
|
|
return handle_server_error(e)
|
|
|
|
|
|
from .models import openai_list_models
|
|
from .chat_completions import openai_chat_completions
|
|
from .info import get_openai_info
|
|
from .simulated import *
|
|
from .completions import openai_completions
|