Spaces:
Sleeping
Sleeping
lukestanley
commited on
Commit
•
124003a
1
Parent(s):
8093276
Tidying: reordering code a bit
Browse files
utils.py
CHANGED
@@ -184,21 +184,6 @@ def llm_stream_serverless(prompt,model):
|
|
184 |
# TODO: remove replacement once new version of runpod is deployed
|
185 |
return json.loads(output)
|
186 |
|
187 |
-
def query_ai_prompt(prompt, replacements, model_class):
|
188 |
-
prompt = replace_text(prompt, replacements)
|
189 |
-
if LLM_WORKER == "mistral":
|
190 |
-
return llm_stream_mistral_api(prompt, model_class)
|
191 |
-
if LLM_WORKER == "mistral":
|
192 |
-
return llm_stream_mistral_api(prompt, model_class)
|
193 |
-
if LLM_WORKER == "runpod":
|
194 |
-
return llm_stream_serverless(prompt, model_class)
|
195 |
-
if LLM_WORKER == "http":
|
196 |
-
return llm_streaming(prompt, model_class)
|
197 |
-
if LLM_WORKER == "in_memory":
|
198 |
-
return llm_stream_sans_network(prompt, model_class)
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
# Global variables to enforce rate limiting
|
203 |
LAST_REQUEST_TIME = None
|
204 |
REQUEST_INTERVAL = 0.5 # Minimum time interval between requests in seconds
|
@@ -248,4 +233,17 @@ def llm_stream_mistral_api(prompt: str, pydantic_model_class) -> Union[str, Dict
|
|
248 |
print("No pydantic model class provided, returning without class validation")
|
249 |
return json.loads(output)
|
250 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
|
|
|
184 |
# TODO: remove replacement once new version of runpod is deployed
|
185 |
return json.loads(output)
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
# Global variables to enforce rate limiting
|
188 |
LAST_REQUEST_TIME = None
|
189 |
REQUEST_INTERVAL = 0.5 # Minimum time interval between requests in seconds
|
|
|
233 |
print("No pydantic model class provided, returning without class validation")
|
234 |
return json.loads(output)
|
235 |
|
236 |
+
def query_ai_prompt(prompt, replacements, model_class):
|
237 |
+
prompt = replace_text(prompt, replacements)
|
238 |
+
if LLM_WORKER == "mistral":
|
239 |
+
return llm_stream_mistral_api(prompt, model_class)
|
240 |
+
if LLM_WORKER == "mistral":
|
241 |
+
return llm_stream_mistral_api(prompt, model_class)
|
242 |
+
if LLM_WORKER == "runpod":
|
243 |
+
return llm_stream_serverless(prompt, model_class)
|
244 |
+
if LLM_WORKER == "http":
|
245 |
+
return llm_streaming(prompt, model_class)
|
246 |
+
if LLM_WORKER == "in_memory":
|
247 |
+
return llm_stream_sans_network(prompt, model_class)
|
248 |
+
|
249 |
|