Spaces:
Sleeping
Sleeping
lukestanley
commited on
Commit
•
00af17e
1
Parent(s):
859cc57
Assert RunPod env vars are setup before trying to use them
Browse files- .gitignore +2 -1
- utils.py +3 -0
.gitignore
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
.aider*
|
2 |
-
.cache
|
|
|
|
1 |
.aider*
|
2 |
+
.cache
|
3 |
+
*.pyc
|
utils.py
CHANGED
@@ -155,6 +155,8 @@ def llm_stream_sans_network(
|
|
155 |
def llm_stream_serverless(prompt,model):
|
156 |
RUNPOD_ENDPOINT_ID = env.get("RUNPOD_ENDPOINT_ID")
|
157 |
RUNPOD_API_KEY = env.get("RUNPOD_API_KEY")
|
|
|
|
|
158 |
url = f"https://api.runpod.ai/v2/{RUNPOD_ENDPOINT_ID}/runsync"
|
159 |
|
160 |
headers = {
|
@@ -171,6 +173,7 @@ def llm_stream_serverless(prompt,model):
|
|
171 |
}
|
172 |
|
173 |
response = requests.post(url, json=data, headers=headers)
|
|
|
174 |
result = response.json()
|
175 |
print(result)
|
176 |
output = result['output'].replace("model:mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf\n", "")
|
|
|
155 |
def llm_stream_serverless(prompt,model):
|
156 |
RUNPOD_ENDPOINT_ID = env.get("RUNPOD_ENDPOINT_ID")
|
157 |
RUNPOD_API_KEY = env.get("RUNPOD_API_KEY")
|
158 |
+
assert RUNPOD_ENDPOINT_ID, "RUNPOD_ENDPOINT_ID environment variable not set"
|
159 |
+
assert RUNPOD_API_KEY, "RUNPOD_API_KEY environment variable not set"
|
160 |
url = f"https://api.runpod.ai/v2/{RUNPOD_ENDPOINT_ID}/runsync"
|
161 |
|
162 |
headers = {
|
|
|
173 |
}
|
174 |
|
175 |
response = requests.post(url, json=data, headers=headers)
|
176 |
+
assert response.status_code == 200, f"Unexpected RunPod API status code: {response.status_code} with body: {response.text}"
|
177 |
result = response.json()
|
178 |
print(result)
|
179 |
output = result['output'].replace("model:mixtral-8x7b-instruct-v0.1.Q4_K_M.gguf\n", "")
|