ianeksdi commited on
Commit
1890de8
·
verified ·
1 Parent(s): e098322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import yaml
2
  import re
3
- from smolagents import HfApiModel
4
  from tools.final_answer import FinalAnswerTool
5
  from Gradio_UI import GradioUI
6
 
7
- # 🚀 Updated system prompt: No code extraction allowed.
8
  system_prompt = (
9
  "You are a health and lifestyle advisor specializing in the early detection and prevention of hypertension. "
10
  "Provide only the final, direct, and concise lifestyle advice based solely on the user's details. "
@@ -22,7 +22,7 @@ def remove_code_snippets(text):
22
  # ✅ Use only the final_answer tool.
23
  final_answer = FinalAnswerTool()
24
 
25
- # 🎯 Updated Model Setup
26
  model = HfApiModel(
27
  max_tokens=2096,
28
  temperature=0.5,
@@ -34,10 +34,10 @@ model = HfApiModel(
34
  with open("prompts.yaml", 'r') as stream:
35
  prompt_templates = yaml.safe_load(stream)
36
 
37
- # 🔄 Initialize GenericAgent instead of CodeAgent
38
- agent = GenericAgent(
39
  model=model,
40
- tools=[final_answer], # Restricted to final answer only.
41
  max_steps=6,
42
  verbosity_level=1,
43
  grammar=None,
@@ -51,7 +51,7 @@ agent = GenericAgent(
51
  def run_agent(user_input):
52
  """Runs the agent and ensures no code snippets are in the output."""
53
  raw_response = agent.run(user_input)
54
- clean_response = remove_code_snippets(raw_response)
55
  return clean_response
56
 
57
  # 🚀 Launch the Gradio UI.
 
1
  import yaml
2
  import re
3
+ from smolagents import CodeAgent, HfApiModel
4
  from tools.final_answer import FinalAnswerTool
5
  from Gradio_UI import GradioUI
6
 
7
+ # 🚀 Updated system prompt: No code recognition or extraction allowed.
8
  system_prompt = (
9
  "You are a health and lifestyle advisor specializing in the early detection and prevention of hypertension. "
10
  "Provide only the final, direct, and concise lifestyle advice based solely on the user's details. "
 
22
  # ✅ Use only the final_answer tool.
23
  final_answer = FinalAnswerTool()
24
 
25
+ # 🎯 Model setup
26
  model = HfApiModel(
27
  max_tokens=2096,
28
  temperature=0.5,
 
34
  with open("prompts.yaml", 'r') as stream:
35
  prompt_templates = yaml.safe_load(stream)
36
 
37
+ # 🔄 Initialize CodeAgent (but block code extraction)
38
+ agent = CodeAgent(
39
  model=model,
40
+ tools=[final_answer], # Restricted to final advice only.
41
  max_steps=6,
42
  verbosity_level=1,
43
  grammar=None,
 
51
  def run_agent(user_input):
52
  """Runs the agent and ensures no code snippets are in the output."""
53
  raw_response = agent.run(user_input)
54
+ clean_response = remove_code_snippets(raw_response) # Filter out code snippets
55
  return clean_response
56
 
57
  # 🚀 Launch the Gradio UI.