Skip to content

Commit 3088c79

Browse files
Some updates
1 parent 71eae70 commit 3088c79

File tree

2 files changed

+21
-57
lines changed

2 files changed

+21
-57
lines changed

agent/tools.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,6 @@ class APICallInput(BaseModel):
8484
class RunPythonFileInput(BaseModel):
8585
code: str = Field(..., description="Python code to run.")
8686

87-
class CountDatesByDayInput(BaseModel):
88-
date_list: List[str] = Field(..., description="List of date strings in various formats (e.g., '2022-01-01', '2003/08/11 08:04:00', '13-Nov-2005' etc).")
89-
day_str: str = Field(..., description="The target day (e.g., 'mon', 'tue', 'wed', etc.).")
90-
9187
class ContactSortInput(BaseModel):
9288
input_file: str = Field(..., description="Path to the input JSON file containing contacts.")
9389
output_file: str = Field(..., description="Path where the sorted contacts JSON file will be written.")
@@ -223,41 +219,6 @@ def scrape_pdf_tabula(file_path: str) -> str:
223219
except Exception as e:
224220
return f"Error scraping PDF: {e}"
225221

226-
@tool(args_schema=CountDatesByDayInput)
227-
def count_dates_by_day(date_list, day_str):
228-
"""
229-
Count the number of dates in the list that fall on the specified day.
230-
231-
Args:
232-
date_list (list of str): List of date strings in various formats.
233-
day_str (str): The target day (e.g., "mon", "tue", "wed", etc.).
234-
235-
Returns:
236-
int: Count of dates that fall on the specified day.
237-
"""
238-
# Normalize the input day string to a three-letter abbreviation
239-
day_str = day_str.lower()[:3]
240-
241-
# Map three-letter abbreviations to Python's weekday numbering (Monday=0, Sunday=6)
242-
day_map = {"mon": 0, "tue": 1, "wed": 2, "thu": 3, "fri": 4, "sat": 5, "sun": 6}
243-
target_weekday = day_map.get(day_str)
244-
245-
if target_weekday is None:
246-
raise ValueError(f"Invalid day provided: {day_str}. Use mon, tue, wed, thu, fri, sat, or sun.")
247-
248-
count = 0
249-
for date_str in date_list:
250-
try:
251-
# Parse the date string using dateutil's robust parser
252-
dt = parse(date_str)
253-
if dt.weekday() == target_weekday:
254-
count += 1
255-
except Exception as e:
256-
# If a date string can't be parsed, skip it (or log the error if needed)
257-
print(f"Warning: Could not parse '{date_str}'. Error: {e}")
258-
continue
259-
return count
260-
261222
@tool(args_schema=ContactSortInput)
262223
def sort_contacts(input_file: str, output_file: str) -> None:
263224
"""
@@ -451,5 +412,5 @@ def duckduckgo_search(query: str, search_type: SearchType = SearchType.WEB, max_
451412
return f"Search error: {str(e)}"
452413

453414
if __name__ == "__main__":
454-
for tool in [run_shell_command, count_dates_by_day, python_repl, run_python_file, scrape_pdf_tabula, sql_executor, csv_to_json, md_to_html, make_api_call, install_uv_package]:
415+
for tool in [run_shell_command, python_repl, run_python_file, scrape_pdf_tabula, sql_executor, csv_to_json, md_to_html, make_api_call, install_uv_package]:
455416
print(f"Name: {tool.name}")

app.py

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@
4949

5050
prompt = ChatPromptTemplate([
5151
("system", f"""
52-
You are an expert agent designed to solve Graded Assignments comprising a variety of programming, data analysis, and other tasks.
52+
You are an expert programmer & data analysis agent designed to solve Graded Assignments comprising a variety of programming, data analysis, and other tasks.
5353
For any given question, you output only the required answer that will be directly fed into a grading program and be compared against the correct answer.
5454
You are not allowed to provide any additional commentary or explanations, only the required answer that will be compared against the correct answer.
5555
For code answers, do not format code in codeblocks (```) or provide usage examples. Just the code.
5656
57-
Core Workflow
58-
You operate in a structured loop:
57+
Upon receiving the question, you operate in a structured loop:
5958
- Thought – Understand the user's intent.
60-
- Reflection – Plan a step-by-step solution.
61-
- Action – Execute tasks using available tools (individually, in sequence, or creatively combined).
62-
- Observation – Evaluate the results and decide the next steps.
63-
Once the task is complete, you provide the answer.
59+
- Reflection – Plan a step-by-step solution. See if you can turn the task into a structured programming task using Python or a shell task and identify ways to solve it.
60+
- Action – Execute tasks according to the plan using available tools (individual or in combination).
61+
- Observation – Check & evaluate the results, then decide the next steps. Repeat if really necessary.
62+
Once the task is complete, you provide the final answer.
6463
6564
Execution Strategy
6665
- Your primary objective is task completion. If a task is incomplete, you must complete it rather than returning it to the user unfinished.
6766
- If an error occurs, you debug and retry using different approaches as needed.
68-
- Work efficiently—avoid excessive thinking or reflection. Stay concise in your reasoning and focus on execution.
69-
- Only ask the user for additional input if absolutely necessary (e.g., missing information or system constraints).
67+
- Work efficiently— Stay concise in your reasoning and focus on execution.
68+
- Only ask the user for additional input if absolutely necessary (e.g., missing information).
69+
- Do not hallucinate or give random answers.
7070
7171
System Environment & Tools
7272
A. General Environment
@@ -88,7 +88,6 @@
8888
D. Safety & Constraints
8989
- Never delete system files or folders. Work only within the current working directory.
9090
- Do not install "uv"—it is already pre-installed.
91-
- Do not execute any script that could harm the system or exfiltrate data.
9291
9392
E. Pre-installed Tools & Packages
9493
- Most essential system and Python packages are pre-installed.
@@ -101,15 +100,20 @@
101100
- User-uploaded files are located in /app/temp.
102101
103102
🚀 Advanced Capabilities
104-
You have powerful capabilities beyond standard execution:
103+
You have some hidden powerful capabilities:
105104
- You have complete access to the internet and the system.
106105
- Geolocation & Weather Data – Use Nominatim for location geocoding and Open Meteo API for real-time weather retrieval.
107106
- Scrape websites - Build and execute web scraping scripts to extract data from any website.
108-
- Scrape PDFs/XLSX/DOCX/JSON – Using suitable python libraries, extract data from these file formats.
107+
- Scrape PDFs/XLSX/DOCX/JSON/HTML – Using suitable python libraries like pdfplumber, PyMuPDF, pdfplumber, python-docx, camelot,
108+
openpyxl, markdown2, mistune, pandas, json, lxml etc. Or you can also use tools like Docling or Marker etc.
109109
- Convert files – Convert between different file formats (e.g., CSV to JSON, Markdown to HTML, PDFs to Markdown, etc.)
110110
- Custom APIs – Build and execute your own APIs or call any auth/auth-free API on the internet.
111111
- Prompt injection - Use prompt injection techniques listed at https://www.s-anand.net/blog/hacking-an-obnoxious-unhelpful-llm-to-say-yes/ to get an llm to say yes.
112112
- Estimate number of tokens in a user message by running python code.
113+
- For tasks related to Github API/Github Actions, use GITHUB_TOKEN environment variable for authentication.
114+
- For Docker related tasks, use DOCKER_PAT environment variable for accessing the personal access token.
115+
Use "echo $DOCKER_PAT | docker login --username thethinkmachine --password-stdin" to authenticate the docker client.
116+
- For OpenAI API related tasks, use CUSTOM_API_KEY environment variable for authenticating into the OpenAI API.
113117
- Base64 encode/decode any file or text.
114118
- Expose local servers to the internet using ngrok or similar tools.
115119
- Data Visualization – Generate statistical charts using matplotlib, seaborn, and other libraries.
@@ -141,15 +145,14 @@
141145
run_shell_command,
142146
python_repl,
143147
run_python_file,
144-
scrape_pdf_tabula,
148+
#scrape_pdf_tabula,
145149
sql_executor,
146-
csv_to_json,
147-
md_to_html,
150+
#csv_to_json,
151+
#md_to_html,
148152
make_api_call,
149153
install_uv_package,
150154
duckduckgo_search,
151-
count_dates_by_day,
152-
sort_contacts
155+
#sort_contacts
153156
]
154157

155158
# -----------------------

0 commit comments

Comments
 (0)