Spaces:
Sleeping
Sleeping
Commit
·
0b0ca02
1
Parent(s):
43151a4
Add Damascus Real Estate Falcon 7B test
Browse files- README.md +48 -6
- app.py +301 -0
- requirements.txt +8 -0
README.md
CHANGED
|
@@ -1,12 +1,54 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Damascus Real Estate Chatbot
|
| 3 |
+
emoji: 🏠
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.0.2
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Damascus Real Estate Chatbot - Falcon 7B Test
|
| 14 |
+
|
| 15 |
+
Testing Falcon 7B Instruct for Syrian Arabic real estate queries on Hugging Face Spaces.
|
| 16 |
+
|
| 17 |
+
## Overview
|
| 18 |
+
|
| 19 |
+
This is a test deployment of the Damascus Real Estate Chatbot using:
|
| 20 |
+
- **Falcon 7B Instruct** for Arabic language understanding
|
| 21 |
+
- **Syrian Arabic dialect** for natural conversation
|
| 22 |
+
- **20 Damascus property listings** for real estate matching
|
| 23 |
+
- **Entity extraction** for user requirements
|
| 24 |
+
- **Gradio interface** for easy testing
|
| 25 |
+
|
| 26 |
+
## Features
|
| 27 |
+
|
| 28 |
+
- 🤖 **Falcon 7B Instruct** - Advanced Arabic language model
|
| 29 |
+
- 🏠 **Real Estate Matching** - Finds properties based on user requirements
|
| 30 |
+
- 💬 **Syrian Dialect** - Natural Damascus conversational style
|
| 31 |
+
- 📋 **Entity Extraction** - Understands location, rooms, features
|
| 32 |
+
- 🔍 **Smart Filtering** - Matches properties to user criteria
|
| 33 |
+
|
| 34 |
+
## Usage
|
| 35 |
+
|
| 36 |
+
Ask questions in Syrian Arabic like:
|
| 37 |
+
- "بدي شقة مفروشة بالمالكي مع شرفة"
|
| 38 |
+
- "في شي ستوديو باب شرقي مفروش؟"
|
| 39 |
+
- "شو عندك بالشعلان رخيص؟"
|
| 40 |
+
|
| 41 |
+
## Next Steps
|
| 42 |
+
|
| 43 |
+
After testing on Hugging Face Spaces, this will be deployed to:
|
| 44 |
+
- **AWS EC2 G4 instances** for production
|
| 45 |
+
- **vLLM integration** for parallel inference
|
| 46 |
+
- **ChromaDB RAG** for semantic search
|
| 47 |
+
- **Performance optimization** for real-world usage
|
| 48 |
+
|
| 49 |
+
## Technical Details
|
| 50 |
+
|
| 51 |
+
- **Model**: tiiuae/falcon-7b-instruct
|
| 52 |
+
- **Framework**: Transformers + Gradio
|
| 53 |
+
- **Languages**: Syrian Arabic, some English for interface
|
| 54 |
+
- **Data**: 20 Damascus property listings
|
app.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Falcon 7B Damascus Real Estate Chatbot - Hugging Face Test
|
| 3 |
+
==========================================================
|
| 4 |
+
|
| 5 |
+
Testing Falcon 7B Instruct on Hugging Face Spaces for Syrian Arabic real estate queries.
|
| 6 |
+
This is the base test before deploying to AWS EC2 G4.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import gradio as gr
|
| 10 |
+
import torch
|
| 11 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 12 |
+
import re
|
| 13 |
+
import json
|
| 14 |
+
from typing import List, Dict, Any
|
| 15 |
+
|
| 16 |
+
# Configuration
|
| 17 |
+
MODEL_NAME = "tiiuae/falcon-7b-instruct"
|
| 18 |
+
MAX_LENGTH = 500
|
| 19 |
+
TEMPERATURE = 0.7
|
| 20 |
+
|
| 21 |
+
print("🚀 Loading Falcon 7B for Damascus Real Estate...")
|
| 22 |
+
|
| 23 |
+
# Load model and tokenizer
|
| 24 |
+
try:
|
| 25 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
|
| 26 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 27 |
+
MODEL_NAME,
|
| 28 |
+
torch_dtype=torch.float16,
|
| 29 |
+
device_map="auto",
|
| 30 |
+
trust_remote_code=True
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
generator = pipeline(
|
| 34 |
+
"text-generation",
|
| 35 |
+
model=model,
|
| 36 |
+
tokenizer=tokenizer,
|
| 37 |
+
torch_dtype=torch.float16,
|
| 38 |
+
device=0 if torch.cuda.is_available() else -1
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
print("✅ Falcon 7B loaded successfully")
|
| 42 |
+
model_loaded = True
|
| 43 |
+
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f"❌ Model loading failed: {e}")
|
| 46 |
+
generator = None
|
| 47 |
+
model_loaded = False
|
| 48 |
+
|
| 49 |
+
# Damascus property listings (from Project_Description.txt)
|
| 50 |
+
DAMASCUS_LISTINGS = [
|
| 51 |
+
"1. مفروشة بالكامل، غرفتين وصالون، المالكي، طابق ثالث، شرفة واسعة، غسالة صحون، مليون وثمانمائة ألف ليرة بالشهر.",
|
| 52 |
+
"2. ستوديو مفروش، باب شرقي، طابق أول، شرفة صغيرة، مكيف، ثمانمائة ألف ليرة بالشهر.",
|
| 53 |
+
"3. شقة فارغة، ثلاث غرف، المزة، طابق ثاني، شرفة كبيرة، موقف سيارة، مليونين وخمسمائة ألف ليرة بالشهر.",
|
| 54 |
+
"4. مفروشة، غرفة وصالون، الشعلان، طابق رابع، مكيفات، غسالة ملابس، مليون ومائتا ألف ليرة بالشهر.",
|
| 55 |
+
"5. دوبلكس فاخر، أربع غرف، أبو رمانة، طابقين، تراس كبير، مصعد، خمسة ملايين ليرة بالشهر.",
|
| 56 |
+
"6. ستوديو فارغ، القصاع، طابق أرضي، بدون شرفة، خمسمائة ألف ليرة بالشهر.",
|
| 57 |
+
"7. مفروشة جزئياً، غرفتين، الجرمانا، طابق ثالث، شرفة متوسطة، غسالة صحون، مليون وأربعمائة ألف ليرة بالشهر.",
|
| 58 |
+
"8. شقة فارغة، غرفة وصالون، باب توما، طابق ثاني، شرفة صغيرة، تسعمائة ألف ليرة بالشهر.",
|
| 59 |
+
"9. مفروشة بالكامل، ثلاث غرف، المالكي، طابق أول، شرفتين، مكيفات، موقف سيارة، ثلاثة ملايين ليرة بالشهر.",
|
| 60 |
+
"10. ستوديو مفروش، الشعلان، طابق خامس، شرفة واسعة، مكيف، فرن كهربائي، مليون ليرة بالشهر."
|
| 61 |
+
]
|
| 62 |
+
|
| 63 |
+
def create_falcon_prompt(user_query: str, listings: List[str]) -> str:
|
| 64 |
+
"""Create a prompt for Falcon 7B to respond in Syrian Arabic"""
|
| 65 |
+
|
| 66 |
+
listings_text = "\n".join(listings)
|
| 67 |
+
|
| 68 |
+
prompt = f"""You are a real estate agent in Damascus, Syria. You help people find apartments.
|
| 69 |
+
|
| 70 |
+
Available Properties:
|
| 71 |
+
{listings_text}
|
| 72 |
+
|
| 73 |
+
User Query: "{user_query}"
|
| 74 |
+
|
| 75 |
+
Instructions:
|
| 76 |
+
1. Respond ONLY in Syrian Arabic (Damascus dialect)
|
| 77 |
+
2. Only mention properties from the Available Properties list above
|
| 78 |
+
3. If no suitable properties exist, say "عذراً، ما في عندي شقة بهاي المواصفات حالياً"
|
| 79 |
+
4. Be natural and conversational
|
| 80 |
+
5. Recommend the best matching properties
|
| 81 |
+
|
| 82 |
+
Response:"""
|
| 83 |
+
|
| 84 |
+
return prompt
|
| 85 |
+
|
| 86 |
+
def extract_entities_basic(query: str) -> Dict[str, Any]:
|
| 87 |
+
"""Extract basic entities from Syrian Arabic query"""
|
| 88 |
+
entities = {
|
| 89 |
+
'location': None,
|
| 90 |
+
'furnished': None,
|
| 91 |
+
'rooms': None,
|
| 92 |
+
'features': [],
|
| 93 |
+
'price_pref': None
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
query_lower = query.lower()
|
| 97 |
+
|
| 98 |
+
# Location extraction
|
| 99 |
+
locations = ['المالكي', 'باب شرقي', 'المزة', 'الشعلان', 'أبو رمانة', 'القصاع', 'الجرمانا', 'باب توما']
|
| 100 |
+
for loc in locations:
|
| 101 |
+
if loc in query_lower:
|
| 102 |
+
entities['location'] = loc
|
| 103 |
+
break
|
| 104 |
+
|
| 105 |
+
# Furnished status
|
| 106 |
+
if 'مفروش' in query_lower:
|
| 107 |
+
entities['furnished'] = 'furnished'
|
| 108 |
+
elif 'فارغ' in query_lower:
|
| 109 |
+
entities['furnished'] = 'unfurnished'
|
| 110 |
+
|
| 111 |
+
# Room count
|
| 112 |
+
if 'ستوديو' in query_lower:
|
| 113 |
+
entities['rooms'] = 'studio'
|
| 114 |
+
elif 'غرفتين' in query_lower:
|
| 115 |
+
entities['rooms'] = '2_rooms'
|
| 116 |
+
elif 'ثلاث غرف' in query_lower:
|
| 117 |
+
entities['rooms'] = '3_rooms'
|
| 118 |
+
|
| 119 |
+
# Features
|
| 120 |
+
if 'شرفة' in query_lower:
|
| 121 |
+
entities['features'].append('balcony')
|
| 122 |
+
if 'موقف' in query_lower:
|
| 123 |
+
entities['features'].append('parking')
|
| 124 |
+
if 'مكيف' in query_lower:
|
| 125 |
+
entities['features'].append('ac')
|
| 126 |
+
|
| 127 |
+
# Price preference
|
| 128 |
+
if 'رخيص' in query_lower:
|
| 129 |
+
entities['price_pref'] = 'cheap'
|
| 130 |
+
elif 'فاخر' in query_lower:
|
| 131 |
+
entities['price_pref'] = 'luxury'
|
| 132 |
+
|
| 133 |
+
return entities
|
| 134 |
+
|
| 135 |
+
def filter_listings_by_entities(listings: List[str], entities: Dict[str, Any]) -> List[str]:
|
| 136 |
+
"""Filter listings based on extracted entities"""
|
| 137 |
+
filtered = []
|
| 138 |
+
|
| 139 |
+
for listing in listings:
|
| 140 |
+
listing_lower = listing.lower()
|
| 141 |
+
matches = True
|
| 142 |
+
|
| 143 |
+
# Location filter
|
| 144 |
+
if entities.get('location'):
|
| 145 |
+
if entities['location'] not in listing_lower:
|
| 146 |
+
matches = False
|
| 147 |
+
|
| 148 |
+
# Furnished filter
|
| 149 |
+
if entities.get('furnished'):
|
| 150 |
+
if entities['furnished'] == 'furnished' and 'مفروش' not in listing_lower:
|
| 151 |
+
matches = False
|
| 152 |
+
elif entities['furnished'] == 'unfurnished' and 'فارغ' not in listing_lower:
|
| 153 |
+
matches = False
|
| 154 |
+
|
| 155 |
+
# Room filter
|
| 156 |
+
if entities.get('rooms'):
|
| 157 |
+
if entities['rooms'] == 'studio' and 'ستوديو' not in listing_lower:
|
| 158 |
+
matches = False
|
| 159 |
+
elif entities['rooms'] == '2_rooms' and 'غرفتين' not in listing_lower:
|
| 160 |
+
matches = False
|
| 161 |
+
elif entities['rooms'] == '3_rooms' and 'ثلاث غرف' not in listing_lower:
|
| 162 |
+
matches = False
|
| 163 |
+
|
| 164 |
+
# Feature filters
|
| 165 |
+
for feature in entities.get('features', []):
|
| 166 |
+
if feature == 'balcony' and 'شرفة' not in listing_lower:
|
| 167 |
+
matches = False
|
| 168 |
+
elif feature == 'parking' and 'موقف' not in listing_lower:
|
| 169 |
+
matches = False
|
| 170 |
+
elif feature == 'ac' and 'مكيف' not in listing_lower:
|
| 171 |
+
matches = False
|
| 172 |
+
|
| 173 |
+
if matches:
|
| 174 |
+
filtered.append(listing)
|
| 175 |
+
|
| 176 |
+
return filtered[:5] # Return top 5 matches
|
| 177 |
+
|
| 178 |
+
def generate_response(user_query: str) -> tuple:
|
| 179 |
+
"""Generate response using Falcon 7B"""
|
| 180 |
+
|
| 181 |
+
if not model_loaded:
|
| 182 |
+
return "❌ Model not loaded. Please check the setup.", "{}", "[]"
|
| 183 |
+
|
| 184 |
+
try:
|
| 185 |
+
# Extract entities
|
| 186 |
+
entities = extract_entities_basic(user_query)
|
| 187 |
+
|
| 188 |
+
# Filter listings
|
| 189 |
+
relevant_listings = filter_listings_by_entities(DAMASCUS_LISTINGS, entities)
|
| 190 |
+
|
| 191 |
+
# Create prompt
|
| 192 |
+
prompt = create_falcon_prompt(user_query, relevant_listings if relevant_listings else DAMASCUS_LISTINGS[:3])
|
| 193 |
+
|
| 194 |
+
# Generate with Falcon
|
| 195 |
+
response = generator(
|
| 196 |
+
prompt,
|
| 197 |
+
max_length=len(prompt) + MAX_LENGTH,
|
| 198 |
+
temperature=TEMPERATURE,
|
| 199 |
+
do_sample=True,
|
| 200 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 201 |
+
num_return_sequences=1
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
# Extract generated text
|
| 205 |
+
full_response = response[0]['generated_text']
|
| 206 |
+
generated_part = full_response[len(prompt):].strip()
|
| 207 |
+
|
| 208 |
+
# Clean up response
|
| 209 |
+
if generated_part:
|
| 210 |
+
# Remove any potential English or unwanted text
|
| 211 |
+
lines = generated_part.split('\n')
|
| 212 |
+
arabic_lines = []
|
| 213 |
+
for line in lines:
|
| 214 |
+
if line.strip() and any('\u0600' <= c <= '\u06FF' for c in line):
|
| 215 |
+
arabic_lines.append(line.strip())
|
| 216 |
+
elif line.strip() and not any(c.isalpha() for c in line):
|
| 217 |
+
arabic_lines.append(line.strip()) # Keep Arabic numerals/punctuation
|
| 218 |
+
|
| 219 |
+
final_response = '\n'.join(arabic_lines[:5]) # Limit response length
|
| 220 |
+
|
| 221 |
+
if not final_response:
|
| 222 |
+
final_response = "عذراً، صار في مشكلة بالنظام. جرب مرة تانية."
|
| 223 |
+
else:
|
| 224 |
+
final_response = "عذراً، ما قدرت أفهم طلبك. ممكن تعيد صياغته؟"
|
| 225 |
+
|
| 226 |
+
return final_response, json.dumps(entities, ensure_ascii=False), json.dumps(relevant_listings, ensure_ascii=False)
|
| 227 |
+
|
| 228 |
+
except Exception as e:
|
| 229 |
+
return f"❌ Error: {str(e)}", "{}", "[]"
|
| 230 |
+
|
| 231 |
+
# Gradio interface
|
| 232 |
+
def chatbot_interface(message: str) -> tuple:
|
| 233 |
+
"""Gradio interface function"""
|
| 234 |
+
response, entities, listings = generate_response(message)
|
| 235 |
+
return response, entities, listings
|
| 236 |
+
|
| 237 |
+
# Create Gradio app
|
| 238 |
+
with gr.Blocks(title="Damascus Real Estate - Falcon 7B") as demo:
|
| 239 |
+
gr.Markdown("# 🏠 Damascus Real Estate Chatbot")
|
| 240 |
+
gr.Markdown("### Powered by Falcon 7B Instruct - Syrian Arabic Dialect")
|
| 241 |
+
gr.Markdown("Ask about apartments in Damascus in Arabic!")
|
| 242 |
+
|
| 243 |
+
with gr.Row():
|
| 244 |
+
with gr.Column(scale=2):
|
| 245 |
+
user_input = gr.Textbox(
|
| 246 |
+
label="سؤالك بالعربي (Your Question in Arabic)",
|
| 247 |
+
placeholder="مثال: بدي شقة مفروشة بالمالكي مع شرفة",
|
| 248 |
+
lines=2
|
| 249 |
+
)
|
| 250 |
+
submit_btn = gr.Button("🔍 ابحث (Search)", variant="primary")
|
| 251 |
+
|
| 252 |
+
with gr.Column(scale=3):
|
| 253 |
+
chatbot_response = gr.Textbook(
|
| 254 |
+
label="🤖 رد الوكيل العقاري (Real Estate Agent Response)",
|
| 255 |
+
lines=6
|
| 256 |
+
)
|
| 257 |
+
|
| 258 |
+
with gr.Row():
|
| 259 |
+
with gr.Column():
|
| 260 |
+
extracted_entities = gr.Textbox(
|
| 261 |
+
label="📋 المتطلبات المستخرجة (Extracted Requirements)",
|
| 262 |
+
lines=3
|
| 263 |
+
)
|
| 264 |
+
with gr.Column():
|
| 265 |
+
matched_listings = gr.Textbox(
|
| 266 |
+
label="🏠 الشقق المطابقة (Matched Properties)",
|
| 267 |
+
lines=3
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
# Example queries
|
| 271 |
+
gr.Markdown("### أمثلة (Examples):")
|
| 272 |
+
examples = [
|
| 273 |
+
"بدي شقة مفروشة بالمالكي مع شرفة واسعة",
|
| 274 |
+
"في شي ستوديو باب شرقي مفروش؟",
|
| 275 |
+
"بدي شقة ثلاث غرف فارغة بالمزة",
|
| 276 |
+
"شو عندك بالشعلان مفروش؟",
|
| 277 |
+
"بدي شقة رخيصة مع مكيف"
|
| 278 |
+
]
|
| 279 |
+
|
| 280 |
+
for example in examples:
|
| 281 |
+
gr.Button(example).click(
|
| 282 |
+
lambda x=example: x,
|
| 283 |
+
outputs=user_input
|
| 284 |
+
)
|
| 285 |
+
|
| 286 |
+
# Event handlers
|
| 287 |
+
submit_btn.click(
|
| 288 |
+
chatbot_interface,
|
| 289 |
+
inputs=user_input,
|
| 290 |
+
outputs=[chatbot_response, extracted_entities, matched_listings]
|
| 291 |
+
)
|
| 292 |
+
|
| 293 |
+
user_input.submit(
|
| 294 |
+
chatbot_interface,
|
| 295 |
+
inputs=user_input,
|
| 296 |
+
outputs=[chatbot_response, extracted_entities, matched_listings]
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
# Launch the app
|
| 300 |
+
if __name__ == "__main__":
|
| 301 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
torch
|
| 2 |
+
torchvision
|
| 3 |
+
torchaudio
|
| 4 |
+
transformers==4.31.0
|
| 5 |
+
gradio
|
| 6 |
+
accelerate
|
| 7 |
+
einops
|
| 8 |
+
xformers
|