DevsDoCode commited on
Commit
8207b05
1 Parent(s): 87729e7

Update deepinfra.py

Browse files
Files changed (1) hide show
  1. deepinfra.py +4 -3
deepinfra.py CHANGED
@@ -28,7 +28,9 @@ def generate(message: str, model: str='meta-llama/Meta-Llama-3-70B-Instruct', sy
28
  - Union[str, None]: The response message from the LLM if successful, otherwise None.
29
  """
30
  url = "https://api.deepinfra.com/v1/openai/chat/completions"
31
-
 
 
32
  data = json.dumps(
33
  {
34
  'model': model,
@@ -41,13 +43,12 @@ def generate(message: str, model: str='meta-llama/Meta-Llama-3-70B-Instruct', sy
41
  )
42
 
43
  try:
44
- result = requests.post(url=url, data=data)
45
  return result.json()['choices'][0]['message']['content']
46
  except Exception as e:
47
  print("Error:", e)
48
  return None
49
 
50
-
51
 
52
  if __name__ == "__main__":
53
 
 
28
  - Union[str, None]: The response message from the LLM if successful, otherwise None.
29
  """
30
  url = "https://api.deepinfra.com/v1/openai/chat/completions"
31
+ headers ={
32
+ "Authorization" : "Bearer jwt:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJnaDoxMjE3NTEyOTkiLCJleHAiOjE3MTcwODExMzN9.L51dMtUEJgsWb684EkNAyXIsznZqyJWdrbcPboM2ZgI"
33
+ }
34
  data = json.dumps(
35
  {
36
  'model': model,
 
43
  )
44
 
45
  try:
46
+ result = requests.post(url=url, headers=headers, data=data)
47
  return result.json()['choices'][0]['message']['content']
48
  except Exception as e:
49
  print("Error:", e)
50
  return None
51
 
 
52
 
53
  if __name__ == "__main__":
54