Spaces:
Sleeping
Sleeping
David Hrachovy
commited on
Commit
·
400552c
1
Parent(s):
5a3f6d9
Update
Browse files- app.py +13 -8
- estate.db +2 -2
- init_db.py +1 -1
app.py
CHANGED
@@ -1,14 +1,19 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
from langchain_community.agent_toolkits.sql.toolkit import SQLDatabaseToolkit
|
6 |
import gradio as gr
|
7 |
from dotenv import load_dotenv
|
8 |
-
from langchain.
|
9 |
from langchain.prompts import ChatPromptTemplate
|
10 |
-
import
|
|
|
|
|
|
|
|
|
|
|
11 |
from init_db import db_description, Project
|
|
|
12 |
# Load environment variables
|
13 |
load_dotenv()
|
14 |
|
@@ -82,7 +87,7 @@ def chat_with_sql(message, history):
|
|
82 |
yield f"Error: {str(e)}"
|
83 |
|
84 |
# Create the Gradio interface
|
85 |
-
count_projects = Project.select().count()
|
86 |
demo = gr.ChatInterface(
|
87 |
fn=chat_with_sql,
|
88 |
title="Estate Chat",
|
|
|
1 |
+
# Standard library imports
|
2 |
+
import os.path
|
3 |
+
|
4 |
+
# Third-party imports
|
|
|
5 |
import gradio as gr
|
6 |
from dotenv import load_dotenv
|
7 |
+
from langchain.agents import AgentExecutor, create_openai_tools_agent
|
8 |
from langchain.prompts import ChatPromptTemplate
|
9 |
+
from langchain.schema import HumanMessage, AIMessage
|
10 |
+
from langchain_community.utilities import SQLDatabase
|
11 |
+
from langchain_community.agent_toolkits.sql.toolkit import SQLDatabaseToolkit
|
12 |
+
from langchain_openai import ChatOpenAI
|
13 |
+
|
14 |
+
# Local imports
|
15 |
from init_db import db_description, Project
|
16 |
+
|
17 |
# Load environment variables
|
18 |
load_dotenv()
|
19 |
|
|
|
87 |
yield f"Error: {str(e)}"
|
88 |
|
89 |
# Create the Gradio interface
|
90 |
+
count_projects = Project.select().where(Project.structure.is_null(False)).count()
|
91 |
demo = gr.ChatInterface(
|
92 |
fn=chat_with_sql,
|
93 |
title="Estate Chat",
|
estate.db
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:214270678ea85f7102ea9ce460d33c9ba0fe3226c3c4087bc302cc2e7666b030
|
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), 'min_price': int, lowest available
|
8 |
|
9 |
db = SqliteExtDatabase('estate.db', pragmas=(
|
10 |
('cache_size', -1024 * 64), # 64MB page-cache.
|
|
|
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. Some values can be null/unknown"
|
8 |
|
9 |
db = SqliteExtDatabase('estate.db', pragmas=(
|
10 |
('cache_size', -1024 * 64), # 64MB page-cache.
|