lalashechka commited on
Commit
2b60277
·
verified ·
1 Parent(s): 8c02509

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -34,6 +34,13 @@ async def generate_response(request_body: RequestBody):
34
  json_data = {'messages': [{'role': 'user','content': input_text}],'model': 'llama-3.1-70b-versatile',}
35
  response = requests.post('https://api.groq.com/openai/v1/chat/completions', headers=headers, json=json_data)
36
  all_chunk = response.json()["choices"][0]["message"]["content"]
 
 
 
 
 
 
 
37
 
38
  if key_body != key_true:
39
  all_chunk = "How's the hack going?"
 
34
  json_data = {'messages': [{'role': 'user','content': input_text}],'model': 'llama-3.1-70b-versatile',}
35
  response = requests.post('https://api.groq.com/openai/v1/chat/completions', headers=headers, json=json_data)
36
  all_chunk = response.json()["choices"][0]["message"]["content"]
37
+
38
+ if model == "cohere":
39
+ key_cohere = os.environ['key_cohere']
40
+ headers = {'accept': 'application/json','content-type': 'application/json','Authorization': f'Bearer {key_cohere}',}
41
+ data = {"model":"command-r-plus","messages":[{ "role": "user", "content": input_text}]}
42
+ response = requests.post('https://api.cohere.com/v2/chat', headers=headers, json=data)
43
+ all_chunk = response.json()['message']['content'][0]['text']
44
 
45
  if key_body != key_true:
46
  all_chunk = "How's the hack going?"