BotifyCloudAdmin commited on
Commit
d6b7bed
·
verified ·
1 Parent(s): e73ae5f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -10,11 +10,16 @@ AVAILABLE_MODELS = {
10
  "Llama3.1-8b-Instruct": "meta-llama/Meta-Llama-3.1-8B-Instruct",
11
  }
12
 
13
- ENDPOINT_URL = "https://api.hyperbolic.xyz/v1"
14
- OAI_API_KEY = os.getenv('HYPERBOLIC_XYZ_KEY')
 
 
15
  PASSWORD = os.getenv("PASSWD") # Store the password in an environment variable
16
 
17
- client = OpenAI(base_url=ENDPOINT_URL, api_key=OAI_API_KEY)
 
 
 
18
 
19
  def respond(
20
  message: str,
@@ -34,7 +39,13 @@ def respond(
34
  messages.append({"role": "user", "content": message})
35
 
36
  response = ""
37
- for chunk in client.chat.completions.create(
 
 
 
 
 
 
38
  model=AVAILABLE_MODELS[model_choice], # Use the selected model
39
  messages=messages,
40
  max_tokens=max_tokens,
 
10
  "Llama3.1-8b-Instruct": "meta-llama/Meta-Llama-3.1-8B-Instruct",
11
  }
12
 
13
+ HYPERB_ENDPOINT_URL = "https://api.hyperbolic.xyz/v1"
14
+ HF_ENDPOINT_URL = "https://huggingface.co/api/inference-proxy/together"
15
+ HYPERB_API_KEY = os.getenv('HYPERBOLIC_XYZ_KEY')
16
+ HF_API_KEY = os.getenv('HF_KEY')
17
  PASSWORD = os.getenv("PASSWD") # Store the password in an environment variable
18
 
19
+ DEPLOY_TO_HF = ["deepseek-ai/DeepSeek-V3"]
20
+
21
+ hyperb_client = OpenAI(base_url=HYPERB_ENDPOINT_URL, api_key=HYPERB_API_KEY)
22
+ hf_client = OpenAI(base_url=HF_ENDPOINT_URL, api_key=HF_API_KEY)
23
 
24
  def respond(
25
  message: str,
 
39
  messages.append({"role": "user", "content": message})
40
 
41
  response = ""
42
+
43
+ if model_choice in DEPLOY_TO_HF:
44
+ this_client = hf_client
45
+ else:
46
+ this_client = hyperb_client
47
+
48
+ for chunk in this_client.chat.completions.create(
49
  model=AVAILABLE_MODELS[model_choice], # Use the selected model
50
  messages=messages,
51
  max_tokens=max_tokens,