Spaces:
Sleeping
Sleeping
Add google chat
Browse files- requirements.txt +2 -1
- tools.py +9 -5
requirements.txt
CHANGED
|
@@ -14,4 +14,5 @@ google-search-results
|
|
| 14 |
langchain-huggingface
|
| 15 |
langchain-community
|
| 16 |
supabase
|
| 17 |
-
sentence-transformers
|
|
|
|
|
|
| 14 |
langchain-huggingface
|
| 15 |
langchain-community
|
| 16 |
supabase
|
| 17 |
+
sentence-transformers
|
| 18 |
+
langchain-google-genai
|
tools.py
CHANGED
|
@@ -4,6 +4,7 @@ from langchain_core.messages import SystemMessage, HumanMessage, AnyMessage
|
|
| 4 |
from langgraph.graph.message import add_messages
|
| 5 |
from langchain_community.vectorstores import SupabaseVectorStore
|
| 6 |
from supabase.client import create_client
|
|
|
|
| 7 |
from langchain_huggingface import HuggingFaceEmbeddings, ChatHuggingFace, HuggingFaceEndpoint
|
| 8 |
from serpapi import GoogleSearch
|
| 9 |
from dotenv import load_dotenv
|
|
@@ -34,7 +35,7 @@ def web_search(query: str) -> str:
|
|
| 34 |
params = {
|
| 35 |
"engine": "google",
|
| 36 |
"q": query,
|
| 37 |
-
"api_key": os.getenv("
|
| 38 |
"num": 5
|
| 39 |
}
|
| 40 |
search = GoogleSearch(params)
|
|
@@ -46,11 +47,14 @@ def web_search(query: str) -> str:
|
|
| 46 |
)
|
| 47 |
return context if context else "No results found."
|
| 48 |
|
| 49 |
-
llm = ChatHuggingFace(llm = HuggingFaceEndpoint(
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
tools = [add, subtract, divide, web_search]
|
|
|
|
| 54 |
llm_with_tools = llm.bind_tools(tools)
|
| 55 |
|
| 56 |
def retriever(state: AgentState) -> Dict:
|
|
|
|
| 4 |
from langgraph.graph.message import add_messages
|
| 5 |
from langchain_community.vectorstores import SupabaseVectorStore
|
| 6 |
from supabase.client import create_client
|
| 7 |
+
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 8 |
from langchain_huggingface import HuggingFaceEmbeddings, ChatHuggingFace, HuggingFaceEndpoint
|
| 9 |
from serpapi import GoogleSearch
|
| 10 |
from dotenv import load_dotenv
|
|
|
|
| 35 |
params = {
|
| 36 |
"engine": "google",
|
| 37 |
"q": query,
|
| 38 |
+
"api_key": os.getenv("SERPAPI_KEY"),
|
| 39 |
"num": 5
|
| 40 |
}
|
| 41 |
search = GoogleSearch(params)
|
|
|
|
| 47 |
)
|
| 48 |
return context if context else "No results found."
|
| 49 |
|
| 50 |
+
# llm = ChatHuggingFace(llm = HuggingFaceEndpoint(
|
| 51 |
+
# repo_id = "meta-llama/Llama-2-7b-chat-hf",
|
| 52 |
+
# temperature=0,
|
| 53 |
+
# huggingfacehub_api_token=os.environ.get("HUGGING_FACE_API_KEY")))
|
| 54 |
+
|
| 55 |
+
|
| 56 |
tools = [add, subtract, divide, web_search]
|
| 57 |
+
llm =ChatGoogleGenerativeAI(model = "gemini-2.0-flash")
|
| 58 |
llm_with_tools = llm.bind_tools(tools)
|
| 59 |
|
| 60 |
def retriever(state: AgentState) -> Dict:
|