Spaces:
Running
Running
David Hrachovy
commited on
Commit
·
8257d41
1
Parent(s):
400552c
Update
Browse files
README.md
CHANGED
@@ -44,5 +44,5 @@ A Gradio interface that scrapes and analyzes real estate projects using LangChai
|
|
44 |
|
45 |
5. Upgrade all packages to their latest versions:
|
46 |
```sh
|
47 |
-
uv pip compile - -o requirements.txt
|
48 |
```
|
|
|
44 |
|
45 |
5. Upgrade all packages to their latest versions:
|
46 |
```sh
|
47 |
+
uv pip compile - -o requirements.txt --upgrade
|
48 |
```
|
app.py
CHANGED
@@ -51,7 +51,7 @@ LIMIT 5;
|
|
51 |
|
52 |
# Get the OpenAI tools agent prompt
|
53 |
prompt = ChatPromptTemplate.from_messages([
|
54 |
-
("system", "You are a helpful assistant. You speak Czech. You can answer questions about real estate projects (novostavby) in Czech Republic. You have access to a database of real estate projects (translate output to Czech too). Some info about the structure of the database: " + db_description + "Note that some json values can be null so you must sometimes check
|
55 |
("placeholder", "{chat_history}"),
|
56 |
("human", "{input}"),
|
57 |
("placeholder", "{agent_scratchpad}"),
|
@@ -91,10 +91,11 @@ count_projects = Project.select().where(Project.structure.is_null(False)).count(
|
|
91 |
demo = gr.ChatInterface(
|
92 |
fn=chat_with_sql,
|
93 |
title="Estate Chat",
|
94 |
-
description=f"Zeptej se
|
95 |
examples=[
|
96 |
"Projekt s nejnižším vkladem",
|
97 |
-
"
|
|
|
98 |
],
|
99 |
type="messages"
|
100 |
)
|
|
|
51 |
|
52 |
# Get the OpenAI tools agent prompt
|
53 |
prompt = ChatPromptTemplate.from_messages([
|
54 |
+
("system", "You are a helpful assistant. You speak Czech. You can answer questions about real estate projects (novostavby) in Czech Republic. You have access to a database of real estate projects (translate output to Czech too). Some info about the structure of the database: " + db_description + "Note that some json values can be null so you must sometimes check that is IS NOT NULL. Always query projects with structure->'$.ignore'=false or NULL. For calculating you can adapt this query: " + sql_distance_query),
|
55 |
("placeholder", "{chat_history}"),
|
56 |
("human", "{input}"),
|
57 |
("placeholder", "{agent_scratchpad}"),
|
|
|
91 |
demo = gr.ChatInterface(
|
92 |
fn=chat_with_sql,
|
93 |
title="Estate Chat",
|
94 |
+
description=f"Plánuješ koupit novostavbu? Zeptej se mě na {count_projects} novostaveb v ČR 🇨🇿",
|
95 |
examples=[
|
96 |
"Projekt s nejnižším vkladem",
|
97 |
+
"Nejlevnější byt v Praze",
|
98 |
+
"Nejmenší m2 v Praze"
|
99 |
],
|
100 |
type="messages"
|
101 |
)
|
estate.db
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 2527232
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cf3d4b0ffe9f77b7ebdc2a7b7230299192c969194cca281c91950c8a9fe00ffd
|
3 |
size 2527232
|
init_db.py
CHANGED
@@ -4,7 +4,7 @@ from playhouse.sqlite_ext import *
|
|
4 |
|
5 |
# Initialize database
|
6 |
|
7 |
-
json_structure = "JSON column with hash with keys 'title': str, official title of the project, 'deposit': int, initial deposit (in percentage) for apartments, 'min_price': int, lowest available apartment price with VAT. It should not be booked or sold., 'average_price_per_sqm': int, average price per square meter of the lowest available apartment, 'status': str, status of the project (preparation, selling, sold out), 'city': str, city of the project, 'lat': float, gps coordinates of the project, 'lng': float, gps coordinates of the project, 'start_year': int, year of construction start, 'end_year': int, estimated year of construction end, 'developer': str, name of the contruction company/developer
|
8 |
|
9 |
db = SqliteExtDatabase('estate.db', pragmas=(
|
10 |
('cache_size', -1024 * 64), # 64MB page-cache.
|
@@ -14,7 +14,7 @@ db = SqliteExtDatabase('estate.db', pragmas=(
|
|
14 |
db_description = f"""Table "project" - list of real estate projects (novostavby) in Czech Republic
|
15 |
url: url of the project.
|
16 |
structure: {json_structure}.
|
17 |
-
content: contents of the website.
|
18 |
created_at: date and time of creation.
|
19 |
"""
|
20 |
|
|
|
4 |
|
5 |
# Initialize database
|
6 |
|
7 |
+
json_structure = "JSON column with hash with keys 'title': str, official title of the project, 'deposit': int, initial deposit (in percentage) for apartments, 'min_price': int, lowest available apartment price with VAT. It should not be booked or sold., 'average_price_per_sqm': int, average price per square meter of the lowest available apartment. If they sell house and not apartment, calculate only from the apartment size, not size of garden (land), 'status': str, status of the project (preparation, selling, sold out), 'city': str, city of the project, 'lat': float, gps coordinates of the project, 'lng': float, gps coordinates of the project, 'start_year': int, year of construction start, 'end_year': int, estimated year of construction end, 'developer': str, name of the contruction company/developer, 'ignore': bool, if True, the project does not have any apartments for sale, Some values can be null/unknown"
|
8 |
|
9 |
db = SqliteExtDatabase('estate.db', pragmas=(
|
10 |
('cache_size', -1024 * 64), # 64MB page-cache.
|
|
|
14 |
db_description = f"""Table "project" - list of real estate projects (novostavby) in Czech Republic
|
15 |
url: url of the project.
|
16 |
structure: {json_structure}.
|
17 |
+
content: contents of the website, information about the project.
|
18 |
created_at: date and time of creation.
|
19 |
"""
|
20 |
|