Skip to content

Commit

Permalink
explaining properties md
Browse files Browse the repository at this point in the history
  • Loading branch information
JAlcocerT committed Jul 24, 2024
1 parent e7247d1 commit e72d267
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 16 deletions.
15 changes: 9 additions & 6 deletions LLamaIndex-Mem0/Chat_with_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
class RealEstateAssistant:
def __init__(self):
self.client = OpenAI()
self.memory = Memory()
self.messages = [{"role": "system", "content": "You are a Real Estate Agent that will make relevant follow-up questions to the user to provide the best housing option. When you see a match in the given amenities, you can comment on them."}]
self.memory = Memory() #using mem0 here
self.messages = [{"role": "system", "content": "You are a Real Estate Agent that will make \
relevant follow-up questions to the user to provide the best housing option.\
When you see a match in the given amenities, you can comment on them."}]
self.follow_up_count = 0

# Load flat examples from CSV and add to memory
Expand All @@ -27,7 +29,7 @@ def __init__(self):
Settings.embed_model = embed_model
Settings.chunk_size = 512

# Load documents and create the index
# Load documents and create the index (as per the given .md in the folder)
documents = SimpleDirectoryReader("./datamd").load_data()
self.index = VectorStoreIndex.from_documents(documents)

Expand All @@ -39,7 +41,7 @@ def ask_question(self, question, user_id):
prompt = f"User input: {question}\nPrevious memories: {previous_memories}"
self.messages.append({"role": "user", "content": prompt})

