Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
ANTHROPIC_API_KEY=...
TAVILY_API_KEY=...
OPENAI_API_KEY=...
Binary file added my_agent/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
23 changes: 22 additions & 1 deletion my_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Define the config
class GraphConfig(TypedDict):
model_name: Literal["anthropic", "openai"]
model_name: Literal[ "openai"]


# Define a new graph
Expand Down Expand Up @@ -50,3 +50,24 @@ class GraphConfig(TypedDict):
# This compiles it into a LangChain Runnable,
# meaning you can use it as you would any other runnable
graph = workflow.compile()

# def stream_graph_updates(user_input: str):
# for event in graph.stream({"messages": [("user", user_input)]}):
# for value in event.values():
# print(value)
# print("Assistant:", value["messages"][-1].content)

# while True:
# try:
# user_input = input("User: ")
# if user_input.lower() in ["quit", "exit", "q"]:
# print("Goodbye!")
# break

# stream_graph_updates(user_input)
# except:
# # fallback if input() is not available
# user_input = "What do you know about LangGraph?"
# print("User: " + user_input)
# stream_graph_updates(user_input)
# break
Binary file added my_agent/utils/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added my_agent/utils/__pycache__/nodes.cpython-312.pyc
Binary file not shown.
Binary file added my_agent/utils/__pycache__/state.cpython-312.pyc
Binary file not shown.
Binary file added my_agent/utils/__pycache__/tools.cpython-312.pyc
Binary file not shown.
79 changes: 78 additions & 1 deletion my_agent/utils/tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,80 @@
from langchain_community.tools.tavily_search import TavilySearchResults

tools = [TavilySearchResults(max_results=1)]


import http.client
import json
from typing import List, Optional, Dict
from pydantic import BaseModel, Field
from langchain.tools import tool


class PropertySearchFields(BaseModel):
city: Optional[List[str]] = Field(
None,
description="List of Cities to search properties (e.g., ['Houston', 'Dallas']), CAN NEVER BE A NUMBER",
)
community: Optional[List[str]] = Field(
None,
description="List of Communities to search properties on. {Key Communities: cinco ranch, copperfield, eaglewood, canyon gate at brazon, clear lake city}",
)
zip_code: Optional[str] = Field(
None,
description="Numeric Zip code to search properties by, (e.g., 77027, 77024). Zip codes usually start with '77'.",
)
bedrooms: Optional[Dict[str, int]] = Field(
None,
description="Dictionary with Number of Bedrooms with keys 'min', 'max', or 'equal'",
)
baths: Optional[Dict[str, int]] = Field(
None,
description="Dictionary with Number of Bathrooms with keys 'min', 'max', or 'equal'",
)
price: Optional[Dict[str, int]] = Field(
None,
description="Dictionary with Price of property with keys 'min', 'max', or 'equal'",
)
for_sale: Optional[int] = Field(
1, description="Indicates if the property is on rent"
)

class PropertySearchResultItem(BaseModel):
mlsnum: Optional[str]
address: Optional[str]
price: Optional[float]
beds: int
baths: int
city: str
zipCode: str
sqft: int
#args_schema=PropertySearchFields
class PropertySearchInput(BaseModel):
fields: PropertySearchFields = Field(
..., description="Input fields to search properties"
)
@tool(args_schema=PropertySearchInput)
def search_properties(fields: PropertySearchFields) ->Dict:
"""Search properties based on input filters."""
# Implement your API connection and handling here
# Dummy data for the sake of example
print("1")
properties = [
{"property":
# PropertySearchResultItem(
""" mlsnum="123456",
address="123 Main St",
price=350000.0,
beds=3,
baths=2,
city="Houston",
zipCode="77002",
sqft=1500 """}
# )
]
return properties

# Example use:
# Create an instance of PropertySearchFields with the desired search criteria
# search_criteria = PropertySearchFields(city=["Houston"], max_price=500000)
# properties = search_properties(fields=search_criteria)
tools = [search_properties]