srbhavya01 commited on
Commit
1c37cbf
·
verified ·
1 Parent(s): 978ff37

Update model_api.py

Browse files
Files changed (1) hide show
  1. model_api.py +14 -14
model_api.py CHANGED
@@ -2,21 +2,21 @@ from huggingface_hub import InferenceClient
2
  import os
3
 
4
  def query_model(prompt):
5
- try:
6
- HF_TOKEN = os.getenv("HF_TOKEN")
7
 
8
- client = InferenceClient(
9
- model="HuggingFaceH4/zephyr-7b-beta",
10
- token=HF_TOKEN
11
- )
12
 
13
- response = client.text_generation(
14
- prompt,
15
- max_new_tokens=1200,
16
- temperature=0.7
17
- )
18
 
19
- return response
 
 
 
 
 
 
 
20
 
21
- except Exception as e:
22
- return f"Error: {str(e)}"
 
2
  import os
3
 
4
  def query_model(prompt):
 
 
5
 
6
+ HF_TOKEN = os.getenv("HF_TOKEN")
 
 
 
7
 
8
+ client = InferenceClient(
9
+ model="microsoft/Phi-3-mini-4k-instruct",
10
+ token=HF_TOKEN
11
+ )
 
12
 
13
+ response = client.chat_completion(
14
+ messages=[
15
+ {"role": "system", "content": "You are a certified professional fitness trainer."},
16
+ {"role": "user", "content": prompt}
17
+ ],
18
+ max_tokens=1500,
19
+ temperature=0.7
20
+ )
21
 
22
+ return response.choices[0].message.content