llama-index-tools-playgrounds


Namellama-index-tools-playgrounds JSON
Version 0.3.0 PyPI version JSON
download
home_pageNone
Summaryllama-index tools playgrounds integration
upload_time2024-11-17 23:07:25
maintainertachi
docs_urlNone
authorYour Name
requires_python<4.0,>=3.9
licenseMIT
keywords blockchain decentralized graphql playgroundsapi subgraph thegraph
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Playgrounds Tool Specs

## playgrounds_subgraph_connector

```bash
pip install llama-index-tools-playgrounds
```

Playgrounds API is a service provided by [Playgrounds Analytics](https://playgrounds.network) to streamline interfacing with decentralized subgraphs (indexed blockchain datasets).

The `PlaygroundsSubgraphConnector` is a tool designed for LLM agents to seamlessly interface with and query subgraphs on The Graph's decentralized network via Playgrounds API.

This tool is specifically designed to be used alongside [Llama index](https://github.com/jerryjliu/llama_index) or [langchain](https://python.langchain.com/docs/modules/agents/tools/custom_tools)

- To learn more about Playgrounds API, please visit our website : https://playgrounds.network/
- Obtain you Playgrounds API Key and get started for free here: https://app.playgrounds.network/signup
- Find any Subgraph (dataset) you need here: https://thegraph.com/explorer

### Advantages of this tool:

- **Easy access to Decentralized Subgraphs (Datasets)**: No need for wallet or GRT management.
- **LLM x Blockchain data**: Develop Ai applications that leverage blockchain data seamlessly.

### Basic Usage:

To utilize the tool, simply initialize it with the appropriate `identifier` (Subgraph ID or Deployment ID) and `api_key`. Optionally, specify if you're using a deployment ID.

```python
import openai
from llama_index.agent.openai import OpenAIAgent
from llama_index.tools.playgrounds import PlaygroundsSubgraphConnectorToolSpec


def simple_test():
    """
    Run a simple test querying the financialsDailySnapshots from Uniswap V3 subgraph using OpenAIAgent and Playgrounds API.
    """
    # Set the OpenAI API key
    openai.api_key = "YOUR_OPENAI_API_KEY"

    # Initialize the tool specification with the subgraph's identifier and the Playgrounds API key
    connector_spec = PlaygroundsSubgraphConnectorToolSpec(
        identifier="YOUR_SUBGRAPH_OR_DEPLOYMENT_IDENTIFIER",
        api_key="YOUR_PLAYGROUNDS_API_KEY",
        use_deployment_id=False,  # Set to True if using Deployment ID
    )

    # Setup agent with the tool
    agent = OpenAIAgent.from_tools(connector_spec.to_tool_list())

    # Make a query using the agent
    response = agent.chat(
        "query the financialsDailySnapshots for id, timestamp, totalValueLockedUSD, and dailyVolumeUSD. only give me the first 2 rows"
    )
    print(response)


if __name__ == "__main__":
    simple_test()
```

Visit here for more in-depth [Examples](https://github.com/Tachikoma000/playgrounds_subgraph_connector/blob/main/connector_agent_tool/examples.ipynb).

This loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/tree/main/llama_index)
and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.

## playgrounds_subgraph_inspector

Playgrounds API is a service provided by [Playgrounds Analytics](https://playgrounds.network) to facilitate interactions with decentralized subgraphs (indexed blockchain datasets).

The `PlaygroundsSubgraphInspectorToolSpec` is a tool designed for LLM agents to introspect and understand the schema of subgraphs on The Graph's decentralized network via the Playgrounds API.

This tool is specifically designed to be used alongside [Llama index](https://github.com/jerryjliu/llama_index) or [langchain](https://python.langchain.com/docs/modules/agents/tools/custom_tools).

- To learn more about Playgrounds API, please visit our website: [Playgrounds Network](https://playgrounds.network/)
- Obtain your Playgrounds API Key and get started for free [here](https://app.playgrounds.network/signup).
- Discover any Subgraph (dataset) you need [here](https://thegraph.com/explorer).

### Advantages of this tool:

- **Introspection of Decentralized Subgraphs (Datasets)**: Understand the schema of any subgraph without hassle.
- **LLM x Blockchain Data**: Develop AI applications that leverage introspective insights from blockchain data.

### Basic Usage:

To utilize the tool, initialize it with the appropriate `identifier` (Subgraph ID or Deployment ID), `api_key`, and specify if you're using a deployment ID.

```python
import openai
from llama_index.agent.openai import OpenAIAgent
from llama_index.tools.playgrounds import PlaygroundsSubgraphInspectorToolSpec


def inspect_subgraph(
    openai_api_key: str,
    playgrounds_api_key: str,
    identifier: str,
    use_deployment_id: bool,
    user_prompt: str,
):
    """
    Introspect a subgraph using OpenAIAgent and Playgrounds API with the provided parameters.

    Args:
        openai_api_key (str): API key for OpenAI.
        playgrounds_api_key (str): API key for Playgrounds.
        identifier (str): Identifier for the subgraph or deployment.
        use_deployment_id (bool): If True, uses deployment ID in the URL.
        user_prompt (str): User's question or prompt for the agent.

    Returns:
        str: Agent's response.
    """
    # Set the OpenAI API key
    openai.api_key = openai_api_key

    # Initialize the inspector with the provided parameters
    inspector_spec = PlaygroundsSubgraphInspectorToolSpec(
        identifier=identifier,
        api_key=playgrounds_api_key,
        use_deployment_id=use_deployment_id,
    )

    # Integrate the tool with the agent
    agent = OpenAIAgent.from_tools(inspector_spec.to_tool_list())

    # Send the user prompt to the agent
    response = agent.chat(user_prompt)
    return response


if __name__ == "__main__":
    query = inspect_subgraph(
        openai_api_key="YOUR_OPENAI_API_KEY",
        playgrounds_api_key="YOUR_PLAYGROUNDS_API_KEY",
        identifier="YOUR_SUBGRAPH_OR_DEPLOYMENT_IDENTIFIER",
        use_deployment_id=False,
        user_prompt="Which entities will help me understand the usage of Uniswap V3?",
    )
```

Visit here for more in-depth [Examples](https://github.com/Tachikoma000/playgrounds_subgraph_connector/blob/main/introspector_agent_tool/examples.ipynb).

This inspector is designed to be used as a way to understand the schema of subgraphs and subgraph data being loaded into [LlamaIndex](https://github.com/run-llama/llama_index/).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "llama-index-tools-playgrounds",
    "maintainer": "tachi",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": "blockchain, decentralized, graphql, playgroundsapi, subgraph, thegraph",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/14/ce/20a4bd9ab153a7881afec9ba9debc93cbc66eae8cf2829ef7bc64d6d399c/llama_index_tools_playgrounds-0.3.0.tar.gz",
    "platform": null,
    "description": "# Playgrounds Tool Specs\n\n## playgrounds_subgraph_connector\n\n```bash\npip install llama-index-tools-playgrounds\n```\n\nPlaygrounds API is a service provided by [Playgrounds Analytics](https://playgrounds.network) to streamline interfacing with decentralized subgraphs (indexed blockchain datasets).\n\nThe `PlaygroundsSubgraphConnector` is a tool designed for LLM agents to seamlessly interface with and query subgraphs on The Graph's decentralized network via Playgrounds API.\n\nThis tool is specifically designed to be used alongside [Llama index](https://github.com/jerryjliu/llama_index) or [langchain](https://python.langchain.com/docs/modules/agents/tools/custom_tools)\n\n- To learn more about Playgrounds API, please visit our website : https://playgrounds.network/\n- Obtain you Playgrounds API Key and get started for free here: https://app.playgrounds.network/signup\n- Find any Subgraph (dataset) you need here: https://thegraph.com/explorer\n\n### Advantages of this tool:\n\n- **Easy access to Decentralized Subgraphs (Datasets)**: No need for wallet or GRT management.\n- **LLM x Blockchain data**: Develop Ai applications that leverage blockchain data seamlessly.\n\n### Basic Usage:\n\nTo utilize the tool, simply initialize it with the appropriate `identifier` (Subgraph ID or Deployment ID) and `api_key`. Optionally, specify if you're using a deployment ID.\n\n```python\nimport openai\nfrom llama_index.agent.openai import OpenAIAgent\nfrom llama_index.tools.playgrounds import PlaygroundsSubgraphConnectorToolSpec\n\n\ndef simple_test():\n    \"\"\"\n    Run a simple test querying the financialsDailySnapshots from Uniswap V3 subgraph using OpenAIAgent and Playgrounds API.\n    \"\"\"\n    # Set the OpenAI API key\n    openai.api_key = \"YOUR_OPENAI_API_KEY\"\n\n    # Initialize the tool specification with the subgraph's identifier and the Playgrounds API key\n    connector_spec = PlaygroundsSubgraphConnectorToolSpec(\n        identifier=\"YOUR_SUBGRAPH_OR_DEPLOYMENT_IDENTIFIER\",\n        api_key=\"YOUR_PLAYGROUNDS_API_KEY\",\n        use_deployment_id=False,  # Set to True if using Deployment ID\n    )\n\n    # Setup agent with the tool\n    agent = OpenAIAgent.from_tools(connector_spec.to_tool_list())\n\n    # Make a query using the agent\n    response = agent.chat(\n        \"query the financialsDailySnapshots for id, timestamp, totalValueLockedUSD, and dailyVolumeUSD. only give me the first 2 rows\"\n    )\n    print(response)\n\n\nif __name__ == \"__main__\":\n    simple_test()\n```\n\nVisit here for more in-depth [Examples](https://github.com/Tachikoma000/playgrounds_subgraph_connector/blob/main/connector_agent_tool/examples.ipynb).\n\nThis loader is designed to be used as a way to load data into [LlamaIndex](https://github.com/run-llama/llama_index/tree/main/llama_index)\nand/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.\n\n## playgrounds_subgraph_inspector\n\nPlaygrounds API is a service provided by [Playgrounds Analytics](https://playgrounds.network) to facilitate interactions with decentralized subgraphs (indexed blockchain datasets).\n\nThe `PlaygroundsSubgraphInspectorToolSpec` is a tool designed for LLM agents to introspect and understand the schema of subgraphs on The Graph's decentralized network via the Playgrounds API.\n\nThis tool is specifically designed to be used alongside [Llama index](https://github.com/jerryjliu/llama_index) or [langchain](https://python.langchain.com/docs/modules/agents/tools/custom_tools).\n\n- To learn more about Playgrounds API, please visit our website: [Playgrounds Network](https://playgrounds.network/)\n- Obtain your Playgrounds API Key and get started for free [here](https://app.playgrounds.network/signup).\n- Discover any Subgraph (dataset) you need [here](https://thegraph.com/explorer).\n\n### Advantages of this tool:\n\n- **Introspection of Decentralized Subgraphs (Datasets)**: Understand the schema of any subgraph without hassle.\n- **LLM x Blockchain Data**: Develop AI applications that leverage introspective insights from blockchain data.\n\n### Basic Usage:\n\nTo utilize the tool, initialize it with the appropriate `identifier` (Subgraph ID or Deployment ID), `api_key`, and specify if you're using a deployment ID.\n\n```python\nimport openai\nfrom llama_index.agent.openai import OpenAIAgent\nfrom llama_index.tools.playgrounds import PlaygroundsSubgraphInspectorToolSpec\n\n\ndef inspect_subgraph(\n    openai_api_key: str,\n    playgrounds_api_key: str,\n    identifier: str,\n    use_deployment_id: bool,\n    user_prompt: str,\n):\n    \"\"\"\n    Introspect a subgraph using OpenAIAgent and Playgrounds API with the provided parameters.\n\n    Args:\n        openai_api_key (str): API key for OpenAI.\n        playgrounds_api_key (str): API key for Playgrounds.\n        identifier (str): Identifier for the subgraph or deployment.\n        use_deployment_id (bool): If True, uses deployment ID in the URL.\n        user_prompt (str): User's question or prompt for the agent.\n\n    Returns:\n        str: Agent's response.\n    \"\"\"\n    # Set the OpenAI API key\n    openai.api_key = openai_api_key\n\n    # Initialize the inspector with the provided parameters\n    inspector_spec = PlaygroundsSubgraphInspectorToolSpec(\n        identifier=identifier,\n        api_key=playgrounds_api_key,\n        use_deployment_id=use_deployment_id,\n    )\n\n    # Integrate the tool with the agent\n    agent = OpenAIAgent.from_tools(inspector_spec.to_tool_list())\n\n    # Send the user prompt to the agent\n    response = agent.chat(user_prompt)\n    return response\n\n\nif __name__ == \"__main__\":\n    query = inspect_subgraph(\n        openai_api_key=\"YOUR_OPENAI_API_KEY\",\n        playgrounds_api_key=\"YOUR_PLAYGROUNDS_API_KEY\",\n        identifier=\"YOUR_SUBGRAPH_OR_DEPLOYMENT_IDENTIFIER\",\n        use_deployment_id=False,\n        user_prompt=\"Which entities will help me understand the usage of Uniswap V3?\",\n    )\n```\n\nVisit here for more in-depth [Examples](https://github.com/Tachikoma000/playgrounds_subgraph_connector/blob/main/introspector_agent_tool/examples.ipynb).\n\nThis inspector is designed to be used as a way to understand the schema of subgraphs and subgraph data being loaded into [LlamaIndex](https://github.com/run-llama/llama_index/).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index tools playgrounds integration",
    "version": "0.3.0",
    "project_urls": null,
    "split_keywords": [
        "blockchain",
        " decentralized",
        " graphql",
        " playgroundsapi",
        " subgraph",
        " thegraph"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6d91b9a4ab0ee44a8906072feaff685c3dab00c3b9186d15c2a26494f3614658",
                "md5": "6415bbdaf41cc3b59e910887d44c6b37",
                "sha256": "205bb97270ce86211bd0d64ea9fecaeb804792a2b1c383f9949115eac609e03c"
            },
            "downloads": -1,
            "filename": "llama_index_tools_playgrounds-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6415bbdaf41cc3b59e910887d44c6b37",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 8040,
            "upload_time": "2024-11-17T23:07:24",
            "upload_time_iso_8601": "2024-11-17T23:07:24.520156Z",
            "url": "https://files.pythonhosted.org/packages/6d/91/b9a4ab0ee44a8906072feaff685c3dab00c3b9186d15c2a26494f3614658/llama_index_tools_playgrounds-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "14ce20a4bd9ab153a7881afec9ba9debc93cbc66eae8cf2829ef7bc64d6d399c",
                "md5": "86c23087370fbb2b35a8c9893c624d87",
                "sha256": "9776ed032931aa86499b478f04f3d573ea120ee0566cfafef02069b183a16225"
            },
            "downloads": -1,
            "filename": "llama_index_tools_playgrounds-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "86c23087370fbb2b35a8c9893c624d87",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 7423,
            "upload_time": "2024-11-17T23:07:25",
            "upload_time_iso_8601": "2024-11-17T23:07:25.348436Z",
            "url": "https://files.pythonhosted.org/packages/14/ce/20a4bd9ab153a7881afec9ba9debc93cbc66eae8cf2829ef7bc64d6d399c/llama_index_tools_playgrounds-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-17 23:07:25",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-tools-playgrounds"
}
        
Elapsed time: 0.38436s