Metadata-Version: 2.4
Name: iflow-search-crewai
Version: 0.1.0
Summary: CrewAI tools for iFlow Search (心流搜索) — web search, image search, and web-page fetching.
Project-URL: Homepage, https://platform.iflow.cn/
Project-URL: Documentation, https://platform.iflow.cn/docs/
Project-URL: Repository, https://github.com/zhengyanglsun/iflow-search-py
Project-URL: Issues, https://github.com/zhengyanglsun/iflow-search-py/issues
Author: iFlow Search SDK contributors
License: MIT License
        
        Copyright (c) 2026 iFlow Search SDK contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,ai,crewai,iflow,llm,search,tools
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: crewai<2.0,>=0.80.0
Requires-Dist: iflow-search<0.2,>=0.1.0
Requires-Dist: pydantic<3.0,>=2.7
Provides-Extra: dev
Requires-Dist: httpx<1.0,>=0.27; extra == 'dev'
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'dev'
Description-Content-Type: text/markdown

# iflow-search-crewai

CrewAI tools for **iFlow Search (心流搜索)** — web search, image search, and web-page fetching, exposed as native `crewai.tools.BaseTool` instances.

This package is a **CrewAI-native Python tool adapter**. It is **not** a CrewAI Studio / AMP official provider tile. To appear as a first-class “iFlow Search” integration inside CrewAI’s product UI, a separate official partnership / Catalog / Marketplace route is required.

- **Core SDK:** [`iflow-search`](https://pypi.org/project/iflow-search/)
- **Sibling adapters:** [`iflow-search-mcp`](https://pypi.org/project/iflow-search-mcp/), [`iflow-search-langchain`](https://pypi.org/project/iflow-search-langchain/)
- **API docs:** <https://platform.iflow.cn/docs/>

## Install

```bash
pip install iflow-search-crewai
```

## Configuration

```bash
export IFLOW_API_KEY="YOUR_IFLOW_API_KEY"
```

Optional:

```bash
export IFLOW_BASE_URL="https://platform.iflow.cn"
export IFLOW_TIMEOUT_MS="30000"
```

Never commit API keys. Do not hard-code keys in source files.

## Basic CrewAI usage

```python
from crewai import Agent
from iflow_search_crewai import create_iflow_search_tools

agent = Agent(
    role="Researcher",
    goal="Research current information from the web",
    backstory="You are a careful research assistant.",
    tools=create_iflow_search_tools(),
)
```

## Single-tool usage

```python
from iflow_search_crewai import IFlowWebSearchTool

web_search = IFlowWebSearchTool()
result = web_search.run(query="latest AI agent frameworks", count=5)
```

## Tools

| Class | Tool name | Purpose |
| --- | --- | --- |
| `IFlowWebSearchTool` | `iflow_web_search` | Web search by query |
| `IFlowImageSearchTool` | `iflow_image_search` | Image search by query |
| `IFlowWebFetchTool` | `iflow_web_fetch` | Fetch readable content from a URL |

### Arguments

| Tool | Parameters |
| --- | --- |
| Web Search | `query: str`, `count: int = 10` (1–50) |
| Image Search | `query: str`, `count: int = 10` (1–50) |
| Web Fetch | `url: str` (`http://` or `https://`) |

Each tool returns a **JSON string** with compact, LLM-friendly fields (titles, URLs, snippets, etc.).

## DeepSeek + CrewAI smoke example

Requires `crewai`, this package, and API keys in the environment. **Do not hard-code keys.**

```python
import os

from crewai import Agent, Crew, Task, LLM
from iflow_search_crewai import IFlowWebSearchTool

llm = LLM(
    model="deepseek/deepseek-chat",
    api_key=os.environ["DEEPSEEK_API_KEY"],
)

researcher = Agent(
    role="Web Researcher",
    goal="Answer questions using live web search",
    backstory="You use iflow_web_search when current information is needed.",
    tools=[IFlowWebSearchTool()],
    llm=llm,
    verbose=True,
)

task = Task(
    description="What is CrewAI? Give a one-sentence answer grounded in search results.",
    expected_output="A one-sentence summary with a source URL.",
    agent=researcher,
)

crew = Crew(agents=[researcher], tasks=[task], verbose=True)
result = crew.kickoff()
print(result)
```

If your CrewAI version prefers a different DeepSeek model string, adjust `model=` to match your installed CrewAI / LiteLLM configuration.

## vs MCP route

| | `iflow-search-crewai` | `iflow-search-mcp` / `@iflow-ai/search-mcp` |
| --- | --- | --- |
| Integration style | Native CrewAI `BaseTool` | MCP stdio server |
| Host setup | `pip install` + env var | `npx` or Python MCP binary + MCP config |
| Best for | Python-first CrewAI projects | MCP-native hosts and `MCPServerAdapter` |

Both call the same iFlow Search API via the shared `iflow-search` core SDK (Python) or MCP adapter (JS/Python).

## Boundaries

- Not a built-in CrewAI search provider.
- Not an AMP / Studio UI tile without CrewAI official integration work.
- Does not replace `iflow-search-mcp` for MCP-based workflows.

## Local development

```bash
cd packages/iflow-search-crewai
python -m pip install -e "../iflow-search"
python -m pip install -e ".[dev]"
python -m pytest -q
python -m ruff check .
python -m mypy src/iflow_search_crewai
```

## Optional real-API smoke

```bash
export IFLOW_API_KEY="YOUR_IFLOW_API_KEY"
export IFLOW_CREWAI_SMOKE=1
python scripts/smoke_real_api.py
```
