Edited final_answer
Browse files
tools/.ipynb_checkpoints/final_answer-checkpoint.py
CHANGED
@@ -13,7 +13,6 @@
|
|
13 |
# def __init__(self, *args, **kwargs):
|
14 |
# self.is_initialized = False
|
15 |
|
16 |
-
|
17 |
from typing import Any
|
18 |
from smolagents.tools import Tool
|
19 |
|
@@ -33,11 +32,14 @@ class FinalAnswerTool(Tool):
|
|
33 |
|
34 |
# Case 2: If the answer is a list of job listings, format them properly
|
35 |
elif isinstance(answer, list) and all(isinstance(job, dict) for job in answer):
|
36 |
-
formatted_output = "**🔍
|
|
|
|
|
|
|
37 |
|
38 |
for idx, job in enumerate(answer, start=1):
|
39 |
-
title = job.get("Title", "
|
40 |
-
company = job.get("Company", "
|
41 |
location = job.get("Location", "Anywhere")
|
42 |
|
43 |
formatted_output += (
|
@@ -47,6 +49,6 @@ class FinalAnswerTool(Tool):
|
|
47 |
)
|
48 |
return formatted_output
|
49 |
|
50 |
-
# Case 3: If it's an
|
51 |
else:
|
52 |
return f"📌 **Final Answer:**\n\n```{str(answer)}```"
|
|
|
13 |
# def __init__(self, *args, **kwargs):
|
14 |
# self.is_initialized = False
|
15 |
|
|
|
16 |
from typing import Any
|
17 |
from smolagents.tools import Tool
|
18 |
|
|
|
32 |
|
33 |
# Case 2: If the answer is a list of job listings, format them properly
|
34 |
elif isinstance(answer, list) and all(isinstance(job, dict) for job in answer):
|
35 |
+
formatted_output = "**🔍 Job Listings Found**\n\n"
|
36 |
+
|
37 |
+
if not answer:
|
38 |
+
return "⚠️ No job listings found."
|
39 |
|
40 |
for idx, job in enumerate(answer, start=1):
|
41 |
+
title = job.get("Title", "Unknown Job Title")
|
42 |
+
company = job.get("Company", "Unknown Company")
|
43 |
location = job.get("Location", "Anywhere")
|
44 |
|
45 |
formatted_output += (
|
|
|
49 |
)
|
50 |
return formatted_output
|
51 |
|
52 |
+
# Case 3: If it's an unexpected format, return it as a formatted string
|
53 |
else:
|
54 |
return f"📌 **Final Answer:**\n\n```{str(answer)}```"
|
tools/final_answer.py
CHANGED
@@ -13,7 +13,6 @@
|
|
13 |
# def __init__(self, *args, **kwargs):
|
14 |
# self.is_initialized = False
|
15 |
|
16 |
-
|
17 |
from typing import Any
|
18 |
from smolagents.tools import Tool
|
19 |
|
@@ -33,11 +32,14 @@ class FinalAnswerTool(Tool):
|
|
33 |
|
34 |
# Case 2: If the answer is a list of job listings, format them properly
|
35 |
elif isinstance(answer, list) and all(isinstance(job, dict) for job in answer):
|
36 |
-
formatted_output = "**🔍
|
|
|
|
|
|
|
37 |
|
38 |
for idx, job in enumerate(answer, start=1):
|
39 |
-
title = job.get("Title", "
|
40 |
-
company = job.get("Company", "
|
41 |
location = job.get("Location", "Anywhere")
|
42 |
|
43 |
formatted_output += (
|
@@ -47,6 +49,6 @@ class FinalAnswerTool(Tool):
|
|
47 |
)
|
48 |
return formatted_output
|
49 |
|
50 |
-
# Case 3: If it's an
|
51 |
else:
|
52 |
return f"📌 **Final Answer:**\n\n```{str(answer)}```"
|
|
|
13 |
# def __init__(self, *args, **kwargs):
|
14 |
# self.is_initialized = False
|
15 |
|
|
|
16 |
from typing import Any
|
17 |
from smolagents.tools import Tool
|
18 |
|
|
|
32 |
|
33 |
# Case 2: If the answer is a list of job listings, format them properly
|
34 |
elif isinstance(answer, list) and all(isinstance(job, dict) for job in answer):
|
35 |
+
formatted_output = "**🔍 Job Listings Found**\n\n"
|
36 |
+
|
37 |
+
if not answer:
|
38 |
+
return "⚠️ No job listings found."
|
39 |
|
40 |
for idx, job in enumerate(answer, start=1):
|
41 |
+
title = job.get("Title", "Unknown Job Title")
|
42 |
+
company = job.get("Company", "Unknown Company")
|
43 |
location = job.get("Location", "Anywhere")
|
44 |
|
45 |
formatted_output += (
|
|
|
49 |
)
|
50 |
return formatted_output
|
51 |
|
52 |
+
# Case 3: If it's an unexpected format, return it as a formatted string
|
53 |
else:
|
54 |
return f"📌 **Final Answer:**\n\n```{str(answer)}```"
|