Skip to main content

Python SDK for integrating Ads4GPTs advertising logic into conversational AI applications via LangGraph agents

Project description

Ads4GPTs Core SDK

Python SDK for integrating with Ads4GPTs, the monetization backbone of the AI Native Internet.

Overview

The Ads4GPTs Core SDK provides the tools to configure your Integration Agent, connecting your AI application to the Ads4GPTs platform. Ad requests are initiated autonomously based on conversational context and user intent, with full support for streaming responses.

Installation

pip install ads4gpts-core

Requirements

  • Python 3.11 or higher
  • Active Ads4GPTs account with API credentials

Quick Start

1. Configure Environment Variables

export ADS4GPTS_AGENT_URL="https://your-agent-api.com"
export ADS4GPTS_GPT_ID="your-gpt-id"
export ADS4GPTS_API_KEY="your-api-key"
export ADS4GPTS_SSP_ID="your-ssp-id"

2. Basic Usage

from ads4gpts_core import invoke_integration_agent

# First conversation in a session
stream = invoke_integration_agent(
    user_input="What are the best noise-cancelling headphones under €200?",
    message_history=[],
    thread_id="thread_123",
    session_id="session_456",
)

# Process streaming response
async for chunk in stream:
    print(chunk)

3. Continuing a Conversation

# Subsequent messages in the same thread
stream = invoke_integration_agent(
    user_input="How about wireless options?",
    message_history=[
        {"role": "human", "content": "What are the best noise-cancelling headphones under €200?"},
        {"role": "ai", "content": "Here are some great options..."}
    ],
    thread_id="thread_123",
    session_id="session_456",
)

async for chunk in stream:
    print(chunk)

Stream Processing Utilities

Split Stream

Duplicate an async stream into two independent consumers:

from ads4gpts_core import split_stream

async def source_stream():
    for i in range(5):
        yield i

streams = split_stream(source_stream())

# Both consumers receive all chunks
async for chunk in streams['app_stream']:
    print(f"App: {chunk}")

async for chunk in streams['util_stream']:
    print(f"Util: {chunk}")

Merge Streams

Process two streams sequentially:

from ads4gpts_core import merge_streams

async def app_stream():
    for i in range(3):
        yield f"app_{i}"

async def ads_stream():
    for i in range(3):
        yield f"ads_{i}"

# Outputs: app_0, app_1, app_2, ads_0, ads_1, ads_2
async for chunk in merge_streams(app_stream(), ads_stream()):
    print(chunk)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ads4gpts_core-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ads4gpts_core-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file ads4gpts_core-0.1.1.tar.gz.

File metadata

  • Download URL: ads4gpts_core-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ads4gpts_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f7c6b8797395bba43b38a6cecc3b3a3125466ce9511eeffc22e4c27470eaaab3
MD5 7072a7ce35e55e297dea81e1bd6fa582
BLAKE2b-256 1ad626094e09ec5ea307e720ca2a0640f1fa8a036caff9d3f379bc0fbc9a25e9

See more details on using hashes here.

File details

Details for the file ads4gpts_core-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ads4gpts_core-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for ads4gpts_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b85fb5a527322b1f2f9edbe777310b0770afda8cb5f377fb019a736760086e6
MD5 46d1ae61a4d55ecbc6271e5687a7bc2c
BLAKE2b-256 ec9c43955c4ed108b028abcb8a6ec6ce48ed23e9e87a186ba229a977c9dcaf81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page