Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,18 +11,17 @@ import requests
|
|
| 11 |
from pydantic import BaseModel, Field, validator
|
| 12 |
|
| 13 |
class PDOKLocationSearchInput(BaseModel):
|
| 14 |
-
"""Input for the PDOK location search tool."""
|
| 15 |
postal_code: Optional[str] = Field(None, description="Postal code in the format '1234 AA'.")
|
| 16 |
house_number: Optional[str] = Field(None, description="House number.")
|
| 17 |
street_name: Optional[str] = Field(None, description="Street name.")
|
| 18 |
city: Optional[str] = Field(None, description="City name.")
|
| 19 |
|
| 20 |
-
@
|
| 21 |
def validate_postal_code(cls, v):
|
| 22 |
if v is not None and (len(v) != 7 or not v[0:4].isdigit() or v[4] != " " or not v[5:7].isalpha()):
|
| 23 |
raise ValueError("Invalid postal code format. It must be '1234 AA'.")
|
| 24 |
return v
|
| 25 |
-
|
| 26 |
def construct_query(self) -> str:
|
| 27 |
"""Constructs the query string based on provided inputs."""
|
| 28 |
if self.postal_code and self.house_number:
|
|
@@ -160,7 +159,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 160 |
|
| 161 |
agent = CodeAgent(
|
| 162 |
model=model,
|
| 163 |
-
tools=[final_answer, get_current_time_in_timezone,
|
| 164 |
max_steps=6,
|
| 165 |
verbosity_level=1,
|
| 166 |
grammar=None,
|
|
|
|
| 11 |
from pydantic import BaseModel, Field, validator
|
| 12 |
|
| 13 |
class PDOKLocationSearchInput(BaseModel):
|
|
|
|
| 14 |
postal_code: Optional[str] = Field(None, description="Postal code in the format '1234 AA'.")
|
| 15 |
house_number: Optional[str] = Field(None, description="House number.")
|
| 16 |
street_name: Optional[str] = Field(None, description="Street name.")
|
| 17 |
city: Optional[str] = Field(None, description="City name.")
|
| 18 |
|
| 19 |
+
@field_validator('postal_code')
|
| 20 |
def validate_postal_code(cls, v):
|
| 21 |
if v is not None and (len(v) != 7 or not v[0:4].isdigit() or v[4] != " " or not v[5:7].isalpha()):
|
| 22 |
raise ValueError("Invalid postal code format. It must be '1234 AA'.")
|
| 23 |
return v
|
| 24 |
+
|
| 25 |
def construct_query(self) -> str:
|
| 26 |
"""Constructs the query string based on provided inputs."""
|
| 27 |
if self.postal_code and self.house_number:
|
|
|
|
| 159 |
|
| 160 |
agent = CodeAgent(
|
| 161 |
model=model,
|
| 162 |
+
tools=[final_answer, get_current_time_in_timezone, pdok_location_info], ## add your tools here (don't remove final answer)
|
| 163 |
max_steps=6,
|
| 164 |
verbosity_level=1,
|
| 165 |
grammar=None,
|