# Generate response using GPT-4
# Generate response using GPT-4 (OpenAI)
response = self.client.chat.completions.create(
model="gpt-4",
messages=self.messages
Expand Down Expand Up @@ -73,7 +75,8 @@ def query_properties(self, user_id):
self.follow_up_count = 0 # Reset follow-up count after query
return response

# Usage example
### Usage example

user_id = "user_123"
ai_assistant = RealEstateAssistant()

Expand All @@ -96,4 +99,4 @@ def main():
print(f"Properties Query Response: {answer}")

if __name__ == "__main__":
main()
main()
11 changes: 5 additions & 6 deletions LLamaIndex-Mem0/Docker-Compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ version: '3.8'

services:
testing_service:
image: langchain_mem0
container_name: langchain_mem0
image: properties_chat
container_name: Chat_with_Properties
ports:
- "8009:8000"
#command: streamlit run app.py
command: tail -f /dev/null
command: tail -f /dev/null ##command: streamlit run app.py
environment:
- OPENAI_API_KEY=sk-proj-yourapi
- ANTHROPIC_API_KEY=sk-ant-api03-yourapi

#docker exec -it langchain_mem0 /bin/bash
#podman exec -it langchain_mem0 /bin/bash
#docker exec -it properties_chat /bin/bash
#podman exec -it properties_chat /bin/bash
5 changes: 4 additions & 1 deletion LLamaIndex-Mem0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ EXPOSE 8000
#CMD ["streamlit", "run", "app.py"]

# docker build -t langchain_mem0 .
# podman build -t langchain_mem0 .
# podman build -t langchain_mem0 .

# docker build -t properties_chat .
# podman build -t properties_chat .
160 changes: 159 additions & 1 deletion LLamaIndex-Mem0/datamd/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,162 @@
- Parking: Detached 1-car garage and driveway 🚗
- Amenities:
- Outdoor patio with a fire pit 🔥
- Bright
- Bright

7. **Beachfront Villa in Malibu** 🌊
- Location: Malibu, California, USA 🇺🇸
- Price: $8,000,000 💰
- Rooms: 5 bedrooms, 6 bathrooms 🛏️🛁
- Parking: 3-car garage 🚗
- Amenities:
- Private beach access 🏖️
- Infinity pool overlooking the ocean 🏊‍♂️
- Home theater and wine cellar 🎥🍷
- Spacious outdoor deck for entertaining 🌅
- Perfect for: Celebrities and luxury seekers wanting exclusive oceanfront living 🌟

8. **Historic Townhouse in Paris** 🥖
- Location: Le Marais, Paris, France 🇫🇷
- Price: €3,500,000 💶
- Rooms: 4 bedrooms, 3 bathrooms 🛏️🛁
- Parking: Underground parking available 🚗
- Amenities:
- Original architectural details and high ceilings 🏛️
- Private courtyard garden 🌳
- Modern kitchen with top-of-the-line appliances 🍽️
- Proximity to iconic landmarks and cultural sites 🏰
- Perfect for: Art enthusiasts and history lovers seeking Parisian charm 🎨

9. **Mountain Chalet in the Swiss Alps** 🏔️
- Location: Zermatt, Switzerland 🇨🇭
- Price: CHF 4,500,000 💵
- Rooms: 6 bedrooms, 7 bathrooms 🛏️🛁
- Parking: Heated garage 🚗
- Amenities:
- Ski-in/ski-out access 🎿
- Indoor pool and sauna 🏊‍♂️🧖‍♂️
- Panoramic views of the Matterhorn 🏞️
- Fireplace and rustic wood interiors 🔥
- Perfect for: Winter sports enthusiasts and luxury vacationers ❄️

10. **Tropical Estate in Bali** 🌴
- Location: Ubud, Bali, Indonesia 🇮🇩
- Price: $1,200,000 💰
- Rooms: 4 bedrooms, 5 bathrooms 🛏️🛁
- Parking: Private driveway 🚗
- Amenities:
- Lush gardens and rice field views 🌾
- Private infinity pool 🏊‍♂️
- Open-air living and dining areas 🌞
- Traditional Balinese architecture and design 🏡
- Perfect for: Expats and vacation home buyers seeking tranquility and culture 🌺

11. **Eco-Friendly Home in Sydney** 🌿
- Location: Bondi Beach, Sydney, Australia 🇦🇺
- Price: AUD 3,000,000 💵
- Rooms: 3 bedrooms, 2 bathrooms 🛏️🛁
- Parking: 2-car garage 🚗
- Amenities:
- Solar panels and rainwater harvesting systems 🌞💧
- Sustainable materials and design ♻️
- Rooftop garden and outdoor entertaining space 🌳
- Walking distance to Bondi Beach 🌊
- Perfect for: Environmentally conscious buyers and beach lovers 🌱

12. **Luxury Condo in Dubai** 🏙️
- Location: Downtown Dubai, UAE 🇦🇪
- Price: AED 6,000,000 💵
- Rooms: 3 bedrooms, 4 bathrooms 🛏️🛁
- Parking: 2 underground parking spaces 🚗
- Amenities:
- Panoramic views of the Burj Khalifa 🌟
- High-end fitness center and spa 🧘‍♀️
- Private elevator access 🛗
- Smart home technology throughout 🏠
- Perfect for: High-net-worth individuals seeking a lavish urban lifestyle 🏢

13. **Rustic Farmhouse in Tuscany** 🍇
- Location: Chianti, Tuscany, Italy 🇮🇹
- Price: €1,800,000 💶
- Rooms: 5 bedrooms, 4 bathrooms 🛏️🛁
- Parking: Ample outdoor parking 🚗
- Amenities:
- Vineyard and olive grove 🍷🍈
- Swimming pool with countryside views 🏊‍♂️
- Traditional wood-beam ceilings and terracotta floors 🏡
- Proximity to charming Tuscan villages and wineries 🍇
- Perfect for: Wine enthusiasts and those seeking a serene country life 🍷

14. **Modern Loft in Tokyo** 🏢
- Location: Shibuya, Tokyo, Japan 🇯🇵
- Price: ¥150,000,000 💴
- Rooms: 2 bedrooms, 2 bathrooms 🛏️🛁
- Parking: Underground parking available 🚗
- Amenities:
- Open-plan living and dining areas 🍽️
- Floor-to-ceiling windows with city views 🌇
- High-tech security and smart home features 🏠
- Close to trendy shops, restaurants, and nightlife 🛍️🍣
- Perfect for: Young professionals and creatives seeking a vibrant city lifestyle 🌃

15. **Cozy Cabin in the Canadian Rockies** 🏞️
- Location: Banff, Alberta, Canada 🇨🇦
- Price: CAD 950,000 💵
- Rooms: 3 bedrooms, 2 bathrooms 🛏️🛁
- Parking: Detached garage and driveway 🚗
- Amenities:
- Wood-burning stove and rustic interiors 🔥
- Large deck with mountain views 🌄
- Proximity to hiking trails and ski resorts 🥾🎿
- Quiet and secluded location 🌲
- Perfect for: Nature lovers and outdoor enthusiasts seeking a mountain retreat 🏔️

### Properties in Poland and Portugal

16. **Charming Mountain Cabin in Zakopane** 🏞️
- Location: Zakopane, Poland 🇵🇱
- Price: PLN 800,000 💵
- Rooms: 3 bedrooms, 2 bathrooms 🛏️🛁
- Parking: 1-car garage and driveway 🚗
- Amenities:
- Traditional wooden architecture 🏡
- Cozy fireplace and rustic interiors 🔥
- Large terrace with mountain views 🌄
- Proximity to Tatra National Park and ski slopes 🎿
- Perfect for: Families and outdoor enthusiasts seeking a serene mountain getaway 🌲

17. **Affordable Retreat in the Bieszczady Mountains** 🏔️
- Location: Bieszczady, Poland 🇵🇱
- Price: PLN 450,000 💵
- Rooms: 2 bedrooms, 1 bathroom 🛏️🛁
- Parking: Outdoor parking space 🚗
- Amenities:
- Wood-burning stove and cozy interiors 🔥
- Surrounded by lush forests and nature trails 🌳
- Outdoor seating area and garden 🌸
- Quiet and secluded location 🌲
- Perfect for: Nature lovers and those seeking a peaceful retreat 🌿

18. **Rustic Cottage in the Serra da Estrela** 🌄
- Location: Serra da Estrela, Portugal 🇵🇹
- Price: €120,000 💶
- Rooms: 2 bedrooms, 1 bathroom 🛏️🛁
- Parking: Private driveway 🚗
- Amenities:
- Stone fireplace and traditional decor 🔥
- Scenic views of the mountains and valleys 🌄
- Proximity to hiking trails and natural parks 🥾
- Charming village setting with local amenities 🏡
- Perfect for: Hikers and nature enthusiasts seeking an affordable mountain home 🌲

19. **Budget-Friendly House in the Peneda-Gerês National Park** 🌳
- Location: Peneda-Gerês, Portugal 🇵🇹
- Price: €100,000 💶
- Rooms: 3 bedrooms, 1 bathroom 🛏️🛁
- Parking: Street parking available 🚗
- Amenities:
- Rustic interiors with wooden beams 🌲
- Garden and outdoor seating area 🌿
- Proximity to lakes, waterfalls, and trails 🏞️
- Located in a charming mountain village 🏘️
- Perfect for: Families and adventurers looking for an affordable nature retreat 🏞️
14 changes: 12 additions & 2 deletions LLamaIndex-Mem0/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,15 @@
</a>
</div>

* https://www.anthropic.com/api
* https://platform.openai.com/
* API's needed:
* https://www.anthropic.com/api
* https://platform.openai.com/

## Chat_with_md

* The **Anthropic model** isn't used directly for generating responses to user questions, it is used indirectly through the `Llama Index` for finding **relevant property documents** based on the user's previous questions.
* [llama_index.llms.anthropic](https://docs.llamaindex.ai/en/stable/examples/llm/anthropic/)

* The **responses** to the user's questions are generated by the **OpenAI's GPT-4 model**.
* The `ask_question` method, the OpenAI client is used to create a chat completion with the GPT-4 model. The current conversation history (self.messages) is passed to the model, which generates a response. The response is then added to the conversation history.
* https://platform.openai.com/docs/api-reference/introduction

0 comments on commit e72d267

Please sign in to comment.