proitm commited on
Commit
fe768be
·
verified ·
1 Parent(s): 7a3cce7

Added full system prompt

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -16,6 +16,19 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
16
  MODEL_ID = "gemini/gemini-2.5-pro-preview-06-05"
17
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  class BasicAgent:
20
  def __init__(self):
21
  print("BasicAgent initialized to use smolagents.")
@@ -31,6 +44,7 @@ class BasicAgent:
31
  self.agent_executor = CodeAgent(
32
  model=llm_model,
33
  tools=[search_tool],
 
34
  )
35
  print("smolagents AgentExecutor initialized successfully with WebSearchTool.")
36
 
@@ -45,11 +59,6 @@ class BasicAgent:
45
  def __call__(self, question: str) -> str:
46
  print(f"\nAgent (smolagents) received question (first 100 chars): {question[:100]}...")
47
  try:
48
- prompt = f"""
49
- If you call any API and it returns rate limit then attempt again but add 30 seconds delay.
50
- Answer the following question without formatting, reasoning or explanation.
51
- ${question}
52
- """
53
  response = self.agent_executor.run(question)
54
 
55
  print(f"Agent (smolagents) returning answer (first 50 chars): {str(response)[:50]}...")
 
16
  MODEL_ID = "gemini/gemini-2.5-pro-preview-06-05"
17
  GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
18
 
19
+ SYSTEM_PROMPT = """
20
+ You are a highly capable and precise code generation and information retrieval agent. Your primary goal is to answer questions from various datasets.
21
+ Instructions:
22
+ Analyze the problem: Understand the user's query, specifically focusing on the factual questions.
23
+ Utilize Web Search: Before attempting to answer, use web search (Google Search or Browsing tool) to find the most accurate and up-to-date information relevant to the question. Formulate precise search queries. Prioritize authoritative sources.
24
+ Generate Code (if necessary): If the question requires computation, data manipulation, or logical reasoning that can be solved by code, generate the necessary code. The code should be correct, efficient, and directly solve the problem posed by the question. Use appropriate programming languages for the task. Ensure the code produces the final answer.
25
+ If you call any API and it returns rate limit then attempt again but add 30 seconds delay.
26
+ Precision is paramount: Your final answer must be as precise and accurate as possible.
27
+ No Explanations or Commentary: Crucially, provide ONLY the final answer to the question. Do NOT include any introductory phrases, concluding remarks, explanations of your thought process, code comments (unless the code itself is the answer), or any other conversational text. Your output should be the direct, concise answer. If the answer is code, provide only the code. If the answer is a numerical value or a string, provide only that value or string.
28
+ Your output format for questions will always be:
29
+ [THE PRECISE ANSWER (e.g., a number, a string, or the complete code if the code itself is the answer)]
30
+ """
31
+
32
  class BasicAgent:
33
  def __init__(self):
34
  print("BasicAgent initialized to use smolagents.")
 
44
  self.agent_executor = CodeAgent(
45
  model=llm_model,
46
  tools=[search_tool],
47
+ system_prompt=SYSTEM_PROMPT,
48
  )
49
  print("smolagents AgentExecutor initialized successfully with WebSearchTool.")
50
 
 
59
  def __call__(self, question: str) -> str:
60
  print(f"\nAgent (smolagents) received question (first 100 chars): {question[:100]}...")
61
  try:
 
 
 
 
 
62
  response = self.agent_executor.run(question)
63
 
64
  print(f"Agent (smolagents) returning answer (first 50 chars): {str(response)[:50]}...")