Revert "feat: Improve documentation for TXTSearchTool"

This reverts commit f7015763d4.
This commit is contained in:
Rip&Tear
2024-09-05 10:29:03 +08:00
parent b9b75c7e1d
commit 8b732247cd

View File

@@ -1,92 +1,62 @@
# TXTSearchTool
!!! note "Experimental"
This tool is currently in an experimental stage. We are actively working on improvements, so there might be unexpected behavior or changes in future versions.
We are still working on improving tools, so there might be unexpected behavior or changes in the future.
## Description
The TXTSearchTool is designed to perform RAG (Retrieval-Augmented Generation) searches within the content of text files. It enables semantic searching of queries within specified text file content, making it an invaluable resource for quickly extracting information or locating specific sections of text based on the provided query.
This tool is used to perform a RAG (Retrieval-Augmented Generation) search within the content of a text file. It allows for semantic searching of a query within a specified text file's content, making it an invaluable resource for quickly extracting information or finding specific sections of text based on the query provided.
## Installation
To use the TXTSearchTool, you need to install the crewai_tools package. Use pip, the Python package manager, by running the following command in your terminal or command prompt:
To use the TXTSearchTool, you first need to install the crewai_tools package. This can be done using pip, a package manager for Python. Open your terminal or command prompt and enter the following command:
```shell
pip install 'crewai[tools]'
```
This command will install the TXTSearchTool along with all necessary dependencies.
This command will download and install the TXTSearchTool along with any necessary dependencies.
## Usage
## Example
The following example demonstrates how to use the TXTSearchTool to search within a text file. This example shows both the initialization of the tool with a specific text file and the subsequent search within that file's content.
### Basic Initialization
There are two ways to initialize the TXTSearchTool:
```python
from crewai_tools import TXTSearchTool
1. Without specifying a text file:
```python
from crewai_tools import TXTSearchTool
# Initialize the tool to search within any text file's content the agent learns about during its execution
tool = TXTSearchTool()
# Initialize the tool to search within any text file's content the agent learns about during its execution
tool = TXTSearchTool()
```
# OR
2. With a specific text file:
```python
from crewai_tools import TXTSearchTool
# Initialize the tool with a specific text file, so the agent can search within the given text file's content
tool = TXTSearchTool(txt='path/to/text/file.txt')
```
# Initialize the tool with a specific text file
tool = TXTSearchTool(txt='path/to/text/file.txt')
```
## Arguments
- `txt` (str): **Optional**. The path to the text file you want to search. This argument is only required if the tool was not initialized with a specific text file; otherwise, the search will be conducted within the initially provided text file.
### Arguments
- `txt` (str, optional): The path to the text file you want to search. If not provided during initialization, it must be specified when using the tool.
## Custom model and embeddings
### Performing a Search
After initialization, you can use the tool to perform searches. The exact method to do this depends on how you're using the tool within your CrewAI setup.
## Advanced Configuration: Custom Models and Embeddings
By default, the TXTSearchTool uses OpenAI for both embeddings and summarization. However, you can customize these settings using a configuration dictionary:
By default, the tool uses OpenAI for both embeddings and summarization. To customize the model, you can use a config dictionary as follows:
```python
tool = TXTSearchTool(
config=dict(
llm=dict(
provider="ollama", # Options: google, openai, anthropic, llama2, etc.
provider="ollama", # or google, openai, anthropic, llama2, ...
config=dict(
model="llama2",
# Uncomment and adjust these optional parameters as needed:
# temperature=0.5,
# top_p=1,
# stream=True,
# stream=true,
),
),
embedder=dict(
provider="google", # Options: openai, ollama, etc.
provider="google", # or openai, ollama, ...
config=dict(
model="models/embedding-001",
task_type="retrieval_document",
# Uncomment if needed:
# title="Embeddings",
),
),
)
)
```
This configuration allows you to specify different providers and models for both the language model (llm) and the embedder.
## Best Practices
- Ensure the text file is in a readable format and encoding.
- For large text files, consider splitting them into smaller, more manageable chunks.
- Experiment with different query formulations to get the most relevant results.
## Limitations
- The tool's effectiveness may vary depending on the size and complexity of the text file.
- Performance can be affected by the chosen language model and embedding provider.
## Troubleshooting
If you encounter issues:
1. Verify that the text file path is correct and accessible.
2. Check that you have the necessary permissions to read the file.
3. Ensure you have a stable internet connection if using cloud-based models.
For further assistance, please refer to the CrewAI documentation or reach out to the support community.