Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -1,6 +1,4 @@
|
|
1 |
from langchain_community.llms import HuggingFaceEndpoint
|
2 |
-
from langchain_community.utilities import SQLDatabase
|
3 |
-
from sqlalchemy import create_engine
|
4 |
from langchain_core.prompts import PromptTemplate
|
5 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
6 |
from langchain.memory import ChatMessageHistory, ConversationBufferMemory
|
@@ -8,16 +6,14 @@ from langchain.schema import StrOutputParser
|
|
8 |
from langchain.schema.runnable import Runnable, RunnablePassthrough, RunnableLambda
|
9 |
from langchain.schema.runnable.config import RunnableConfig
|
10 |
from langchain.schema import StrOutputParser
|
11 |
-
from langchain_community.agent_toolkits import create_sql_agent
|
12 |
|
13 |
import os
|
14 |
import pandas as pd
|
15 |
import numpy as np
|
16 |
-
import random
|
17 |
|
18 |
from langchain.agents import AgentExecutor
|
19 |
from langchain.agents.agent_types import AgentType
|
20 |
-
|
21 |
|
22 |
from deep_translator import GoogleTranslator
|
23 |
|
@@ -48,25 +44,12 @@ async def on_chat_start():
|
|
48 |
llm = HuggingFaceEndpoint(
|
49 |
repo_id=repo_id, temperature=1.0
|
50 |
)
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
cl.user_session.set("createdb", "OK")
|
58 |
-
cl.user_session.set("db", db)
|
59 |
-
else:
|
60 |
-
db = cl.user_session.get("db")
|
61 |
-
|
62 |
-
agent = create_sql_agent(llm, db=db, agent_type="zero-shot-react-description", verbose=True)
|
63 |
-
|
64 |
-
#agent = create_csv_agent(
|
65 |
-
# llm,
|
66 |
-
# "https://cipen.univ-gustave-eiffel.fr/typo3conf/ext/cipen_package/Resources/Public/Dataviz/datalab/crossfilterings/enquete-DClic-juin2022-dataviz-ord1.csv",
|
67 |
-
# verbose=True,
|
68 |
-
# agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION
|
69 |
-
#)
|
70 |
cl.user_session.set("runnable", agent)
|
71 |
|
72 |
@cl.on_message
|
|
|
1 |
from langchain_community.llms import HuggingFaceEndpoint
|
|
|
|
|
2 |
from langchain_core.prompts import PromptTemplate
|
3 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
4 |
from langchain.memory import ChatMessageHistory, ConversationBufferMemory
|
|
|
6 |
from langchain.schema.runnable import Runnable, RunnablePassthrough, RunnableLambda
|
7 |
from langchain.schema.runnable.config import RunnableConfig
|
8 |
from langchain.schema import StrOutputParser
|
|
|
9 |
|
10 |
import os
|
11 |
import pandas as pd
|
12 |
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 |
|
|
|
44 |
llm = HuggingFaceEndpoint(
|
45 |
repo_id=repo_id, temperature=1.0
|
46 |
)
|
47 |
+
agent = create_csv_agent(
|
48 |
+
llm,
|
49 |
+
"https://cipen.univ-gustave-eiffel.fr/typo3conf/ext/cipen_package/Resources/Public/Dataviz/datalab/crossfilterings/enquete-DClic-juin2022-dataviz-ord1.csv",
|
50 |
+
verbose=True,
|
51 |
+
agent_type=AgentType.ZERO_SHOT_REACT_DESCRIPTION
|
52 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
cl.user_session.set("runnable", agent)
|
54 |
|
55 |
@cl.on_message
|