Update agent.py
Browse files
agent.py
CHANGED
|
@@ -19,7 +19,7 @@ from langchain_openai import ChatOpenAI
|
|
| 19 |
|
| 20 |
from langchain.tools import Tool
|
| 21 |
from code_interpreter import CodeInterpreter
|
| 22 |
-
from langchain_chroma import Chroma
|
| 23 |
from langchain_core.messages import AIMessage
|
| 24 |
|
| 25 |
interpreter_instance = CodeInterpreter()
|
|
@@ -27,6 +27,8 @@ interpreter_instance = CodeInterpreter()
|
|
| 27 |
|
| 28 |
load_dotenv()
|
| 29 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
|
|
|
|
| 30 |
|
| 31 |
### ======================================== MATHEMATICAL TOOLS ======================================== ###
|
| 32 |
|
|
@@ -232,6 +234,9 @@ execute_code_multilang_tool = Tool(
|
|
| 232 |
|
| 233 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
| 234 |
|
|
|
|
|
|
|
|
|
|
| 235 |
vector_store = Chroma(
|
| 236 |
collection_name="gaia_dataset",
|
| 237 |
embedding_function=embeddings,
|
|
@@ -243,25 +248,22 @@ create_retriever_tool = create_retriever_tool(
|
|
| 243 |
name="Question Search",
|
| 244 |
description="A tool to retrieve similar questions from a vector store.",
|
| 245 |
)
|
| 246 |
-
|
| 247 |
"""
|
|
|
|
|
|
|
| 248 |
# build a retriever
|
| 249 |
-
|
| 250 |
-
supabase: Client = create_client(
|
| 251 |
-
os.environ.get("SUPABASE_URL"),
|
| 252 |
-
os.environ.get("SUPABASE_SERVICE_KEY"))
|
| 253 |
vector_store = SupabaseVectorStore(
|
|
|
|
| 254 |
client=supabase,
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
query_name="match_documents_langchain",
|
| 258 |
)
|
| 259 |
create_retriever_tool = create_retriever_tool(
|
| 260 |
retriever=vector_store.as_retriever(),
|
| 261 |
name="Question Search",
|
| 262 |
description="A tool to retrieve similar questions from a vector store.",
|
| 263 |
)
|
| 264 |
-
"""
|
| 265 |
|
| 266 |
|
| 267 |
# load the system prompt from the file
|
|
|
|
| 19 |
|
| 20 |
from langchain.tools import Tool
|
| 21 |
from code_interpreter import CodeInterpreter
|
| 22 |
+
#from langchain_chroma import Chroma
|
| 23 |
from langchain_core.messages import AIMessage
|
| 24 |
|
| 25 |
interpreter_instance = CodeInterpreter()
|
|
|
|
| 27 |
|
| 28 |
load_dotenv()
|
| 29 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 30 |
+
SUPABASE_URL = os.environ.get("SUPABASE_URL")
|
| 31 |
+
SUPABASE_SERVICE_KEY = os.environ.get("SUPABASE_SERVICE_KEY")
|
| 32 |
|
| 33 |
### ======================================== MATHEMATICAL TOOLS ======================================== ###
|
| 34 |
|
|
|
|
| 234 |
|
| 235 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-mpnet-base-v2")
|
| 236 |
|
| 237 |
+
"""
|
| 238 |
+
Using chroma database
|
| 239 |
+
|
| 240 |
vector_store = Chroma(
|
| 241 |
collection_name="gaia_dataset",
|
| 242 |
embedding_function=embeddings,
|
|
|
|
| 248 |
name="Question Search",
|
| 249 |
description="A tool to retrieve similar questions from a vector store.",
|
| 250 |
)
|
|
|
|
| 251 |
"""
|
| 252 |
+
|
| 253 |
+
# Using supabase database
|
| 254 |
# build a retriever
|
| 255 |
+
supabase: Client = create_client(SUPABASE_URL, SUPABASE_SERVICE_KEY)
|
|
|
|
|
|
|
|
|
|
| 256 |
vector_store = SupabaseVectorStore(
|
| 257 |
+
embedding=embeddings,
|
| 258 |
client=supabase,
|
| 259 |
+
table_name="gaia_dataset",
|
| 260 |
+
query_name="match_documents",
|
|
|
|
| 261 |
)
|
| 262 |
create_retriever_tool = create_retriever_tool(
|
| 263 |
retriever=vector_store.as_retriever(),
|
| 264 |
name="Question Search",
|
| 265 |
description="A tool to retrieve similar questions from a vector store.",
|
| 266 |
)
|
|
|
|
| 267 |
|
| 268 |
|
| 269 |
# load the system prompt from the file
|