ads4gpts-langchain


Nameads4gpts-langchain JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://www.ads4gpts.com/
SummaryAds for AI applications. Enabling the Freemium model for the AI era.
upload_time2024-12-04 08:07:44
maintainerNone
docs_urlNone
authorIoannis Bakagiannis
requires_python<4.0,>=3.11
licenseGNU AGPLv3
keywords ads gpt llm freemium ai
VCS
bugtrack_url
requirements langchain langgraph httpx pydantic
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ads4GPTs Langchain Toolkit

This is the LangChain toolkit for Ads4GPTs.

A Python package that integrates Ads4GPTs functionalities into LangChain applications, allowing for seamless retrieval of relevant advertisements based on contextual input.

---

## Table of Contents

- [Introduction](#introduction)
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
  - [Prerequisites](#prerequisites)
  - [Environment Variables](#environment-variables)
  - [Initialization](#initialization)
  - [Examples](#examples)
- [API Reference](#api-reference)
  - [Ads4GPTsTool](#ads4gptstool)
  - [Ads4GPTsToolkit](#ads4gptstoolkit)
  - [get_ads4gpts_agent Function](#get_ads4gpts_agent-function)
- [Contributing](#contributing)
- [License](#license)
- [Contact](#contact)

---

## Introduction

**Ads4GPTs LangChain Integration** is a Python package designed to seamlessly incorporate Ads4GPTs functionalities into your LangChain applications. It provides tools and utilities to retrieve contextually relevant advertisements, leveraging the power of LangChain's agentic framework.

Whether you're building a chatbot, a recommendation system, or any application that can benefit from targeted ads, this package offers a robust and production-ready solution.

---

## Features

- **Easy Integration**: Quickly integrate ad retrieval capabilities into your LangChain agents.
- **Contextual Ad Retrieval**: Fetch relevant ads based on the provided context to enhance user engagement.
- **Asynchronous Support**: Both synchronous and asynchronous operations are supported for flexibility.
- **Robust Error Handling**: Comprehensive error handling and logging for reliable production deployments.

---

## Installation

### Using pip

You can install the package directly from PyPI:

```bash
pip install ads4gpts-langchain
```

### From Source

Alternatively, you can install the package from source:

``` bash
git clone https://github.com/ADS4GPTs/ads4gpts.git
cd ads4gpts/libs/python-sdk/ads4gpts-langchain
pip install .
```
## Usage

### Prerequisites

- Python 3.11+
- (Optional) OpenAI Account and API Key
  - In order to use the ads4gpts_agent you 
  - Sign up at OpenAI and obtain an API key.
- Ads4GPTs API Key
  - Obtain an API key for the Ads4GPTs service at https://www.ads4gpts.com


## Environment Variables

The package requires certain environment variables for API authentication:

- OPENAI_API_KEY: Your OpenAI API key.
- ADS4GPTS_API_KEY: Your Ads4GPTs API key.

Set them in your environment:
```bash
export OPENAI_API_KEY='your-openai-api-key'
export ADS4GPTS_API_KEY='your-ads4gpts-api-key'
```
Alternatively, you can pass the API keys directly when initializing classes or set up a .env file.

## Initialization

Import the necessary classes and functions in your Python script:

```python
from ads4gpts_langchain import Ads4GPTsTool, Ads4GPTsToolkit, get_ads4gpts_agent
```

## Examples

Example 1: Using Ads4GPTsTool Directly

```python
from ads4gpts_langchain import Ads4GPTsTool

# Instantiate the tool (API key retrieved from environment variable)
ads_tool = Ads4GPTsTool()

# Retrieve ads synchronously
ads = ads_tool._run(context="Looking for the latest smartphone deals", num_ads=2)
print(ads)

# Retrieve ads asynchronously
import asyncio

async def fetch_ads():
    ads = await ads_tool._arun(context="Best travel packages to Europe", num_ads=3)
    print(ads)

asyncio.run(fetch_ads())

from ads4gpts_langchain import Ads4GPTsToolkit

# Initialize the toolkit
toolkit = Ads4GPTsToolkit()

# Get the list of tools
tools = toolkit.get_tools()

# Use the tool from the toolkit
ads = tools[0]._run(context="Healthy recipes and cooking tips", num_ads=1)
print(ads)
```

Examples for using them in your LangChain and LangGraph application exist in the examples folder of the parent repo.

## Contributing

Contributions are welcome! Please follow these steps:
1. Fork the Repository: Click the "Fork" button at the top right of the repository page.
2. Clone Your Fork:
```bash
git clone git@github.com:ADS4GPTs/ads4gpts.git
```
3. Create a Branch:
``` bash
git checkout -b feature/your-feature-name
```
4. Make Changes: Implement your feature or bug fix.
5. Run Tests: Ensure all tests pass.
```bash
pip install pytest pytest-asyncio
python -m unittest discover tests
```
Formal tests are still under development.
6. Commit Changes:
```bash
git commit -am 'Add your commit message here'
```
7. Push to Your Fork:
```bash
git push origin feature/your-feature-name
```
8. Open a Pull Request: Navigate to the original repository and click "New pull request".

## License

This project is licensed under the License of the Ads4GPTs repository.

## Contact

- Author: Ioannis Bakagiannis
- Email: contact@ads4gpts.com
- GitHub: @ads4gpts

For issues and feature requests, please use the GitHub issues page.




            

Raw data

            {
    "_id": null,
    "home_page": "https://www.ads4gpts.com/",
    "name": "ads4gpts-langchain",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": null,
    "keywords": "ads, GPT, LLM, freemium, AI",
    "author": "Ioannis Bakagiannis",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ef/07/7661d900c0507310229ea8bdaf44061936ec3861764d58e4cf6efa052453/ads4gpts_langchain-0.1.3.tar.gz",
    "platform": null,
    "description": "# Ads4GPTs Langchain Toolkit\n\nThis is the LangChain toolkit for Ads4GPTs.\n\nA Python package that integrates Ads4GPTs functionalities into LangChain applications, allowing for seamless retrieval of relevant advertisements based on contextual input.\n\n---\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Prerequisites](#prerequisites)\n  - [Environment Variables](#environment-variables)\n  - [Initialization](#initialization)\n  - [Examples](#examples)\n- [API Reference](#api-reference)\n  - [Ads4GPTsTool](#ads4gptstool)\n  - [Ads4GPTsToolkit](#ads4gptstoolkit)\n  - [get_ads4gpts_agent Function](#get_ads4gpts_agent-function)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contact](#contact)\n\n---\n\n## Introduction\n\n**Ads4GPTs LangChain Integration** is a Python package designed to seamlessly incorporate Ads4GPTs functionalities into your LangChain applications. It provides tools and utilities to retrieve contextually relevant advertisements, leveraging the power of LangChain's agentic framework.\n\nWhether you're building a chatbot, a recommendation system, or any application that can benefit from targeted ads, this package offers a robust and production-ready solution.\n\n---\n\n## Features\n\n- **Easy Integration**: Quickly integrate ad retrieval capabilities into your LangChain agents.\n- **Contextual Ad Retrieval**: Fetch relevant ads based on the provided context to enhance user engagement.\n- **Asynchronous Support**: Both synchronous and asynchronous operations are supported for flexibility.\n- **Robust Error Handling**: Comprehensive error handling and logging for reliable production deployments.\n\n---\n\n## Installation\n\n### Using pip\n\nYou can install the package directly from PyPI:\n\n```bash\npip install ads4gpts-langchain\n```\n\n### From Source\n\nAlternatively, you can install the package from source:\n\n``` bash\ngit clone https://github.com/ADS4GPTs/ads4gpts.git\ncd ads4gpts/libs/python-sdk/ads4gpts-langchain\npip install .\n```\n## Usage\n\n### Prerequisites\n\n- Python 3.11+\n- (Optional) OpenAI Account and API Key\n  - In order to use the ads4gpts_agent you \n  - Sign up at OpenAI and obtain an API key.\n- Ads4GPTs API Key\n  - Obtain an API key for the Ads4GPTs service at https://www.ads4gpts.com\n\n\n## Environment Variables\n\nThe package requires certain environment variables for API authentication:\n\n- OPENAI_API_KEY: Your OpenAI API key.\n- ADS4GPTS_API_KEY: Your Ads4GPTs API key.\n\nSet them in your environment:\n```bash\nexport OPENAI_API_KEY='your-openai-api-key'\nexport ADS4GPTS_API_KEY='your-ads4gpts-api-key'\n```\nAlternatively, you can pass the API keys directly when initializing classes or set up a .env file.\n\n## Initialization\n\nImport the necessary classes and functions in your Python script:\n\n```python\nfrom ads4gpts_langchain import Ads4GPTsTool, Ads4GPTsToolkit, get_ads4gpts_agent\n```\n\n## Examples\n\nExample 1: Using Ads4GPTsTool Directly\n\n```python\nfrom ads4gpts_langchain import Ads4GPTsTool\n\n# Instantiate the tool (API key retrieved from environment variable)\nads_tool = Ads4GPTsTool()\n\n# Retrieve ads synchronously\nads = ads_tool._run(context=\"Looking for the latest smartphone deals\", num_ads=2)\nprint(ads)\n\n# Retrieve ads asynchronously\nimport asyncio\n\nasync def fetch_ads():\n    ads = await ads_tool._arun(context=\"Best travel packages to Europe\", num_ads=3)\n    print(ads)\n\nasyncio.run(fetch_ads())\n\nfrom ads4gpts_langchain import Ads4GPTsToolkit\n\n# Initialize the toolkit\ntoolkit = Ads4GPTsToolkit()\n\n# Get the list of tools\ntools = toolkit.get_tools()\n\n# Use the tool from the toolkit\nads = tools[0]._run(context=\"Healthy recipes and cooking tips\", num_ads=1)\nprint(ads)\n```\n\nExamples for using them in your LangChain and LangGraph application exist in the examples folder of the parent repo.\n\n## Contributing\n\nContributions are welcome! Please follow these steps:\n1. Fork the Repository: Click the \"Fork\" button at the top right of the repository page.\n2. Clone Your Fork:\n```bash\ngit clone git@github.com:ADS4GPTs/ads4gpts.git\n```\n3. Create a Branch:\n``` bash\ngit checkout -b feature/your-feature-name\n```\n4. Make Changes: Implement your feature or bug fix.\n5. Run Tests: Ensure all tests pass.\n```bash\npip install pytest pytest-asyncio\npython -m unittest discover tests\n```\nFormal tests are still under development.\n6. Commit Changes:\n```bash\ngit commit -am 'Add your commit message here'\n```\n7. Push to Your Fork:\n```bash\ngit push origin feature/your-feature-name\n```\n8. Open a Pull Request: Navigate to the original repository and click \"New pull request\".\n\n## License\n\nThis project is licensed under the License of the Ads4GPTs repository.\n\n## Contact\n\n- Author: Ioannis Bakagiannis\n- Email: contact@ads4gpts.com\n- GitHub: @ads4gpts\n\nFor issues and feature requests, please use the GitHub issues page.\n\n\n\n",
    "bugtrack_url": null,
    "license": "GNU AGPLv3",
    "summary": "Ads for AI applications. Enabling the Freemium model for the AI era.",
    "version": "0.1.3",
    "project_urls": {
        "Documentation": "https://github.com/ADS4GPTs/ads4gpts/libs/python-sdk/ads4gpts-langchain",
        "Homepage": "https://www.ads4gpts.com/",
        "Repository": "https://github.com/ADS4GPTs/ads4gpts/libs/python-sdk/ads4gpts-langchain"
    },
    "split_keywords": [
        "ads",
        " gpt",
        " llm",
        " freemium",
        " ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd18a9bc4e14c53ab9bec6e02e6766524d3fd71fc84a0a869810a2db1745e6c7",
                "md5": "8c74bfbab6381b42aef7ac24b29845ee",
                "sha256": "17ffbdf26b23476a6f80462351ece7f5df25642fd8c4074539cd381007b80c1b"
            },
            "downloads": -1,
            "filename": "ads4gpts_langchain-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c74bfbab6381b42aef7ac24b29845ee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 29686,
            "upload_time": "2024-12-04T08:07:43",
            "upload_time_iso_8601": "2024-12-04T08:07:43.019210Z",
            "url": "https://files.pythonhosted.org/packages/cd/18/a9bc4e14c53ab9bec6e02e6766524d3fd71fc84a0a869810a2db1745e6c7/ads4gpts_langchain-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ef077661d900c0507310229ea8bdaf44061936ec3861764d58e4cf6efa052453",
                "md5": "1fb01e7135f01711b51530b6607d1ca9",
                "sha256": "1fb24333304e867de51d38aed33a7fe6db6699c1d823b4eca88f62e995abd92d"
            },
            "downloads": -1,
            "filename": "ads4gpts_langchain-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "1fb01e7135f01711b51530b6607d1ca9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 26253,
            "upload_time": "2024-12-04T08:07:44",
            "upload_time_iso_8601": "2024-12-04T08:07:44.969841Z",
            "url": "https://files.pythonhosted.org/packages/ef/07/7661d900c0507310229ea8bdaf44061936ec3861764d58e4cf6efa052453/ads4gpts_langchain-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-04 08:07:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ADS4GPTs",
    "github_project": "ads4gpts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "langchain",
            "specs": []
        },
        {
            "name": "langgraph",
            "specs": []
        },
        {
            "name": "httpx",
            "specs": []
        },
        {
            "name": "pydantic",
            "specs": []
        }
    ],
    "lcname": "ads4gpts-langchain"
}
        
Elapsed time: 0.50974s