RaniRahbani commited on
Commit
1d59cf0
·
verified ·
1 Parent(s): b4c1690

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -4,8 +4,8 @@ from huggingface_hub import InferenceClient
4
  """
5
  For more information on huggingface_hub Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
- client = InferenceClient("unsloth/Llama-3.2-1B-Instruct")
8
- # client = InferenceClient(model="https://aq0teqpujnx3bv68.us-east-1.aws.endpoints.huggingface.cloud/")
9
 
10
  def respond(
11
  message,
@@ -22,7 +22,7 @@ def respond(
22
  "your role is to assist, not replace a registered dietitian, so kindly remind users to "
23
  "consult a professional for personalized advice when necessary."
24
  max_tokens = 512
25
- temperature = 0.7
26
  top_p = 0.95
27
 
28
  messages = [{"role": "system", "content": system_message}]
@@ -41,11 +41,13 @@ def respond(
41
  messages,
42
  max_tokens=max_tokens,
43
  stream=True,
 
44
  temperature=temperature,
45
  top_p=top_p,
46
  ):
47
  token = message.choices[0].delta.content
48
-
 
49
  response += token
50
  yield response
51
 
@@ -57,9 +59,9 @@ demo = gr.ChatInterface(
57
  fn=respond,
58
  #title="Hi there! I'm your Dietician Assistant, here to help you with general advice on diet, nutrition, and healthy eating habits. Let's explore your questions.",
59
  title="Your Personal Dietician Assistant: Expert Guidance on Healthy Eating and Nutrition",
60
- examples=["What are some healthy snacks I can eat if I feel hungry between meals?",
61
- "How can I improve my gut health through diet?",
62
- "Can you recommend some high-protein vegetarian meals?"]
63
  # additional_inputs=[
64
  # gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
65
  # gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
 
4
  """
5
  For more information on huggingface_hub Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
6
  """
7
+ # client = InferenceClient("unsloth/Llama-3.2-1B-Instruct")
8
+ client = InferenceClient( model="https://kjynd32snp9r6qb7.us-east-1.aws.endpoints.huggingface.cloud")
9
 
10
  def respond(
11
  message,
 
22
  "your role is to assist, not replace a registered dietitian, so kindly remind users to "
23
  "consult a professional for personalized advice when necessary."
24
  max_tokens = 512
25
+ temperature = 0.9
26
  top_p = 0.95
27
 
28
  messages = [{"role": "system", "content": system_message}]
 
41
  messages,
42
  max_tokens=max_tokens,
43
  stream=True,
44
+ stop=["<|im_end|><|im_end|>", "<|im_end|>"],
45
  temperature=temperature,
46
  top_p=top_p,
47
  ):
48
  token = message.choices[0].delta.content
49
+ if not token:
50
+ break
51
  response += token
52
  yield response
53
 
 
59
  fn=respond,
60
  #title="Hi there! I'm your Dietician Assistant, here to help you with general advice on diet, nutrition, and healthy eating habits. Let's explore your questions.",
61
  title="Your Personal Dietician Assistant: Expert Guidance on Healthy Eating and Nutrition",
62
+ examples=["How can I lose weight safely?",
63
+ "What is a healthy weight loss rate?",
64
+ "How do I meal prep efficiently?",]
65
  # additional_inputs=[
66
  # gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
67
  # gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),