Spaces:
Running
Running
David Hrachovy
commited on
Commit
·
6ed422e
1
Parent(s):
9135c43
Update
Browse files- app.py +4 -4
- estate.db +1 -1
- init_db.py +35 -2
app.py
CHANGED
@@ -51,7 +51,7 @@ LIMIT 5;
|
|
51 |
|
52 |
# Get the OpenAI tools agent prompt
|
53 |
prompt = ChatPromptTemplate.from_messages([
|
54 |
-
("system", f"You are a helpful assistant that presents information about real estate projects in database for investors.
|
55 |
("placeholder", "{chat_history}"),
|
56 |
("human", "{input}"),
|
57 |
("placeholder", "{agent_scratchpad}"),
|
@@ -91,11 +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"Planning to buy a new apartment? Ask me about {count_projects} new
|
95 |
examples=[
|
96 |
-
"Project with the lowest deposit before completion",
|
97 |
"Cheapest apartment in Prague",
|
98 |
-
"
|
|
|
99 |
],
|
100 |
type="messages"
|
101 |
)
|
|
|
51 |
|
52 |
# Get the OpenAI tools agent prompt
|
53 |
prompt = ChatPromptTemplate.from_messages([
|
54 |
+
("system", f"You are a helpful assistant that presents information about real estate projects in database for investors. Use 'IS NOT NULL' when necessary. Do not present SQL or JSON. Use simple language. Do not make up information or hallucinate. If final result rows are empty respond that you could not find records matching criteria. Table structure: {db_description}. This JSON structure info can help you: {json_structure}."),
|
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"Planning to buy a new apartment? Ask me about {count_projects} new constructions (novostavby) in Prague 🇨🇿",
|
95 |
examples=[
|
|
|
96 |
"Cheapest apartment in Prague",
|
97 |
+
"The lowest deposit before completion",
|
98 |
+
"All 2+kk below 8000000 CZK",
|
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 2560000
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:25a3f76ad7a2856560c2de8067c3e677d86fd6bcaa20f9f7c1353def16289b2d
|
3 |
size 2560000
|
init_db.py
CHANGED
@@ -4,19 +4,52 @@ from playhouse.sqlite_ext import *
|
|
4 |
|
5 |
# Initialize database
|
6 |
|
7 |
-
json_structure = "JSON column with hash with keys
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
db = SqliteExtDatabase('estate.db')
|
10 |
|
11 |
db_description = f"""Table "project" - list of real estate projects (novostavby) in Czech Republic
|
12 |
url: url of the project.
|
13 |
structure: {json_structure}.
|
14 |
content: unstructured additional information about the project.
|
15 |
-
created_at: date and time of creation
|
|
|
16 |
"""
|
17 |
|
18 |
class Project(Model):
|
19 |
url = CharField(unique=True)
|
|
|
20 |
structure = JSONField(null=True)
|
21 |
content = TextField(null=True)
|
22 |
created_at = DateTimeField(default=datetime.now)
|
|
|
4 |
|
5 |
# Initialize database
|
6 |
|
7 |
+
json_structure = """JSON column with hash with keys
|
8 |
|
9 |
+
'title': str, official title of the project
|
10 |
+
'deposit': int (in percentage), sum of all payments before the apartment is complete ("koladace" requested)
|
11 |
+
'cheapest_available_apartments' : hash with keys:
|
12 |
+
'1+kk': int, lowest price for 1+kk with VAT in CZK. It should not be booked or sold
|
13 |
+
'2+kk': int
|
14 |
+
'3+kk': int
|
15 |
+
'4+kk': int
|
16 |
+
'5+kk': int
|
17 |
+
'7+kk': int
|
18 |
+
'8+kk': int
|
19 |
+
'9+kk': int
|
20 |
+
'10+kk': int
|
21 |
+
'1+1': int
|
22 |
+
'2+1': int
|
23 |
+
'3+1': int
|
24 |
+
'4+1': int
|
25 |
+
'5+1': int
|
26 |
+
'6+1': int
|
27 |
+
'7+1': int
|
28 |
+
'8+1': int
|
29 |
+
'9+1': int
|
30 |
+
'10+1': int
|
31 |
+
'min_price': int, lowest available apartment price in CZK with VAT. It should not be booked or sold.
|
32 |
+
'status': str, status of the project (preparation, selling, sold out)
|
33 |
+
'city': str, city of the project
|
34 |
+
'lat': float, gps coordinates of the project
|
35 |
+
'lng': float, gps coordinates of the project
|
36 |
+
'start_year': int, year of construction start
|
37 |
+
'end_year': int, estimated year of construction end
|
38 |
+
'developer': str, name of the contruction company/"developer"
|
39 |
+
'ignore': bool, if True, the project does not have any apartments for sale. Some values can be null/unknown"""
|
40 |
db = SqliteExtDatabase('estate.db')
|
41 |
|
42 |
db_description = f"""Table "project" - list of real estate projects (novostavby) in Czech Republic
|
43 |
url: url of the project.
|
44 |
structure: {json_structure}.
|
45 |
content: unstructured additional information about the project.
|
46 |
+
created_at: date and time of creation
|
47 |
+
title: title of the project
|
48 |
"""
|
49 |
|
50 |
class Project(Model):
|
51 |
url = CharField(unique=True)
|
52 |
+
title = CharField(null=True)
|
53 |
structure = JSONField(null=True)
|
54 |
content = TextField(null=True)
|
55 |
created_at = DateTimeField(default=datetime.now)
|