crewai-aisearchapi


Namecrewai-aisearchapi JSON
Version 1.0.8 PyPI version JSON
download
home_pageNone
SummaryAI Search API integration for CrewAI - Enable intelligent web search in your crews
upload_time2025-09-01 11:56:05
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2025 aisearchapi 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.
keywords crewai ai-agents search-api aisearchapi web-search intelligent-search research-automation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AI Search API for CrewAI - Contextual Prompts Guide

[![PyPI version](https://badge.fury.io/py/crewai-aisearchapi.svg)](https://badge.fury.io/py/crewai-aisearchapi)
[![Python Support](https://img.shields.io/pypi/pyversions/crewai-aisearchapi.svg)](https://pypi.org/project/crewai-aisearchapi/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

A **Python integration for CrewAI** that connects your agents to the [AI Search API](https://aisearchapi.io/?utm_source=pypi).  
It enables **contextual prompts, multi-message context handling, and intelligent answers with source citations**.

👉 Get your **free API key** from the [AI Search API dashboard](https://app.aisearchapi.io/dashboard?utm_source=pypi).

---

## Features

- **🔍 Prompt + Context Search**: Send a query plus structured context for better results  
- **💬 Multi-Message Context**: Pass multiple user messages for conversational awareness  
- **📚 Sources Included**: Responses come with citations when available  
- **⚡ CrewAI Integration**: Works with `Agent`, `Task`, `Crew` out of the box  
- **🖥️ Works with Local LLMs**: Use Ollama for reasoning + the search API for live info  
- **🛡️ Robust Error Handling**: Clear exceptions when context roles or models are invalid  

---

## Installation

```bash
pip install crewai-aisearchapi
```

---

## Quick Start (with Ollama + CrewAI)

```python
from crewai import Agent, Task, Crew, Process, LLM
from crewai_aisearchapi import AISearchTool

llm = LLM(
    model="ollama/llama3.2:3b",          # use a local model
    base_url="http://localhost:11434",   # Ollama default
    temperature=0.2,
)

tool = AISearchTool(api_key="your-api-key")

agent = Agent(
    role="Researcher",
    goal="Answer questions with context and sources.",
    backstory="Careful and concise.",
    tools=[tool],
    llm=llm,
    verbose=True,
)

task = Task(
    description="Answer: '{question}'. Keep it short.",
    expected_output="2–4 sentences.",
    agent=agent,
    markdown=True,
)

crew = Crew(agents=[agent], tasks=[task], process=Process.sequential, verbose=True)

if __name__ == "__main__":
    print(crew.kickoff(inputs={"question": "What is RLHF in AI?"}))
```

---

## Contextual Prompts

The AI Search API is designed to handle **context-rich prompts**.  
All context messages must use `"role": "user"`.

```python
result = tool.run({
    "prompt": "Explain how RLHF improves AI safety.",
    "context": [
        {"role": "user", "content": "Keep it simple, I'm new to ML."},
        {"role": "user", "content": "Add one practical example."}
    ],
    "response_type": "markdown"
})
```

This produces an answer that considers both your question and the context messages.

---

## Configuration Options

```python
from crewai_aisearchapi import AISearchTool, AISearchToolConfig

config = AISearchToolConfig(
    default_response_type="markdown",
    include_sources=True,
    timeout=30,
    verbose=True
)

tool = AISearchTool(api_key="your-api-key", config=config)
```

---

## Handling Responses

The tool returns a formatted string containing:
- **Answer** (the AI response)  
- **Sources** (when available)  
- **Response Time**  

Example:

```markdown
Reinforcement Learning with Human Feedback (RLHF) helps align AI models with human intent...

**Sources:**
- [1] https://example.com/rlhf-overview
- [2] https://research.example.org/rlhf

*Response time: 120ms*
```

---

## Environment Variables

```bash
export AISEARCH_API_KEY="your-api-key"
```

In Python:

```python
import os
from crewai_aisearchapi import AISearchTool

tool = AISearchTool(api_key=os.getenv("AISEARCH_API_KEY"))
```

---

## Troubleshooting

- **`model not found`** → Ensure you pulled the Ollama model:  
  `ollama pull llama3.2:3b`  
- **`Each context message must have role "user"`** → Convert `system` → `user` in your context.  
- **API key errors** → Check `AISEARCH_API_KEY` is set correctly in your environment.  

---

## License

MIT License - see the [LICENSE](LICENSE) file.

---

## Support

- **Dashboard & API Key**: [AI Search API Dashboard](https://app.aisearchapi.io/dashboard?utm_source=pypi)  
- **Docs**: [docs.aisearchapi.io](https://docs.aisearchapi.io/)  
- **Homepage**: [aisearchapi.io](https://aisearchapi.io/?utm_source=pypi)  
- **Issues**: [GitHub Issues](https://github.com/aisearchapi/crewai-aisearchapi/issues)  

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "crewai-aisearchapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "crewai, ai-agents, search-api, aisearchapi, web-search, intelligent-search, research-automation",
    "author": null,
    "author_email": "AI Search API <admin@aisearchapi.io>",
    "download_url": "https://files.pythonhosted.org/packages/51/eb/93eb8e25205e9082112dbff6286377f3cd73cd397bd2236e2cf546849f3d/crewai_aisearchapi-1.0.8.tar.gz",
    "platform": null,
    "description": "# AI Search API for CrewAI - Contextual Prompts Guide\r\n\r\n[![PyPI version](https://badge.fury.io/py/crewai-aisearchapi.svg)](https://badge.fury.io/py/crewai-aisearchapi)\r\n[![Python Support](https://img.shields.io/pypi/pyversions/crewai-aisearchapi.svg)](https://pypi.org/project/crewai-aisearchapi/)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\nA **Python integration for CrewAI** that connects your agents to the [AI Search API](https://aisearchapi.io/?utm_source=pypi).  \r\nIt enables **contextual prompts, multi-message context handling, and intelligent answers with source citations**.\r\n\r\n\ud83d\udc49 Get your **free API key** from the [AI Search API dashboard](https://app.aisearchapi.io/dashboard?utm_source=pypi).\r\n\r\n---\r\n\r\n## Features\r\n\r\n- **\ud83d\udd0d Prompt + Context Search**: Send a query plus structured context for better results  \r\n- **\ud83d\udcac Multi-Message Context**: Pass multiple user messages for conversational awareness  \r\n- **\ud83d\udcda Sources Included**: Responses come with citations when available  \r\n- **\u26a1 CrewAI Integration**: Works with `Agent`, `Task`, `Crew` out of the box  \r\n- **\ud83d\udda5\ufe0f Works with Local LLMs**: Use Ollama for reasoning + the search API for live info  \r\n- **\ud83d\udee1\ufe0f Robust Error Handling**: Clear exceptions when context roles or models are invalid  \r\n\r\n---\r\n\r\n## Installation\r\n\r\n```bash\r\npip install crewai-aisearchapi\r\n```\r\n\r\n---\r\n\r\n## Quick Start (with Ollama + CrewAI)\r\n\r\n```python\r\nfrom crewai import Agent, Task, Crew, Process, LLM\r\nfrom crewai_aisearchapi import AISearchTool\r\n\r\nllm = LLM(\r\n    model=\"ollama/llama3.2:3b\",          # use a local model\r\n    base_url=\"http://localhost:11434\",   # Ollama default\r\n    temperature=0.2,\r\n)\r\n\r\ntool = AISearchTool(api_key=\"your-api-key\")\r\n\r\nagent = Agent(\r\n    role=\"Researcher\",\r\n    goal=\"Answer questions with context and sources.\",\r\n    backstory=\"Careful and concise.\",\r\n    tools=[tool],\r\n    llm=llm,\r\n    verbose=True,\r\n)\r\n\r\ntask = Task(\r\n    description=\"Answer: '{question}'. Keep it short.\",\r\n    expected_output=\"2\u20134 sentences.\",\r\n    agent=agent,\r\n    markdown=True,\r\n)\r\n\r\ncrew = Crew(agents=[agent], tasks=[task], process=Process.sequential, verbose=True)\r\n\r\nif __name__ == \"__main__\":\r\n    print(crew.kickoff(inputs={\"question\": \"What is RLHF in AI?\"}))\r\n```\r\n\r\n---\r\n\r\n## Contextual Prompts\r\n\r\nThe AI Search API is designed to handle **context-rich prompts**.  \r\nAll context messages must use `\"role\": \"user\"`.\r\n\r\n```python\r\nresult = tool.run({\r\n    \"prompt\": \"Explain how RLHF improves AI safety.\",\r\n    \"context\": [\r\n        {\"role\": \"user\", \"content\": \"Keep it simple, I'm new to ML.\"},\r\n        {\"role\": \"user\", \"content\": \"Add one practical example.\"}\r\n    ],\r\n    \"response_type\": \"markdown\"\r\n})\r\n```\r\n\r\nThis produces an answer that considers both your question and the context messages.\r\n\r\n---\r\n\r\n## Configuration Options\r\n\r\n```python\r\nfrom crewai_aisearchapi import AISearchTool, AISearchToolConfig\r\n\r\nconfig = AISearchToolConfig(\r\n    default_response_type=\"markdown\",\r\n    include_sources=True,\r\n    timeout=30,\r\n    verbose=True\r\n)\r\n\r\ntool = AISearchTool(api_key=\"your-api-key\", config=config)\r\n```\r\n\r\n---\r\n\r\n## Handling Responses\r\n\r\nThe tool returns a formatted string containing:\r\n- **Answer** (the AI response)  \r\n- **Sources** (when available)  \r\n- **Response Time**  \r\n\r\nExample:\r\n\r\n```markdown\r\nReinforcement Learning with Human Feedback (RLHF) helps align AI models with human intent...\r\n\r\n**Sources:**\r\n- [1] https://example.com/rlhf-overview\r\n- [2] https://research.example.org/rlhf\r\n\r\n*Response time: 120ms*\r\n```\r\n\r\n---\r\n\r\n## Environment Variables\r\n\r\n```bash\r\nexport AISEARCH_API_KEY=\"your-api-key\"\r\n```\r\n\r\nIn Python:\r\n\r\n```python\r\nimport os\r\nfrom crewai_aisearchapi import AISearchTool\r\n\r\ntool = AISearchTool(api_key=os.getenv(\"AISEARCH_API_KEY\"))\r\n```\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\n- **`model not found`** \u2192 Ensure you pulled the Ollama model:  \r\n  `ollama pull llama3.2:3b`  \r\n- **`Each context message must have role \"user\"`** \u2192 Convert `system` \u2192 `user` in your context.  \r\n- **API key errors** \u2192 Check `AISEARCH_API_KEY` is set correctly in your environment.  \r\n\r\n---\r\n\r\n## License\r\n\r\nMIT License - see the [LICENSE](LICENSE) file.\r\n\r\n---\r\n\r\n## Support\r\n\r\n- **Dashboard & API Key**: [AI Search API Dashboard](https://app.aisearchapi.io/dashboard?utm_source=pypi)  \r\n- **Docs**: [docs.aisearchapi.io](https://docs.aisearchapi.io/)  \r\n- **Homepage**: [aisearchapi.io](https://aisearchapi.io/?utm_source=pypi)  \r\n- **Issues**: [GitHub Issues](https://github.com/aisearchapi/crewai-aisearchapi/issues)  \r\n",
    "bugtrack_url": null,
    "license": "MIT License\r\n        \r\n        Copyright (c) 2025 aisearchapi\r\n        \r\n        Permission is hereby granted, free of charge, to any person obtaining a copy\r\n        of this software and associated documentation files (the \"Software\"), to deal\r\n        in the Software without restriction, including without limitation the rights\r\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n        copies of the Software, and to permit persons to whom the Software is\r\n        furnished to do so, subject to the following conditions:\r\n        \r\n        The above copyright notice and this permission notice shall be included in all\r\n        copies or substantial portions of the Software.\r\n        \r\n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n        SOFTWARE.\r\n        ",
    "summary": "AI Search API integration for CrewAI - Enable intelligent web search in your crews",
    "version": "1.0.8",
    "project_urls": {
        "Documentation": "https://docs.aisearchapi.io/integrations/crewai",
        "Homepage": "https://github.com/aisearchapi/crewai-aisearchapi",
        "Repository": "https://github.com/aisearchapi/crewai-aisearchapi"
    },
    "split_keywords": [
        "crewai",
        " ai-agents",
        " search-api",
        " aisearchapi",
        " web-search",
        " intelligent-search",
        " research-automation"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bd23ffd9081b3003751e99717b6bb4173d65eaf6e26297db18b1b1ff849d40a8",
                "md5": "f39129008f55c4480a3bba6cdf3dd4fb",
                "sha256": "fc351ac3ad30cccf9cbd260cac76c766e431c23b9cdea1f43089e916aaf77601"
            },
            "downloads": -1,
            "filename": "crewai_aisearchapi-1.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f39129008f55c4480a3bba6cdf3dd4fb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7722,
            "upload_time": "2025-09-01T11:56:04",
            "upload_time_iso_8601": "2025-09-01T11:56:04.801890Z",
            "url": "https://files.pythonhosted.org/packages/bd/23/ffd9081b3003751e99717b6bb4173d65eaf6e26297db18b1b1ff849d40a8/crewai_aisearchapi-1.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "51eb93eb8e25205e9082112dbff6286377f3cd73cd397bd2236e2cf546849f3d",
                "md5": "3a3090f09ee452cd292a538575cd073a",
                "sha256": "65f7bfe24736d85afec8dda25ca9d3854c1fb708e127d7ebab89e577718dce5e"
            },
            "downloads": -1,
            "filename": "crewai_aisearchapi-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "3a3090f09ee452cd292a538575cd073a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7675,
            "upload_time": "2025-09-01T11:56:05",
            "upload_time_iso_8601": "2025-09-01T11:56:05.873720Z",
            "url": "https://files.pythonhosted.org/packages/51/eb/93eb8e25205e9082112dbff6286377f3cd73cd397bd2236e2cf546849f3d/crewai_aisearchapi-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-01 11:56:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aisearchapi",
    "github_project": "crewai-aisearchapi",
    "github_not_found": true,
    "lcname": "crewai-aisearchapi"
}
        
Elapsed time: 1.55637s