Package: llama-index-tools-playgrounds
Playgrounds Tool Specsplaygrounds_subgraph_connectorPlaygrounds API is a service provided byPlaygrounds Analyticsto streamline interfacing with decentralized subgraphs (indexed blockchain datasets).ThePlaygroundsSubgraphConnectoris 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 alongsideLlama indexorlangchainTo 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/signupFind any Subgraph (dataset) you need here:https://thegraph.com/explorerAdvantages 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 appropriateidentifier(Subgraph ID or Deployment ID) andapi_key. Optionally, specify if you're using a deployment ID.importopenaifromllama_index.agentimportOpenAIAgentfromllama_index.tools.playgrounds_subgraph_connectorimport(PlaygroundsSubgraphConnectorToolSpec,)defsimple_test():"""Run a simple test querying the financialsDailySnapshots from Uniswap V3 subgraph using OpenAIAgent and Playgrounds API."""# Set the OpenAI API keyopenai.api_key="YOUR_OPENAI_API_KEY"# Initialize the tool specification with the subgraph's identifier and the Playgrounds API keyconnector_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 toolagent=OpenAIAgent.from_tools(connector_spec.to_tool_list())# Make a query using the agentresponse=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-depthExamples.This loader is designed to be used as a way to load data intoLlamaIndexand/or subsequently used as a Tool in aLangChainAgent.playgrounds_subgraph_inspectorPlaygrounds API is a service provided byPlaygrounds Analyticsto facilitate interactions with decentralized subgraphs (indexed blockchain datasets).ThePlaygroundsSubgraphInspectorToolSpecis 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 alongsideLlama indexorlangchain.To learn more about Playgrounds API, please visit our website:Playgrounds NetworkObtain your Playgrounds API Key and get started for freehere.Discover any Subgraph (dataset) you needhere.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 appropriateidentifier(Subgraph ID or Deployment ID),api_key, and specify if you're using a deployment ID.importopenaifromllama_index.agentimportOpenAIAgentfromllama_index.tools.playgrounds_subgraph_inspectorimport(PlaygroundsSubgraphInspectorToolSpec,)definspect_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 keyopenai.api_key=openai_api_key# Initialize the inspector with the provided parametersinspector_spec=PlaygroundsSubgraphInspectorToolSpec(identifier=identifier,api_key=playgrounds_api_key,use_deployment_id=use_deployment_id,)# Integrate the tool with the agentagent=OpenAIAgent.from_tools(inspector_spec.to_tool_list())# Send the user prompt to the agentresponse=agent.chat(user_prompt)returnresponseif__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-depthExamples.This inspector is designed to be used as a way to understand the schema of subgraphs and subgraph data being loaded intoLlamaIndexand/or subsequently used as a Tool in aLangChainAgent.