Lhumpal commited on
Commit
99942af
·
verified ·
1 Parent(s): edb921e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -57
app.py CHANGED
@@ -9,8 +9,7 @@ app = FastAPI()
9
  hf_token = os.environ.get("HF_TOKEN")
10
 
11
  if hf_token:
12
- # client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct", token=hf_token)
13
- client = InferenceClient("Lhumpal/hunting-beast-llm", token=hf_token)
14
  else:
15
  raise ValueError("HF_TOKEN environment variable not set. Please add it as a secret in your Hugging Face Space.")
16
 
@@ -41,58 +40,4 @@ async def chat(request: ChatRequest):
41
 
42
  return {"response": response.choices[0].message.content}
43
  except Exception as e:
44
- raise HTTPException(status_code=500, detail=str(e))
45
-
46
- # from fastapi import FastAPI, HTTPException
47
- # from pydantic import BaseModel
48
- # from huggingface_hub import InferenceClient
49
- # import os
50
-
51
- # app = FastAPI()
52
-
53
- # # Get the token from the environment variable
54
- # hf_token = os.environ.get("HF_TOKEN")
55
-
56
- # if hf_token:
57
- # client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=hf_token)
58
- # else:
59
- # raise ValueError("HF_TOKEN environment variable not set. Please add it as a secret in your Hugging Face Space.")
60
-
61
- # # Rest of your code...
62
-
63
- # class ChatRequest(BaseModel):
64
- # message: str
65
- # history: list[tuple[str, str]] = []
66
- # system_message: str = "You are a friendly Chatbot."
67
- # max_tokens: int = 512
68
- # temperature: float = 0.7
69
- # top_p: float = 0.95
70
-
71
- # class ChatResponse(BaseModel):
72
- # response: str
73
-
74
- # @app.post("/chat", response_model=ChatResponse)
75
- # async def chat(request: ChatRequest):
76
- # try:
77
- # messages = [{"role": "system", "content": request.system_message}]
78
- # for val in request.history:
79
- # if val[0]:
80
- # messages.append({"role": "user", "content": val[0]})
81
- # if val[1]:
82
- # messages.append({"role": "assistant", "content": val[1]})
83
- # messages.append({"role": "user", "content": request.message})
84
-
85
- # response = ""
86
- # for message in client.chat_completion(
87
- # messages,
88
- # max_tokens=request.max_tokens,
89
- # stream=True,
90
- # temperature=request.temperature,
91
- # top_p=request.top_p,
92
- # ):
93
- # token = message.choices[0].delta.content
94
- # response += token
95
-
96
- # return {"response": response}
97
- # except Exception as e:
98
- # raise HTTPException(status_code=500, detail=str(e))
 
9
  hf_token = os.environ.get("HF_TOKEN")
10
 
11
  if hf_token:
12
+ client = InferenceClient("meta-llama/Llama-3.2-3B-Instruct", token=hf_token)
 
13
  else:
14
  raise ValueError("HF_TOKEN environment variable not set. Please add it as a secret in your Hugging Face Space.")
15
 
 
40
 
41
  return {"response": response.choices[0].message.content}
42
  except Exception as e:
43
+ raise HTTPException(status_code=500, detail=str(e))