Spaces:
Running
Running
File size: 795 Bytes
87296cd 9a2f0cb 87296cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # D:\jan-contract\tools\scheme_tools.py
import os
from dotenv import load_dotenv
from langchain.tools import tool
from langchain_community.tools.tavily_search import TavilySearchResults
load_dotenv()
# Safely set environment variable only if it exists
tavily_key = os.getenv("TAVILY_API_KEY")
if tavily_key:
os.environ["TAVILY_API_KEY"] = tavily_key
@tool
def scheme_search(query: str):
"""
Searches for government schemes based on a user's profile.
Use this tool to find relevant government schemes for a user.
"""
# Increased max_results to 7 to find content from more sources
tavily_search = TavilySearchResults(max_results=7)
results = tavily_search.invoke(f"official government schemes for {query} in India site:gov.in OR site:nic.in")
return results |