-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathopenai_compat.py
More file actions
31 lines (25 loc) · 803 Bytes
/
openai_compat.py
File metadata and controls
31 lines (25 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
OpenAI Chat Completions compatible server (system-prompt flavored)
Startup entrypoint that exposes the modular app implemented in protobuf2openai.
"""
from __future__ import annotations
import os
import asyncio
from protobuf2openai.app import app # FastAPI app
if __name__ == "__main__":
import uvicorn
import config
# Refresh JWT on startup before running the server
try:
from warp2protobuf.core.auth import refresh_jwt_if_needed as _refresh_jwt
asyncio.run(_refresh_jwt())
except Exception:
pass
uvicorn.run(
app,
host=os.getenv("HOST", config.OPENAI_COMPAT_HOST),
port=int(os.getenv("PORT", config.OPENAI_COMPAT_PORT)),
log_level=config.LOG_LEVEL.lower(),
)