Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -13,7 +13,11 @@ import numpy as np
|
|
13 |
|
14 |
from langchain.agents import AgentExecutor
|
15 |
from langchain.agents.agent_types import AgentType
|
16 |
-
from langchain_experimental.agents.agent_toolkits import create_csv_agent
|
|
|
|
|
|
|
|
|
17 |
|
18 |
from deep_translator import GoogleTranslator
|
19 |
|
@@ -69,13 +73,22 @@ async def on_chat_start():
|
|
69 |
llm = HuggingFaceEndpoint(
|
70 |
repo_id=repo_id, temperature=1.0
|
71 |
)
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
cl.user_session.set("runnable", agent)
|
80 |
|
81 |
@cl.on_message
|
|
|
13 |
|
14 |
from langchain.agents import AgentExecutor
|
15 |
from langchain.agents.agent_types import AgentType
|
16 |
+
#from langchain_experimental.agents.agent_toolkits import create_csv_agent
|
17 |
+
|
18 |
+
from langchain_community.agent_toolkits import create_sql_agent
|
19 |
+
from langchain_community.utilities import SQLDatabase
|
20 |
+
from sqlalchemy import create_engine
|
21 |
|
22 |
from deep_translator import GoogleTranslator
|
23 |
|
|
|
73 |
llm = HuggingFaceEndpoint(
|
74 |
repo_id=repo_id, temperature=1.0
|
75 |
)
|
76 |
+
|
77 |
+
|
78 |
+
df = pd.read_csv("https://cipen.univ-gustave-eiffel.fr/typo3conf/ext/cipen_package/Resources/Public/Dataviz/datalab/crossfilterings/EmploisRome/" + selectRomes[1:] + ".csv")
|
79 |
+
engine = create_engine("sqlite:///sphinx" + str(cl.user_session.get("id")) + ".db")
|
80 |
+
df.to_sql("sphinx" + str(cl.user_session.get("id")), engine, index=False)
|
81 |
+
db = SQLDatabase(engine=engine)
|
82 |
+
agent = create_sql_agent(llm, db=db, verbose=True)
|
83 |
+
|
84 |
+
|
85 |
+
#agent = create_csv_agent(
|
86 |
+
# llm,
|
87 |
+
# "https://cipen.univ-gustave-eiffel.fr/typo3conf/ext/cipen_package/Resources/Public/Dataviz/datalab/crossfilterings/EmploisRome/" + selectRomes[1:] + ".csv",
|
88 |
+
# verbose=False,
|
89 |
+
# agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
90 |
+
# max_iterations=5,
|
91 |
+
#)
|
92 |
cl.user_session.set("runnable", agent)
|
93 |
|
94 |
@cl.on_message
|