ParthSadaria commited on
Commit
9d35223
·
verified ·
1 Parent(s): 045bd95

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -23
main.py CHANGED
@@ -5,17 +5,8 @@ import requests
5
 
6
  app = FastAPI()
7
 
8
- # Valid API keys and model aliases
9
  valid_api_keys = ['PARTH-SADARIA-NI-API-CHAWI', 'HEET-NI-CHEESEWADI-API-KEY']
10
- model_aliases = {
11
- 'Llama-3.1-Nemotron-70B-Instruct': 'nvidia/Llama-3.1-Nemotron-70B-Instruct',
12
- 'Meta-Llama-3.1-8B-Instruct': 'meta-llama/Meta-Llama-3.1-8B-Instruct',
13
- 'Meta-Llama-3.1-70B-Instruct': 'meta-llama/Meta-Llama-3.1-70B-Instruct',
14
- 'Meta-Llama-3.1-70B-Instruct-Turbo': 'meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo',
15
- 'Meta-Llama-3.1-405B-Instruct': 'meta-llama/Meta-Llama-3.1-405B-Instruct',
16
- 'Llama-3.2-11B-Vision-Instruct': 'meta-llama/Llama-3.2-11B-Vision-Instruct',
17
- 'Meta-Llama-3-8B-Instruct': 'meta-llama/Meta-Llama-3-8B-Instruct',
18
- }
19
 
20
  class Payload(BaseModel):
21
  model: str
@@ -42,20 +33,11 @@ async def get_completion(payload: Payload, request: Request):
42
  if api_key not in valid_api_keys:
43
  raise HTTPException(status_code=403, detail="Forbidden: Invalid API key. Join dsc.gg/chadgang and DM @mr_leaderyt on Discord for a free API key :)")
44
 
45
- # Resolve model alias or set default service
46
- user_model = payload.model
47
- full_model_name = model_aliases.get(user_model, user_model)
48
 
49
- # If model alias is not found, default to tiptopuni
50
- is_deepinfra_model = full_model_name in model_aliases.values()
51
- url = (
52
- "https://api.deepinfra.com/v1/openai/chat/completions"
53
- if is_deepinfra_model else
54
- "https://gpt.tiptopuni.com/api/openai/v1/chat/completions"
55
- )
56
-
57
- # Set up payload for streaming
58
- payload_dict = {**payload.dict(), "model": full_model_name, "stream": True}
59
 
60
  # Define a generator to stream the response
61
  def stream_generator():
 
5
 
6
  app = FastAPI()
7
 
8
+ # Valid API keys
9
  valid_api_keys = ['PARTH-SADARIA-NI-API-CHAWI', 'HEET-NI-CHEESEWADI-API-KEY']
 
 
 
 
 
 
 
 
 
10
 
11
  class Payload(BaseModel):
12
  model: str
 
33
  if api_key not in valid_api_keys:
34
  raise HTTPException(status_code=403, detail="Forbidden: Invalid API key. Join dsc.gg/chadgang and DM @mr_leaderyt on Discord for a free API key :)")
35
 
36
+ # Set the URL for all requests
37
+ url = "https://gpt.tiptopuni.com/api/openai/v1/chat/completions"
 
38
 
39
+ # Prepare the payload for streaming
40
+ payload_dict = {**payload.dict(), "stream": True}
 
 
 
 
 
 
 
 
41
 
42
  # Define a generator to stream the response
43
  def stream_generator():