Skip to content

About

A Semantic Kernel plugin for the Datacircle API: find the best GTM APIs

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

semantic-kernel-datacircle

Find the best GTM APIs. We benchmark all the GTM APIs and we put the results on our website: https://datacircle.dev

This package is a Semantic Kernel plugin on Datacircle's open API, https://api.datacircle.dev/v1. You need no key and no account.

pip install semantic-kernel-datacircle
Function What it gives Call
list_apis Every GTM API on Datacircle, with its slug, number of plans and providers, and its best plan GET /apis
best_plans One API's plans, best first by score out of 100, each with its rank and price per 1,000 calls GET /apis/{slug}/best
search_plans Plans by provider or plan name, on every API or one, sorted by score, provider or price GET /plans
provider The APIs a provider sells and its rank on each GET /providers/{slug}

Use

With an agent:

import asyncio

from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion
from semantic_kernel_datacircle import DatacirclePlugin

agent = ChatCompletionAgent(
    service=OpenAIChatCompletion(),
    name="GTMAssistant",
    instructions="Answer from the Datacircle functions.",
    plugins=[DatacirclePlugin()],
)


async def main():
    response = await agent.get_response(messages="Which email finder API is best for under $5 per 1,000?")
    print(response)


asyncio.run(main())

Or on a kernel, with auto function calling:

from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import FunctionChoiceBehavior
from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.functions import KernelArguments
from semantic_kernel_datacircle import DatacirclePlugin

kernel = Kernel()
kernel.add_service(OpenAIChatCompletion())
kernel.add_plugin(DatacirclePlugin(), plugin_name="datacircle")

settings = OpenAIChatPromptExecutionSettings(function_choice_behavior=FunctionChoiceBehavior.Auto())
result = await kernel.invoke_prompt("Who sells the cheapest Hunter plan?", arguments=KernelArguments(settings=settings))

Any chat completion service with function calling works. Each function is a @kernel_function that gives the model the API's answer as JSON. A function can also be called through the kernel itself:

await kernel.invoke(plugin_name="datacircle", function_name="best_plans", arguments=KernelArguments(slug="email-finder", limit=3))

or as a plain function that gives a dict:

from semantic_kernel_datacircle import best_plans

best_plans(slug="email-finder", limit=3)

Each plan comes with its rank, provider, plan, score, price per 1,000 (perThousand, in dollars) and its page on datacircle.dev, which lists every field. An unknown slug or a value out of range comes back as {"error": ...} with the API's words (an unknown API's answer lists every slug), so the model can call again.

Network

Each call makes one HTTPS GET to https://api.datacircle.dev/v1 with the function's arguments and nothing else. The API takes up to 60 calls a minute from one address; the functions wait once, a minute at most, when it asks them to. DatacirclePlugin(timeout=10) sets how long a call may take. Every plan is also one file at https://datacircle.dev/datacircle.json.

Links

MIT license.

About

A Semantic Kernel plugin for the Datacircle API: find the best GTM APIs

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages