llama-index-tools-playgrounds


Namellama-index-tools-playgrounds JSON
Version 0.1.3 PyPI version JSON
download
home_page
Summaryllama-index tools playgrounds integration
upload_time2024-02-21 22:25:30
maintainertachi
docs_urlNone
authorYour Name
requires_python>=3.8.1,<4.0
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

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 import OpenAIAgent
from llama_index.tools.playgrounds_subgraph_connector 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 import OpenAIAgent
from llama_index.tools.playgrounds_subgraph_inspector 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/tree/main/llama_index) and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "llama-index-tools-playgrounds",
    "maintainer": "tachi",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0",
    "maintainer_email": "",
    "keywords": "blockchain,decentralized,graphql,playgroundsapi,subgraph,thegraph",
    "author": "Your Name",
    "author_email": "you@example.com",
    "download_url": "https://files.pythonhosted.org/packages/81/1b/5f2c9d2df8c2cbcd7a144e79ae631eb4d42a56ebe5be87957bad6e2036ec/llama_index_tools_playgrounds-0.1.3.tar.gz",
    "platform": null,
    "description": "# Playgrounds Tool Specs\n\n## playgrounds_subgraph_connector\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 import OpenAIAgent\nfrom llama_index.tools.playgrounds_subgraph_connector import (\n    PlaygroundsSubgraphConnectorToolSpec,\n)\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 import OpenAIAgent\nfrom llama_index.tools.playgrounds_subgraph_inspector import (\n    PlaygroundsSubgraphInspectorToolSpec,\n)\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/tree/main/llama_index) and/or subsequently used as a Tool in a [LangChain](https://github.com/hwchase17/langchain) Agent.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "llama-index tools playgrounds integration",
    "version": "0.1.3",
    "project_urls": null,
    "split_keywords": [
        "blockchain",
        "decentralized",
        "graphql",
        "playgroundsapi",
        "subgraph",
        "thegraph"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a9596bd931f53022d91885df446f5307877c13492f4d1e2e74c5d89b93fc7f8",
                "md5": "3010147926a13075fb2ae8f7d85281b0",
                "sha256": "67166241b4d10110ee5903a1d6b501f7a8f26d9c1071254c8ad8c3bd36995d54"
            },
            "downloads": -1,
            "filename": "llama_index_tools_playgrounds-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3010147926a13075fb2ae8f7d85281b0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0",
            "size": 8029,
            "upload_time": "2024-02-21T22:25:27",
            "upload_time_iso_8601": "2024-02-21T22:25:27.706930Z",
            "url": "https://files.pythonhosted.org/packages/9a/95/96bd931f53022d91885df446f5307877c13492f4d1e2e74c5d89b93fc7f8/llama_index_tools_playgrounds-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "811b5f2c9d2df8c2cbcd7a144e79ae631eb4d42a56ebe5be87957bad6e2036ec",
                "md5": "36d85c1a29a01afa77e7e878386c0980",
                "sha256": "0a75f5cebf30e50293efe59270e6fe423f818dfec09d4dfa61a8d7627726f496"
            },
            "downloads": -1,
            "filename": "llama_index_tools_playgrounds-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "36d85c1a29a01afa77e7e878386c0980",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0",
            "size": 7355,
            "upload_time": "2024-02-21T22:25:30",
            "upload_time_iso_8601": "2024-02-21T22:25:30.344793Z",
            "url": "https://files.pythonhosted.org/packages/81/1b/5f2c9d2df8c2cbcd7a144e79ae631eb4d42a56ebe5be87957bad6e2036ec/llama_index_tools_playgrounds-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-21 22:25:30",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "llama-index-tools-playgrounds"
}
        
Elapsed time: 0.18736s