Lurosm commited on
Commit
9c26a51
·
verified ·
1 Parent(s): 8eb81a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -47,8 +47,8 @@ class PDOKLocationInfo(BaseModel):
47
  centroide_rd: str
48
 
49
  @tool
50
- def pdok_location_info(postal_code: Optional[str] = None, house_number: Optional[str] = None, street_name: Optional[str] = None, city: Optional[str] = None) -> Union[PDOKLocationInfo, str]:
51
- """Provides information about a Dutch address or postal code. The combinations of postalcode and housenumber are vallid input or streetname, housenumber and city. Don't attempt to fill fields if you missing input, ask the user.
52
 
53
  Args:
54
  postal_code: Postal code in the format '1234 AA'.
@@ -57,8 +57,7 @@ def pdok_location_info(postal_code: Optional[str] = None, house_number: Optional
57
  city: Name of the city.
58
 
59
  Returns:
60
- Union[PDOKLocationInfo, str]: Either a PDOKLocationInfo object containing the location information,
61
- or a string containing error and debug information if something goes wrong.
62
  """
63
 
64
  debug_info = []
@@ -116,13 +115,15 @@ def pdok_location_info(postal_code: Optional[str] = None, house_number: Optional
116
 
117
  first_result = docs[0]
118
  location_info = PDOKLocationInfo(**first_result)
119
- return location_info
 
120
 
121
  except requests.exceptions.RequestException as e:
122
  return f"Error during API request: {e}\nDebug info:\n" + "\n".join(debug_info)
123
  except (ValueError, KeyError) as e:
124
  return f"Error processing API response: {e}\nDebug info:\n" + "\n".join(debug_info)
125
 
 
126
  @tool
127
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
128
  #Keep this format for the description / args / args description but feel free to modify the tool
 
47
  centroide_rd: str
48
 
49
  @tool
50
+ def pdok_location_info(postal_code: Optional[str] = None, house_number: Optional[str] = None, street_name: Optional[str] = None, city: Optional[str] = None) -> str:
51
+ """Provides information about a Dutch address or postal code.
52
 
53
  Args:
54
  postal_code: Postal code in the format '1234 AA'.
 
57
  city: Name of the city.
58
 
59
  Returns:
60
+ str: JSON string containing the location information or error message with debug info.
 
61
  """
62
 
63
  debug_info = []
 
115
 
116
  first_result = docs[0]
117
  location_info = PDOKLocationInfo(**first_result)
118
+ # Convert the PDOKLocationInfo object to a JSON string
119
+ return location_info.model_dump_json()
120
 
121
  except requests.exceptions.RequestException as e:
122
  return f"Error during API request: {e}\nDebug info:\n" + "\n".join(debug_info)
123
  except (ValueError, KeyError) as e:
124
  return f"Error processing API response: {e}\nDebug info:\n" + "\n".join(debug_info)
125
 
126
+
127
  @tool
128
  def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
129
  #Keep this format for the description / args / args description but feel free to modify the tool