Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,8 +20,8 @@ SPOTIFY_REDIRECT_URI = os.getenv("REDIRECT_URL")
|
|
| 20 |
|
| 21 |
# OpenAI API and custom proxy config
|
| 22 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 23 |
-
OPENAI_BASE_URL = os.getenv("OPENAI_URL") # e.g. "https://your.proxy.base.url"
|
| 24 |
-
OPENAI_CUSTOM_PATH = os.getenv("OPENAI_CUSTOM_PATH", "/v1/chat/completions")
|
| 25 |
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4")
|
| 26 |
|
| 27 |
# Spotify OAuth setup
|
|
@@ -38,11 +38,11 @@ temp_file = os.path.join(tempfile.gettempdir(), "playlist_recommendations.txt")
|
|
| 38 |
# OpenAI client with custom base URL and path rewrite
|
| 39 |
def update_base_url(request: httpx.Request) -> None:
|
| 40 |
if request.url.path == "/v1/chat/completions":
|
| 41 |
-
request.url = request.url.copy_with(path=
|
| 42 |
|
| 43 |
client = OpenAI(
|
| 44 |
api_key=OPENAI_API_KEY,
|
| 45 |
-
base_url=
|
| 46 |
http_client=httpx.Client(
|
| 47 |
event_hooks={"request": [update_base_url]}
|
| 48 |
),
|
|
|
|
| 20 |
|
| 21 |
# OpenAI API and custom proxy config
|
| 22 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 23 |
+
#OPENAI_BASE_URL = os.getenv("OPENAI_URL") # e.g. "https://your.proxy.base.url"
|
| 24 |
+
#OPENAI_CUSTOM_PATH = os.getenv("OPENAI_CUSTOM_PATH", "/v1/chat/completions")
|
| 25 |
OPENAI_MODEL = os.getenv("OPENAI_MODEL", "gpt-4")
|
| 26 |
|
| 27 |
# Spotify OAuth setup
|
|
|
|
| 38 |
# OpenAI client with custom base URL and path rewrite
|
| 39 |
def update_base_url(request: httpx.Request) -> None:
|
| 40 |
if request.url.path == "/v1/chat/completions":
|
| 41 |
+
request.url = request.url.copy_with(path="/v1/chat/completions") # if your proxy uses the same path, this can be omitted
|
| 42 |
|
| 43 |
client = OpenAI(
|
| 44 |
api_key=OPENAI_API_KEY,
|
| 45 |
+
base_url="https://api.shapes.inc",
|
| 46 |
http_client=httpx.Client(
|
| 47 |
event_hooks={"request": [update_base_url]}
|
| 48 |
),
|