pvanand commited on
Commit
28a7c76
1 Parent(s): b998742

Update helper_functions_api.py

Browse files
Files changed (1) hide show
  1. helper_functions_api.py +11 -0
helper_functions_api.py CHANGED
@@ -206,6 +206,17 @@ def openrouter_response(messages, model="meta-llama/llama-3-70b-instruct:nitro")
206
  print(f"An error occurred: {str(e)}")
207
  return None
208
 
 
 
 
 
 
 
 
 
 
 
 
209
 
210
  def json_from_text(text):
211
  """
 
206
  print(f"An error occurred: {str(e)}")
207
  return None
208
 
209
+ def openrouter_response_stream(messages, model="meta-llama/llama-3-70b-instruct:nitro"):
210
+ response = or_client.chat.completions.create(
211
+ model=model,
212
+ messages=messages,
213
+ max_tokens=4096,
214
+ stream=True
215
+ )
216
+
217
+ for chunk in response:
218
+ if chunk.choices[0].delta.content is not None:
219
+ yield chunk.choices[0].delta.content
220
 
221
  def json_from_text(text):
222
  """