Skip to main content

ads4gpts-langgraph-agent

ADS4GPTs LangGraph agent. Integrate Ads into AI Agents and monetize.

Overview

The ads4gpts-langgraph-agent package provides a LangGraph agent that integrates advertising capabilities into AI agents. This allows for the seamless inclusion of promotional content within AI-driven conversations, enabling monetization opportunities.

The package is a specific implementation for Inline Sponsored Response Ads, which is one format that ADS4GPTs offer.

If you find this cool please give us a star ⭐️

GitHub Stars

Star ⭐️ the general ADS4GPTs tool monorepo

GitHub Stars

Star ⭐️ the general ADS4GPTs open standards

GitHub Stars

Features

  • Contextual Ad Integration: Ads are integrated into conversations based on the context, ensuring relevance and engagement.
  • Customizable UX: Control where and how the ads are integrated within the graph.
  • Personalization & Context Blending: Make the ads desirable and relevant to increase User retention.
  • Privacy First: All sensitive data are being processed within your graph.
  • Support for Multiple LLM Providers: Compatible with OpenAI, Anthropic, and Groq models.
  • Logging: Configurable logging for monitoring and debugging.

Installation

To install the package, use pip or any other package manager:

pip install ads4gpts-langgraph-agent

Usage

The ads4gpts-langgraph-agent is meant to be part of a single or multi-agent architectures, where the application aims to monetize with advertising. Key differentiator from all other solutions is that the Ad integration becomes part of the AI application UX.

You can control the Ad placement deterministically by introducing the ads4gpts-langgraph-agent as a node in the LangGraph graph:

from langgraph.graph import StateGraph, START, END
# State needs to have a messages field
# ConfigSchema needs to have gpt_id and session_id fields
from your_repo import ConfigSchema, State 
from ads4gpts_langgraph_agent import make_ads4gpts_langgraph_agent

graph_builder = StateGraph(State, ConfigSchema)
graph_builder.add_node("ads4gpts_node", make_ads4gpts_langgraph_agent())

Follow the subgraph_example in the examples folder for a complete implementation of this approach.

On the other hand you let other agents call the ads4gpts-langgraph-agent autonomously through tool execution:

from langgraph.graph import StateGraph, START, END
# State needs to have a messages field
# ConfigSchema needs to have gpt_id and session_id fields
from your_repo import ConfigSchema, State 
from ads4gpts_langgraph_agent import make_ads4gpts_langgraph_agent, make_handoff_tool

ads4gpts_agent =  make_ads4gpts_langgraph_agent()
ads4gpts_tool = make_handoff_tool(ads4gpts_agent)

Follow the tool_example in the examples folder for a complete implementation of the tool approach.

Configuration

The agent requires several configuration parameters, which can be provided through environment variables or directly in the code through the make_ads4gpts_langgraph_agent constructor function:

  • ADS4GPTS_API_KEY: API key for ADS4GPTs.
  • ADS4GPTS_BASE_URL: Base URL for ADS4GPTs API. You can omit that to use the default settings.
  • ADS4GPTS_ADS_ENDPOINT: Endpoint for fetching ads. You can omit that to use the default settings.
  • PROVIDER: LLM provider (e.g., openai, anthropic, groq).
  • {PROVIDER}_API_KEY: API key for the selected LLM provider e.g. OPENAI_API_KEY.

Testing

To run the tests, use the following command:

pytest tests/

License

This project is licensed under the GNU AGPLv3 License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Contact

For any questions or inquiries, please contact the ADS4GPTs team at contact@ads4gpts.com

Release files for ads4gpts-langgraph-agent 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ads4gpts-langgraph-agent 0.1.10
File Size Uploaded
ads4gpts_langgraph_agent-0.1.10.tar.gz 22.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ads4gpts-langgraph-agent 0.1.10
File Interpreter ABI Platform
ads4gpts_langgraph_agent-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 43.4 kB

Release files / ads4gpts_langgraph_agent-0.1.10.tar.gz

Download URL ads4gpts_langgraph_agent-0.1.10.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
346666c519c675059fbbb77f989897d2c2443aaa73f30351b9c15f80deff786d
BLAKE2b-256 checksum
How to use checksums
9c7a89dc1fb1bfca635242b565526cba51b9fa541bbbdfe16f6d6563994e8ed6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / ads4gpts_langgraph_agent-0.1.10-py3-none-any.whl

Download URL ads4gpts_langgraph_agent-0.1.10-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e4930b0f13e584a0180d818cdd597d4a239316e2b5fe59015560acf2182a82cc
BLAKE2b-256 checksum
How to use checksums
e1eb43e97a188cf6aab731c2a18e5449a299ee446ad3248dc1514478c58d76bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page