The RexiaAIQueryKnowledgeBase
class is a tool within the ReXia.AI framework that allows agents to query a knowledge base using large language models. This tool is designed to enable smaller local models to access information or assistance from larger, more capable models.
llm
: An instance of the RexiaAIOpenAI class, configured with the specified model and temperature.
Initializes a RexiaAIQueryKnowledgeBase instance.
Parameters:
base_url
: The base URL for the large language model API.api_key
: The API key for the large language model API.model
: The model identifier for querying the knowledge base.temperature
: The temperature to control the randomness of model responses.
Queries the knowledge base with the given query and returns the model's response.
Parameters:
query
: The task or query to be sent to the knowledge base.
Returns:
- The response from the knowledge base to the given query.
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 RexiaAIQueryKnowledgeBase
class:
from rexia_ai.tools import RexiaAIQueryKnowledgeBase
from rexia_ai.agent import Agent
from rexia_ai.workflows import SimpleToolWorkflow
# Initialize the RexiaAIQueryKnowledgeBase instance
knowledge_base_tool = RexiaAIQueryKnowledgeBase(
base_url="https://api.example.com",
api_key="your-api-key",
model="gpt-3.5-turbo",
temperature=0.7
)
# Create an Agent instance with SimpleToolWorkflow and the knowledge base tool
agent = Agent(
llm=..., # Your language model instance
task="Query the knowledge base for information",
workflow=SimpleToolWorkflow,
verbose=True,
tools={"query_knowledge_base": knowledge_base_tool}
)
# Run the agent
result = agent.invoke("What is the capital of France?")
print(result)
- ReXia.AI components (
RexiaAIOpenAI
)
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.