The RexiaAIGoogleSearch class is an extension of the Google Search Tool from langchain_community, adapted to work more consistently with open-source models within the ReXia.AI framework. This tool allows agents to perform Google searches and retrieve results.
api_key: The API key for Google Search.engine_id: The engine ID for Google Search.google_search_api: An instance of GoogleSearchAPIWrapper from langchain_google_community.
Initializes a RexiaAIGoogleSearch instance.
Parameters:
api_key: The API key for Google Search.engine_id: The engine ID for Google Search.
Runs a query through Google Search and parses the result.
Parameters:
query: The search query to execute.
Returns:
- The search result as a string.
Returns the tool as a JSON object for ReXia.AI.
Returns:
- The tool as a JSON object.
Returns the tool as a dictionary object for ReXia.AI.
Returns:
- The tool as a dictionary object.
Here's an example of how to use the RexiaAIGoogleSearch class:
from rexia_ai.tools import RexiaAIGoogleSearch
from rexia_ai.agent import Agent
from rexia_ai.workflows import SimpleToolWorkflow
# Initialize the RexiaAIGoogleSearch instance
google_search_tool = RexiaAIGoogleSearch(
api_key="your-google-api-key",
engine_id="your-google-engine-id"
)
# Create an Agent instance with SimpleToolWorkflow and the Google search tool
agent = Agent(
llm=..., # Your language model instance
task="Search for information on a topic",
workflow=SimpleToolWorkflow,
verbose=True,
tools={"google_search": google_search_tool}
)
# Run the agent
result = agent.invoke("What is the capital of France?")
print(result)langchain_google_community- ReXia.AI components (
BaseTool)
Ensure all dependencies are installed and properly imported.
We welcome contributions to improve the ReXia.AI framework. Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Make your changes.
- Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Create a new Pull Request.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Credit to the original authors of the langchain_community Google Search Tool, who did most of the work. This class extends their implementation to work more consistently with open-source models within ReXia.AI.