sahil-datascience commited on
Commit
727ef0f
·
1 Parent(s): bba52b2

Prompt template .yaml added

Browse files
Files changed (2) hide show
  1. app.py +11 -10
  2. prompt.yaml +16 -0
app.py CHANGED
@@ -8,18 +8,22 @@ from smolagents import (CodeAgent, InferenceClientModel,
8
  DuckDuckGoSearchTool, WikipediaSearchTool,
9
  PythonInterpreterTool, VisitWebpageTool)
10
  from smolagents.agents import PromptTemplates
 
11
 
12
  # (Keep Constants as is)
13
  # --- Constants ---
14
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
15
 
16
- SYSTEM_PROMPT = """You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
17
- YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
18
- If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise.
19
- If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
20
- If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string."""
21
-
22
 
 
 
 
 
 
 
23
 
24
  # --- Basic Agent Definition ---
25
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
@@ -32,10 +36,7 @@ class BasicAgent:
32
  wiki_tool = WikipediaSearchTool()
33
  python_tool = PythonInterpreterTool()
34
  visit_tool = VisitWebpageTool()
35
-
36
- # Create prompt templates with your system prompt
37
- prompt_templates = PromptTemplates(system=SYSTEM_PROMPT)
38
-
39
  self.agent = CodeAgent(
40
  model=self.model,
41
  tools=[search_tool, wiki_tool, python_tool, visit_tool],
 
8
  DuckDuckGoSearchTool, WikipediaSearchTool,
9
  PythonInterpreterTool, VisitWebpageTool)
10
  from smolagents.agents import PromptTemplates
11
+ import yaml
12
 
13
  # (Keep Constants as is)
14
  # --- Constants ---
15
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
16
 
17
+ # --- System Prompt ---
18
+ with open("prompts.yaml", "r", encoding="utf-8") as f:
19
+ prompts = yaml.safe_load(f)
 
 
 
20
 
21
+ prompt_templates = PromptTemplates(
22
+ system=prompts["system"],
23
+ planning=prompts["planning"],
24
+ managed_agent=prompts["managed_agent"],
25
+ final_answer=prompts["final_answer"],
26
+ )
27
 
28
  # --- Basic Agent Definition ---
29
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
36
  wiki_tool = WikipediaSearchTool()
37
  python_tool = PythonInterpreterTool()
38
  visit_tool = VisitWebpageTool()
39
+
 
 
 
40
  self.agent = CodeAgent(
41
  model=self.model,
42
  tools=[search_tool, wiki_tool, python_tool, visit_tool],
prompt.yaml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ system: |
2
+ You are a general AI assistant. I will ask you a question.
3
+ Report your thoughts, and finish your answer with the following template: FINAL ANSWER: [YOUR FINAL ANSWER].
4
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
5
+ If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise.
6
+ If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
7
+ If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
8
+ planning: |
9
+ Think step by step and plan how to answer the question using available tools.
10
+ managed_agent: |
11
+ If you are managing another agent. Delegate tasks as needed.
12
+ final_answer: |
13
+ YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings.
14
+ If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise.
15
+ If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise.
16
+ If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.