xg220 commited on
Commit
a5fe1f8
·
verified ·
1 Parent(s): 5973b48

Update app.py

Browse files

added fnol tool

Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
 
3
  import requests
4
  import pytz
5
  import yaml
@@ -41,6 +42,39 @@ def get_current_time_in_timezone(timezone: str) -> str:
41
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
42
 
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  final_answer = FinalAnswerTool()
45
 
46
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
@@ -65,6 +99,7 @@ agent = CodeAgent(
65
  tools=[
66
  final_answer,
67
  image_generation_tool,
 
68
  get_current_time_in_timezone, # even though it's decorated
69
  random_normal_draws # same here
70
  ],
 
1
  from smolagents import CodeAgent,DuckDuckGoSearchTool, HfApiModel,load_tool,tool
2
  import datetime
3
+ import re
4
  import requests
5
  import pytz
6
  import yaml
 
42
  return f"Error fetching time for timezone '{timezone}': {str(e)}"
43
 
44
 
45
+ @tool
46
+ def extract_fnol_info(email_text: str) -> str:
47
+ """Extracts FNOL details (car make, injury type, date of incident) from a natural-language claim email.
48
+
49
+ Args:
50
+ email_text: The body of the claim email.
51
+
52
+ Returns:
53
+ A structured summary with the car make, injury type, and date of incident, or 'missing' if not found.
54
+ """
55
+ prompt = f"""
56
+ You are an assistant extracting First Notification of Loss (FNOL) information from an email.
57
+ Extract the following from the email below:
58
+
59
+ - Car make and model
60
+ - Date of incident (in YYYY-MM-DD format if possible)
61
+ - Injury type
62
+
63
+ If any information is missing, say 'Missing'.
64
+
65
+ Email:
66
+ \"\"\"
67
+ {email_text}
68
+ \"\"\"
69
+
70
+ Return in this format:
71
+ Car: <car>
72
+ Date: <date>
73
+ Injury: <injury>
74
+ """
75
+ return prompt
76
+
77
+
78
  final_answer = FinalAnswerTool()
79
 
80
  # If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
 
99
  tools=[
100
  final_answer,
101
  image_generation_tool,
102
+ extract_fnol_info,
103
  get_current_time_in_timezone, # even though it's decorated
104
  random_normal_draws # same here
105
  ],