ianeksdi commited on
Commit
5ce92b5
·
verified ·
1 Parent(s): ed83f87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -3,13 +3,11 @@ from smolagents import CodeAgent, HfApiModel
3
  from tools.final_answer import FinalAnswerTool
4
  from Gradio_UI import GradioUI
5
 
6
- # Updated system prompt with explicit instructions to not include internal reasoning,
7
- # chain-of-thought, intermediate steps, or code snippets.
8
  system_prompt = (
9
  "You are a health and lifestyle advisor specializing in the early detection and prevention of hypertension. "
10
  "Provide direct and concise lifestyle advice based on the user's details. "
11
- "Output a clear answer as plain text with no extra commentary. "
12
- "Do NOT include any internal reasoning, chain-of-thought, intermediate steps, or code snippets."
13
  )
14
 
15
  def clean_response(text):
@@ -45,9 +43,6 @@ agent = CodeAgent(
45
  prompt_templates=prompt_templates
46
  )
47
 
48
- # Override the code extraction function to disable code snippet extraction.
49
- agent.extract_code_snippet = lambda text: text
50
-
51
  def run_agent(user_input):
52
  """
53
  Runs the agent and returns a clean, formatted response.
@@ -56,7 +51,7 @@ def run_agent(user_input):
56
  response = agent.run(user_input)
57
  return clean_response(response)
58
  except Exception as e:
59
- return "I apologize, but I couldn't process your request. Please try again."
60
 
61
  # Launch the Gradio UI
62
  GradioUI(agent).launch()
 
3
  from tools.final_answer import FinalAnswerTool
4
  from Gradio_UI import GradioUI
5
 
6
+ # Simplified system prompt without any code-related instructions
 
7
  system_prompt = (
8
  "You are a health and lifestyle advisor specializing in the early detection and prevention of hypertension. "
9
  "Provide direct and concise lifestyle advice based on the user's details. "
10
+ "Output a clear answer as plain text with no extra commentary."
 
11
  )
12
 
13
  def clean_response(text):
 
43
  prompt_templates=prompt_templates
44
  )
45
 
 
 
 
46
  def run_agent(user_input):
47
  """
48
  Runs the agent and returns a clean, formatted response.
 
51
  response = agent.run(user_input)
52
  return clean_response(response)
53
  except Exception as e:
54
+ return f"I apologize, but I couldn't process your request. Please try again."
55
 
56
  # Launch the Gradio UI
57
  GradioUI(agent).launch()