Metadata-Version: 2.5
Name: langroid-datacircle
Version: 0.1.0
Summary: Langroid tools for the Datacircle API: find the best GTM APIs
Project-URL: Homepage, https://datacircle.dev
Project-URL: Documentation, https://api.datacircle.dev/v1/openapi.json
Project-URL: Repository, https://github.com/waynehamadi/langroid-datacircle
License-Expression: MIT
License-File: LICENSE
Keywords: agents,api,api-pricing,b2b-data,datacircle,gtm,langroid,toolmessage,tools
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: langroid>=0.59.0
Description-Content-Type: text/markdown

# langroid-datacircle

Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website.

Our website: https://datacircle.dev

This package gives [Langroid](https://github.com/langroid/langroid) four tools that call Datacircle's public API, https://api.datacircle.dev/v1. You need no key and no account.

| Tool | Class | Gives | Call |
| --- | --- | --- | --- |
| `datacircle_list_apis` | `DatacircleListApisTool` | Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan | `GET /apis` |
| `datacircle_best_plans` | `DatacircleBestPlansTool` | One API's plans, sorted by score out of 100, best first. Each plan comes with a rank and a price per 1,000 calls | `GET /apis/{slug}/best` |
| `datacircle_search_plans` | `DatacircleSearchPlansTool` | Plans that match a provider or plan name, on all APIs or on one API. You can sort them by score, provider or price | `GET /plans` |
| `datacircle_provider` | `DatacircleProviderTool` | The APIs a provider sells, and the provider's rank on each API | `GET /providers/{slug}` |

## Install

```bash
pip install langroid-datacircle
```

The package needs Langroid 0.59 or later and Python 3.11 or later.

## Give the tools to an agent

```python
import langroid as lr
from langroid_datacircle import datacircle_tools

agent = lr.ChatAgent(
    lr.ChatAgentConfig(
        name="Researcher",
        system_message="You find the best GTM APIs with Datacircle's tools.",
        handle_llm_no_tool="done",
    )
)
agent.enable_message(datacircle_tools())

task = lr.Task(agent, interactive=False)
result = task.run("Which email finder API is best for under $5 per 1,000?")
print(result.content)
```

Each tool is a `ToolMessage` class with its own `handle()`, so the agent needs no method of its own. The model picks a tool. The agent runs the tool and gives the model the tool's result. With `handle_llm_no_tool="done"`, the task ends on the model's first answer that calls no tool.

By default, Langroid shows the model each tool's JSON format in the system message. To send the tools through the model's own function calling, set `use_functions_api=True` and `use_tools=False` in `ChatAgentConfig`. The tools work both ways.

To add the tools beside your own, list them: `agent.enable_message([MyTool, *datacircle_tools()])`.

To give only some of the tools, name them: `datacircle_tools(["datacircle_best_plans"])`. You can also pass the classes: `agent.enable_message(DatacircleBestPlansTool)`.

## Call a tool yourself

`handle()` returns a tool's output for the model, as JSON text:

```python
from langroid_datacircle import DatacircleBestPlansTool

print(DatacircleBestPlansTool(slug="email-finder", limit=3).handle())
```

The functions `list_apis`, `best_plans`, `search_plans` and `provider` return each tool's output as Python dicts.

## Tool output for the model

Each result is our API's answer as JSON text. Each plan comes with a rank, provider, plan, score, price per 1,000 (`perThousand`, in dollars) and a page on datacircle.dev. That page lists every field.

You can give a provider's name in place of a slug. The tool turns `Bright Data` into `bright-data`.

Pass an unknown slug and the model gets `{"error": ...}` with the API's error message. The error message for an unknown API slug lists every valid slug. The model can then pick one and call the tool again. The tool checks each argument from the model before the API call. For a number out of range, Langroid sends the model an error message. The tool makes no API call.

## Network

Each tool call makes one HTTPS GET request to https://api.datacircle.dev/v1 and no other network calls. In an async task (`task.run_async`), the request runs in a thread, so the task keeps running. The request holds only the tool's own arguments. The API takes up to 60 calls a minute from one IP address. If the API says to wait, the tool waits up to a minute. The tool waits at most once per call. All plans are in one file at https://datacircle.dev/datacircle.json.

## Links

- Datacircle: https://datacircle.dev
- The API: https://datacircle.dev/api
- The API's spec: https://api.datacircle.dev/v1/openapi.json
- What each key means: https://datacircle.dev/fields

MIT license.
