Skip to content

Commit f80771c

Browse files
committed
remove OPENAI_API_KEY from provider sample
1 parent ecf3570 commit f80771c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

samples/managed-llm-provider/app/app.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import os
21
import json
32
import logging
3+
import os
4+
5+
import requests
46
from fastapi import FastAPI, Form, Request
57
from fastapi.responses import HTMLResponse
6-
import requests
78

89
app = FastAPI()
910

@@ -18,7 +19,7 @@
1819
# Get the API key for the LLM
1920
# For development, you can use your local API key. In production, the LLM gateway service will override the need for it.
2021
def get_api_key():
21-
return os.getenv("OPENAI_API_KEY", "API key not set")
22+
return os.getenv("OPENAI_API_KEY", "")
2223

2324
# Home page form
2425
@app.get("/", response_class=HTMLResponse)
@@ -29,14 +30,14 @@ async def home():
2930
<body>
3031
<h1>Ask the AI Model</h1>
3132
<form method="post" action="/ask" onsubmit="document.getElementById('loader').style.display='block'">
32-
<textarea name="prompt" autofocus="autofocus" rows="5" cols="60" placeholder="Enter your question here..."
33+
<textarea name="prompt" autofocus="autofocus" rows="5" cols="60" placeholder="Enter your question here..."
3334
onkeydown="if(event.key==='Enter'&&!event.shiftKey){event.preventDefault();this.form.submit();}">
3435
</textarea>
3536
<br><br>
3637
<input type="submit" value="Ask">
3738
</form>
3839
</body>
39-
40+
4041
</html>
4142
"""
4243

samples/managed-llm-provider/compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
app:
3-
build:
3+
build:
44
context: ./app
55
dockerfile: Dockerfile
66
ports:
@@ -9,7 +9,6 @@ services:
99
environment:
1010
- ENDPOINT_URL=http://llm/api/v1/chat/completions # endpoint to the Provider Service
1111
- MODEL=anthropic.claude-3-haiku-20240307-v1:0 # LLM model ID used in the Provider Service
12-
- OPENAI_API_KEY=FAKE_TOKEN # the actual value will be ignored when using the Provider Service
1312
healthcheck:
1413
test: ["CMD", "python3", "-c", "import sys, urllib.request; urllib.request.urlopen(sys.argv[1]).read()", "http://localhost:8000/"]
1514
interval: 30s

0 commit comments

Comments
 (0)