llama-cpp-python-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 llama-cpp-python four tools that call Datacircle's open API, https://api.datacircle.dev/v1. You pass the four tools to Llama.create_chat_completion() or to llama-cpp-python's OpenAI-compatible server. The package then runs each tool call the model returns. You need no key and no account.
| Tool | What the tool gives | Call |
|---|---|---|
datacircle_list_apis |
Every GTM API on Datacircle, with the API's slug, number of plans, number of providers and best plan | GET /apis |
datacircle_best_plans |
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 |
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 |
The APIs a provider sells, and the provider's rank on each API | GET /providers/{slug} |
Install
pip install llama-cpp-python-datacircle
llama-cpp-python-datacircle works with any version of llama-cpp-python, on Python 3.9 and later. The package does not import llama_cpp.
Use the tools with the model's own chat template
Most GGUF models come with a chat template. llama-cpp-python uses that template when you give no chat_format. Some chat templates take tools. With one of those templates, the model writes each tool call in the text of the reply. call_all() reads those calls and gives you the tool messages to send back:
from llama_cpp import Llama
from llama_cpp_datacircle import call_all, datacircle_tools
llm = Llama(model_path="qwen2.5-3b-instruct-q4_k_m.gguf", n_ctx=8192)
messages = [{"role": "user", "content": "Who are the 3 best providers for the email-finder API?"}]
reply = llm.create_chat_completion(messages=messages, tools=datacircle_tools())
while tool_messages := call_all(reply):
messages.append(reply["choices"][0]["message"])
messages.extend(tool_messages)
reply = llm.create_chat_completion(messages=messages, tools=datacircle_tools())
print(reply["choices"][0]["message"]["content"])
On each new call, the model's chat template puts each tool message in the prompt. We tested this loop with Qwen 2.5 (3B) and Qwen 3 (1.7B). Qwen writes each call in a <tool_call> block. Llama 3.2 writes calls as JSON. call_all() reads both formats.
Use the tools with chatml-function-calling
With chat_format="chatml-function-calling", llama-cpp-python puts the model's tool calls in the reply's tool_calls. call_all() runs those calls like calls from any other chat format. In llama-cpp-python 0.3.38, chatml-function-calling leaves tool messages out of the prompt. So the model never reads the tool's answer. To let the model read tool answers, use the model's own chat template.
To make the model call one tool, name the tool in tool_choice. Naming a tool works with any chat format. llama-cpp-python then makes the model write only the tool's arguments. The call comes in tool_calls:
reply = llm.create_chat_completion(
messages=messages,
tools=datacircle_tools(),
tool_choice={"type": "function", "function": {"name": "datacircle_best_plans"}},
)
messages.append(reply["choices"][0]["message"])
messages.extend(call_all(reply))
Use the Datacircle tools beside your own tools
You can put the Datacircle tools in the same list as yours: tools=[*datacircle_tools(), my_tool].
tool_calls() gives every call in a reply, including calls to your own tools. call() runs one call. For your own tools, call() returns None. Your code then runs the tool itself:
from llama_cpp_datacircle import call, tool_calls
calls = tool_calls(reply)
messages.append(reply["choices"][0]["message"])
for tool_call in calls:
messages.append(call(tool_call) or my_run_tool(tool_call))
Each call is an OpenAI-format tool call with an id. Each tool message has role: "tool", the call's id in tool_call_id, and the answer as JSON text in content.
To give the model only some of the tools, list their names: datacircle_tools(["datacircle_best_plans"]).
Use the tools with the OpenAI-compatible server
Start llama-cpp-python's server, then call the server with the OpenAI client. call_all() reads the reply from the OpenAI client:
pip install 'llama-cpp-python[server]' openai
python -m llama_cpp.server --model qwen2.5-3b-instruct-q4_k_m.gguf --n_ctx 8192
from openai import OpenAI
from llama_cpp_datacircle import call_all, datacircle_tools
client = OpenAI(base_url="http://localhost:8000/v1", api_key="none")
messages = [{"role": "user", "content": "Who are the 3 best providers for the email-finder API?"}]
reply = client.chat.completions.create(model="local", messages=messages, tools=datacircle_tools())
while tool_messages := call_all(reply):
messages.append(reply.choices[0].message.model_dump(exclude_none=True))
messages.extend(tool_messages)
reply = client.chat.completions.create(model="local", messages=messages, tools=datacircle_tools())
print(reply.choices[0].message.content)
Call a tool yourself
You can call each tool without a model. You get the JSON text of the tool's answer:
import json
from llama_cpp_datacircle import run
answer = json.loads(run("datacircle_best_plans", {"slug": "email-finder", "limit": 3}))
print(answer["plans"])
What the model reads
Each tool gives the model a JSON object as 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.
The tool returns {"error": "..."} with the API's message when the API gives no data, such as for an unknown slug. The error for an unknown API slug lists every valid slug. The tool checks each number from the model first. For a number out of range, the tool returns {"error": "..."} and makes no API call. If the network fails, the tool returns {"error": "..."} with the network error's message. The model can then call the tool again.
Network
Your model runs on your machine. Each tool call makes one HTTPS GET request to https://api.datacircle.dev/v1 and nothing else. The request holds only the tool's own arguments: no key and nothing from your chats. The API takes up to 60 calls a minute from one IP address. The API can ask the tool to wait. The tool then waits once, for a minute at most. Each call uses only Python's standard library. Nothing goes to disk.
Links
- Datacircle: https://datacircle.dev
- The API: https://datacircle.dev/api
- The API's spec: https://api.datacircle.dev/v1/openapi.json
- Every field of a plan: https://datacircle.dev/fields
MIT license.
Metadata
Release files for llama-cpp-python-datacircle 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_cpp_python_datacircle-0.1.0.tar.gz | 14.9 kB | Without provenance | Details for llama_cpp_python_datacircle-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_cpp_python_datacircle-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for llama_cpp_python_datacircle-0.1.0-py3-none-any.whl |
Total release size: 27.3 kB
Release files / llama_cpp_python_datacircle-0.1.0.tar.gz
| Download URL | llama_cpp_python_datacircle-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59007ca982ba573f51f2b7f72d2ccea3df1831e728142bd09ceabedbcf7e7beb
|
|
BLAKE2b-256 checksum How to use checksums |
c8c5e2b004e7ce9489643ea001fbd60adf3d869cc268b054505cf637f6a1d44b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / llama_cpp_python_datacircle-0.1.0-py3-none-any.whl
| Download URL | llama_cpp_python_datacircle-0.1.0-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
113e6c4d0e787803d070f8367a6b0bf3aa2d87a2b983e03f5b899229715f374a
|
|
BLAKE2b-256 checksum How to use checksums |
5d6ede637b95746450ef94696e7b30a7cfb3b0e19ac7c9a04d1fc65badcfdda8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for llama-cpp-python-datacircle 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.