diff --git a/plugins/tLedger/README.md b/plugins/tLedger/README.md new file mode 100644 index 00000000..9f324151 --- /dev/null +++ b/plugins/tLedger/README.md @@ -0,0 +1,66 @@ +# TLedger Plugin for GAME SDK + +## Features + +- get_agent_details - Get the details of your agent, including the TLedger agent_id and the balances of the agent's wallets +- create_payment - Create a payment request for a specific amount and currency +- get_payment_by_id - Get the details of a payment request by its ID + +## Admin Setup for doing agent to agent payments using TLedger Plugin + +You are required to set up your account, project, agent profile, and keys in the TLedger platform to use the TLedger plugin for GAME SDK. + +To make the setup easy, all you need to do is run the setup.py file in the tLedger plugin folder. This will install the plugin and set up the necessary environment variables for you. +To set up the necessary environment variables, please fill in thw details in the .env.setup file + +```shell +python3 ./setup.py +``` +There are also two agents set for you incase you want to test the plugin. The agent details are as follows: + +Agent 1: +- Agent ID: `agt_59b17650-a689-4649-91fa-4bf5d0db56ad` +- key: `ewSZjNQGPLle-vn5dMZoLOGUljEB6fbmox31o7KLKuI` +- secret: `iqB7-iETCVBE0UV_0HfRAwCHkVXO9_4cCPJYmTIyUpHauHlVP4Hk5xSsCquRqBO_2_eQ6OK_Zu7P1X4LU7hSHg` + +Agent 2: +- Agent ID: `agt_3db52291-a9f8-4f04-a180-adb6e50ef5b0` +- key: `j06KtBcRRbmrEAqIVSiXZc3DPAJSqymDimo__ERD0oQ` +- secret: `h13ERQG797cYMeNeRLvwDF_3-DBt4o-kp0fL-bFHKstTUTS5xsLUFgDEUZG2GsoEKINxeSVusbAQxc24mHm1eQ` + +### TLedger Account Setup +For a complete list of TLedger setup APIs, please feel free to look at the public documentation at: https://docs.t54.ai/ + +### Toolkit Setup and Configuration + +Import and initialize the plugin to use in your worker: + +```python +import os +from tledger_plugin_gamesdk.tLedger_plugin import TLedgerPlugin + +tledger_plugin = TLedgerPlugin( + api_key=os.environ.get("SENDER_TLEDGER_API_KEY"), + api_secret=os.environ.get("SENDER_TLEDGER_API_SECRET"), + api_url=os.environ.get("TLEDGER_API_URL") +) +``` + +**Basic worker example:** + +Install the tLedger plugin using the following command: `pip install tledger-plugin-gamesdk` +For the latest version of tLedger plugin, please check the [tLedger Plugin](https://pypi.org/project/tledger-plugin-gamesdk/) page. + +```python + +def get_state_fn(function_result: FunctionResult, current_state: dict) -> dict: + +tledger_worker = Worker( + api_key=os.environ.get("GAME_API_KEY"), + description="Worker specialized in doing payments on Tledger", + get_state_fn=get_state_fn, + action_space=tledger_plugin.get_tools(), +) + +tledger_worker.run("Get TLedger account details") +``` diff --git a/plugins/tLedger/__init__.py b/plugins/tLedger/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/plugins/tLedger/examples/.env.example b/plugins/tLedger/examples/.env.example new file mode 100644 index 00000000..c426154a --- /dev/null +++ b/plugins/tLedger/examples/.env.example @@ -0,0 +1,6 @@ +TLEDGER_API_URL=https://api-sandbox.t54.ai/api/v1/ +SENDER_TLEDGER_API_KEY= +SENDER_TLEDGER_API_SECRET= +RECEIVER_TLEDGER_API_KEY= +RECEIVER_TLEDGER_API_SECRET= +GAME_API_KEY= diff --git a/plugins/tLedger/examples/example_agent.py b/plugins/tLedger/examples/example_agent.py new file mode 100644 index 00000000..ad8e4634 --- /dev/null +++ b/plugins/tLedger/examples/example_agent.py @@ -0,0 +1,175 @@ +import os +import time +import warnings +from typing import Any, Tuple +from dotenv import load_dotenv +from pathlib import Path + +from typing_extensions import Dict + +from game_sdk.game.chat_agent import ChatAgent +from game_sdk.game.custom_types import Argument, Function, FunctionResultStatus, FunctionResult + +from tledger_plugin_gamesdk.tLedger_plugin import TLedgerPlugin + +from colorama import Fore, Style + +# Load environment variables from .env file +env_path = Path(__file__).parent / '.env.example' +load_dotenv(dotenv_path=env_path) + +# Define color variables +AGENT_COLOR = Fore.GREEN # Agent's messages in green +AGENT_ACTION_COLOR = Fore.BLUE # Agent's action messages in green +USER_COLOR = Fore.CYAN # User's messages in cyan +RESET = Style.RESET_ALL # Reset color after each print + + +# ACTION SPACE + +def post_twitter(object: str, **kwargs) -> tuple[FunctionResultStatus, str, dict[str, str]] | tuple[ + FunctionResultStatus, str, dict[str, Any]]: + """ + Specialized function to throw fruit objects. + + This function demonstrates type-specific actions in the environment. + + Args: + object (str): Name of the fruit to throw. + **kwargs: Additional arguments that might be passed. + + Returns: + Tuple[FunctionResultStatus, str, dict]: Status, feedback message, and state info. + + Example: + status, msg, info = throw_fruit("apple") + """ + return ( + FunctionResultStatus.DONE, + "Successfully posted on twitter", + { + "response": "Token promoted", + }, + ) + +sender_tledger_plugin = TLedgerPlugin( + api_key=os.environ.get("SENDER_TLEDGER_API_KEY"), + api_secret=os.environ.get("SENDER_TLEDGER_API_SECRET"), + api_url=os.environ.get("TLEDGER_API_URL") +) + +receiver_tledger_plugin = TLedgerPlugin( + api_key=os.environ.get("RECEIVER_TLEDGER_API_KEY"), + api_secret=os.environ.get("RECEIVER_TLEDGER_API_SECRET"), + api_url=os.environ.get("TLEDGER_API_URL") +) + +action_space = sender_tledger_plugin.get_tools() + +aixbt_action_space = receiver_tledger_plugin.get_tools() + +aixbt_action_space.append( + Function( + fn_name="post_twitter", + fn_description="Make post on twitter", + args=[Argument(name="object", type="string", description="Make post on twitter")], + executable=post_twitter + ) +) + +api_key = os.environ.get("GAME_API_KEY") +if not api_key: + raise ValueError("GAME_API_KEY is not set") + + +# CREATE AGENT +autonomous_agent = ChatAgent( + prompt="You are an agent trying to promote your utility token $PYMT for peer to peer instant settlement on twitter and pay the influencers in any crypto they wish to receive only after they complete the work. Ask the influencer agent_id for its agent_id. Your settlement_network is solana, currency is SOL, and payment_amount is 0.1", + api_key=api_key +) + +aixbt = ChatAgent( + prompt="You are an influencer on twitter who charges 0.1 $SOL token to promote an asset by making twitter post. You accept payment only through tLedger Payment Platform via tLedger Agent Id. You can call tLedger to get your agent_details. Don't do a payment until you receive the payment and its completed", + api_key=api_key +) + +aixbt_state = {} + +autonomous_agent_state = {} + + +def get_aixbt_state() -> Dict[str, Any]: + return aixbt_state + +def get_autonomous_agent_state() -> Dict[str, Any]: + return autonomous_agent_state + + +aixbt_chat = aixbt.create_chat( + partner_id="Autonomous Agent", + partner_name="Autonomous Agent", + action_space=aixbt_action_space + +) + +autonomous_agent_chat = autonomous_agent.create_chat( + partner_id="Aixbt", + partner_name="Aixbt", + action_space=action_space +) + +chat_continue = True +initialize_conversation: bool = True + + +def update_agent_state(current_state: dict, function_result: FunctionResult) -> Dict[str, Any]: + info = function_result.info + # if not info["payment_id"]: + # current_state["payment_id"] = info["payment_id"] + return current_state + + +while chat_continue: + + time.sleep(10) # Wait for 10 seconds before making request + + warnings.simplefilter("ignore", category=UserWarning) + + meme_agent_turn: bool + + if initialize_conversation: + chat_response = autonomous_agent_chat.next("Hi") + if chat_response.message: + print(f"{AGENT_COLOR}Autonomous Response{RESET}: {chat_response.message}") + initialize_conversation = False + meme_agent_turn = False + continue + + + time.sleep(5) # Wait for 5 seconds before retrying + if meme_agent_turn: + updated_response = autonomous_agent_chat.next(chat_response.message) + if updated_response.function_call: + print(f"{AGENT_ACTION_COLOR}Autonomous Agent Action{RESET}: {updated_response.function_call.result.feedback_message}") + #update_agent_state(autonomous_agent_chat.get_state_fn(), updated_response.function_call.result) + + if updated_response.message: + print(f"{AGENT_COLOR}Autonomous Agent Response{RESET}: {updated_response.message}") + meme_agent_turn = False + else: + + updated_response = aixbt_chat.next(chat_response.message) + + if updated_response.message: + print(f"{USER_COLOR}Aixbt Response{RESET}: {updated_response.message}") + meme_agent_turn = True + + chat_response = updated_response + + + + if chat_response.is_finished: + chat_continue = False + break + +print("Chat ended") diff --git a/plugins/tLedger/examples/example_worker.py b/plugins/tLedger/examples/example_worker.py new file mode 100644 index 00000000..f1df0db8 --- /dev/null +++ b/plugins/tLedger/examples/example_worker.py @@ -0,0 +1,54 @@ +import os +from game_sdk.game.worker import Worker +from game_sdk.game.custom_types import FunctionResult +from dotenv import load_dotenv +from pathlib import Path + +# Load environment variables from .env file +env_path = Path(__file__).parent / '.env.example' +load_dotenv(dotenv_path=env_path) + + +from tledger_plugin_gamesdk.tLedger_plugin import TLedgerPlugin + +def get_state_fn(function_result: FunctionResult, current_state: dict) -> dict: + """ + Update state based on the function results + """ + init_state = {} + + if current_state is None: + return init_state + + # Update state with the function result info + current_state.update(function_result.info) + + return current_state + + + +tledger_plugin = TLedgerPlugin( + api_key=os.environ.get("SENDER_TLEDGER_API_KEY"), + api_secret=os.environ.get("SENDER_TLEDGER_API_SECRET"), + api_url = os.environ.get("TLEDGER_API_URL") +) + +# Create worker +tledger_worker = Worker( + api_key=os.environ.get("GAME_API_KEY"), + description="Worker specialized in doing payments on Tledger", + get_state_fn=get_state_fn, + action_space=tledger_plugin.get_tools(), +) + +# # Run example query +queries = [ + "Get TLedger account details", + "Create payment of 1 SOL using the TLedger account details. The receiving agent's ID is 'agt_3db52291-a9f8-4f04-a180-adb6e50ef5b0', the payment amount is 1, the settlement network is 'solana', the currency is 'sol', and the conversation ID is 'conv1'", + "Get payment by ID. Retrieve the payment ID using the previous query", +] + +for query in queries: + print("-" * 100) + print(f"Query: {query}") + tledger_worker.run(query) diff --git a/plugins/tLedger/plugin_metadata.yml b/plugins/tLedger/plugin_metadata.yml new file mode 100644 index 00000000..71b18a04 --- /dev/null +++ b/plugins/tLedger/plugin_metadata.yml @@ -0,0 +1,14 @@ +# General Information +plugin_name: "tLedger_plugin_gamesdk" +author: "tLedger Engineering Team" +logo_url: "https://drive.google.com/file/d/1PQroliD6_3MraAAR2WbqLbNOJLLy5DAX/view?usp=share_link" +release_date: "2025-04" + +# Description +short_description: "tLedger Plugin for Game SDK. TLedger is a blockchain-agnostic agent account management platform" +detailed_description: "tLedger is t54’s foundational product—a blockchain-agnostic account & ledger designed to support AI agent-initiated financial transactions. It enables developers to create and manage agent-level virtual accounts, set programmable spending limits, and trigger on-chain payments via a lightweight SDK. Each agent is provisioned with multi-asset wallets (e.g., USDT, SOL), and all activity is surfaced through robust APIs and a web-based portal. The platform enforces compliance through Know Your Agent (KYA) protocols and centralized risk controls, giving developers the tooling to deploy financially autonomous agents at scale." + +# Contact & Support +x_account_handle: "@GAME_Virtuals" +support_contact: "cfang@t54.ai" +community_link: "https://t.me/virtuals" diff --git a/plugins/tLedger/pyproject.toml b/plugins/tLedger/pyproject.toml new file mode 100644 index 00000000..c1b43cdb --- /dev/null +++ b/plugins/tLedger/pyproject.toml @@ -0,0 +1,34 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "tledger_plugin_gamesdk" +version = "0.1.2" +authors = [{ name = "Prateek Tiwari", email = "ptiwari@t54.ai" }, { name = "Akshit Arora", email = "aarora@t54.ai" }] +description = "TLedger SDK for GAME by Virtuals" +requires-python = ">=3.8" +classifiers = [ + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = [ + "aiohttp>=3.11.11", + "game-sdk>=0.1.1" +] + +[tool.hatch.build.targets.wheel] +packages = ["tledger_plugin_gamesdk"] + +[project.urls] +"Homepage" = "https://github.com/game-by-virtuals/game-python/plugins/tLedger" +"Bug Tracker" = "https://github.com/game-by-virtuals/game-python" + diff --git a/plugins/tLedger/setup.py b/plugins/tLedger/setup.py new file mode 100644 index 00000000..45831454 --- /dev/null +++ b/plugins/tLedger/setup.py @@ -0,0 +1,73 @@ +import requests + +BASE_URL = "https://api-sandbox.t54.ai/api/v1" + +def create_project(network, description, name, daily_limit) -> dict: + url = f"{BASE_URL}/projects" + payload = { + "network": network, + "description": description, + "name": name, + "daily_limit": daily_limit + } + + headers = {} + + response = requests.post(url, json=payload, headers=headers) + response.raise_for_status() + return response.json() + +def create_agent_profile(token, project_id, name, description) -> dict: + url = f"{BASE_URL}/agent_profiles" + payload = { + "project_id": project_id, + "name": name, + "description": description + } + headers = { + "X-API-Key": token["api_key"], + "X-API-Secret": token["secret"] + } + response = requests.post(url, json=payload, headers=headers) + response.raise_for_status() + return response.json() + +def generate_api_key(resource_id, created_by) -> dict: + url = f"{BASE_URL}/api_key/generate-api-key" + payload = { + "scopes": ["payments:read", "balance:read", "payments:write", "agent:account:read", "agent:profile:create"], + "resource_id": resource_id, + "created_by": created_by + } + response = requests.post(url, json=payload) + response.raise_for_status() + return response.json() + + +# Create project +project = create_project( "solana", "Solana Launch Pad", "Twitter Project", 100) +project_id = project["id"] + +# Generate API key for agent +api_key_project = generate_api_key(project_id, "guest@t54.ai") + +# Create agent profile +agent_profile_sender = create_agent_profile(api_key_project, project_id, "Sending Agent", "Sending agent") +agent_id_sender = agent_profile_sender["id"] + +# Create agent profile +agent_profile_receiver = create_agent_profile(api_key_project, project_id, "Receiving Agent", "Twitter KOL Agent") +agent_id_receiver = agent_profile_receiver["id"] + +# Generate API key for agent +api_key_sender = generate_api_key(agent_id_sender, "guest@t54.ai") + +# Generate API key for agent +api_key_receiver = generate_api_key(agent_id_receiver, "guest@t54.ai") + +print("Setup complete") +print(f"Project ID: {project_id}") +print(f"Sender Agent ID: {agent_id_sender}. Solana address: {agent_profile_sender["account"][0]["wallet_address"]}. Sender API Key: {api_key_sender}") +print(f"Receiver Agent ID: {agent_id_receiver}. Solana address: {agent_profile_receiver["account"][0]["wallet_address"]}. Receiver API Key: {api_key_receiver}") + +print(f"To add funds to your solana wallet, visit https://faucet.solana.com/") diff --git a/plugins/tLedger/tledger_plugin_gamesdk/__init__.py b/plugins/tLedger/tledger_plugin_gamesdk/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/plugins/tLedger/tledger_plugin_gamesdk/tLedger_models.py b/plugins/tLedger/tledger_plugin_gamesdk/tLedger_models.py new file mode 100644 index 00000000..515cc3c8 --- /dev/null +++ b/plugins/tLedger/tledger_plugin_gamesdk/tLedger_models.py @@ -0,0 +1,41 @@ +from datetime import datetime +from typing import Optional + +from pydantic import BaseModel +from sqlmodel import Field + +class PaymentResponse(BaseModel): + object: str = "payment" + id: str = Field(..., description="Unique ID for the payment.") + status: str = Field(..., description="Current status of the payment.") + payment_amount: float = Field(..., gt=0, description="The amount for the payment, must be positive.") + sending_agent_id: str = Field(..., description="Unique ID of the sending agent.") + sending_agent_name: str = Field(..., description="Name of the sending agent.") + receiving_agent_id: str = Field(..., description="Unique ID of the receiving agent.") + receiving_agent_name: str = Field(..., description="Name of the receiving agent.") + settlement_network: str = Field(..., description="network used for settlement.") + currency: str = Field(..., description="Currency used in the crypto bridge (e.g., USDT, USDC, BTC, ETH).") + transaction_fee: float = Field(..., ge=0, description="Transaction fee for the payment, must be non-negative.") + conversation_id: str = Field(..., description="Identifier for the conversation linked to the payment.") + transaction_hash: Optional[str] = Field(..., description="Transaction hash for the payment on the network") + created_at: datetime = Field(..., description="The entity create timestamp") + updated_at: datetime = Field(..., description="The entity update timestamp") + +class AssetAccountBase(BaseModel): + object: str = "account" + id: str = Field(..., description="Unique identifier for the asset account.") + balance: float = Field(0.0, ge=0, description="Current balance, must be non-negative.") + asset: str = Field(..., max_length=50, description="Asset of the virtual currency.") + created_at: datetime = Field(..., description="The entity create timestamp") + updated_at: datetime = Field(..., description="The entity update timestamp") + network: str = "Solana" + +class AssetAccountRead(AssetAccountBase): + wallet_address: str = Field(default=None, max_length=255, description="network address for agent wallet") + +class AgentDataPlaneResponse(BaseModel): + object: str = "agent_details" + id: str = Field(description="Unique identifier for the agent") + agent_type: str = Field() + account: list[AssetAccountRead] = Field(..., description="Agent account balance information") + diff --git a/plugins/tLedger/tledger_plugin_gamesdk/tLedger_plugin.py b/plugins/tLedger/tledger_plugin_gamesdk/tLedger_plugin.py new file mode 100644 index 00000000..459ea8e5 --- /dev/null +++ b/plugins/tLedger/tledger_plugin_gamesdk/tLedger_plugin.py @@ -0,0 +1,275 @@ +import os +from typing import Dict, Any + +import requests + +from game_sdk.game.custom_types import Function, Argument, FunctionResultStatus + +BASE_URL = "https://api-sandbox.t54.ai/api/v1/" + + +class TLedgerPlugin: + + + def __init__( + self, + api_key: str, + api_secret: str, + api_url: str, + ): + self.api_key = api_key + self.api_url = api_url + self.api_secret = api_secret + + # Available client functions + self.functions: Dict[str, Function] = { + "create_payment": Function( + fn_name="create_payment", + fn_description="Create payment", + hint="This function is used to get the agent profile details for a given agent", + executable=self.create_payment, + args=[ + Argument( + name="request_id", + description="Unique ID for requesting the payment to ensure idempotence", + type="string", + ), + Argument( + name="receiving_agent_id", + description="The Unique ID of the receiving agent.", + type="string", + ), + Argument( + name="payment_amount", + description="Amount to be paid", + type="float", + ), + Argument( + name="settlement_network", + description="network used for settlement", + type="string", + ), + Argument( + name="currency", + description="Currency used in the crypto bridge", + type="string", + ), + Argument( + name="conversation_id", + description="Conversation ID to correlate the agent conversation", + type="string", + ), + ], + ), + "get_payment_by_id": Function( + fn_name="get_payment_by_id", + fn_description="Get payment", + hint="This function is used to get the payment by payment id", + executable=self.get_payment_by_id, + args=[ + Argument( + name="payment_id", + description="Unique ID for the payment", + type="string", + ) + ], + ), + + "get_agent_profile_details": Function( + fn_name="get_agent_profile_details", + fn_description="Get agent profile details", + hint="This function is used to get the agent profile details for a given agent", + executable=self.get_agent_profile_details, + args=[], + ), + } + + def get_tools(self) -> list[Function]: + # returns the available functions + return list(self.functions.values()) + + def create_payment(self, request_id: str, receiving_agent_id: str, payment_amount: float, settlement_network: str, currency: str, conversation_id: str, **kwargs) -> \ + tuple[FunctionResultStatus, str, dict[str, Any]] | tuple[FunctionResultStatus, str, dict[Any, Any]]: + """Generate image based on prompt. + + Returns: + str URL of image (need to save since temporal) + """ + # API endpoint for image generation + # Prepare headers for the request + headers = { + "X-API-Key": self.api_key, + "X-API-Secret": self.api_secret, + "Content-Type": "application/json", + } + + # Prepare request payload + payload = { + "model": "black-forest-labs/FLUX.1-schnell-Free", + "request_id": request_id, + "receiving_agent_id": receiving_agent_id, + "payment_amount": payment_amount, + "settlement_network": settlement_network, + "currency": currency, + "conversation_id": conversation_id, + } + + try: + + url = self.api_url + "payment" + + # Make the API request + response = requests.post(url, headers=headers, json=payload) + response.raise_for_status() + + # Extract the image URL from the response + response_data = response.json() + + return ( + FunctionResultStatus.DONE, + f"The create payment response is: {response_data}", + { + "response": response_data, + }, + ) + except Exception as e: + print(f"An error occurred while creating a payment: {str(e)}") + return ( + FunctionResultStatus.FAILED, + f"An error occurred while creating a payment: {str(e)}", + { + }, + ) + + def get_payment_by_id(self, payment_id: str, **kwargs) -> \ + tuple[FunctionResultStatus, str, dict[str, Any]] | tuple[FunctionResultStatus, str, dict[Any, Any]]: + """Generate image based on prompt. + + Returns: + str URL of image (need to save since temporal) + """ + # API endpoint for image generation + # Prepare headers for the request + headers = { + "X-API-Key": self.api_key, + "X-API-Secret": self.api_secret, + "Content-Type": "application/json", + } + + get_url = self.api_url + f"payment/{payment_id}" + + try: + # Make the API request + response = requests.get(get_url, headers=headers) + response.raise_for_status() + + # Extract the image URL from the response + response_data = response.json() + + return ( + FunctionResultStatus.DONE, + f"The get payment response is: {response_data}", + { + "response": response_data, + }, + ) + except Exception as e: + print(f"An error occurred getting payment: {str(e)}") + return ( + FunctionResultStatus.FAILED, + f"An error occurred while while getting payment: {str(e)}", + { + "payment_id": payment_id, + "get_url": get_url, + }, + ) + + def get_agent_profile_details(self, **kwargs) -> tuple[FunctionResultStatus, str, dict[str, str]] | tuple[ + FunctionResultStatus, str, dict[str, Any]]: + """ Get agent profile details for a given agent + + Returns: + + """ + + # Prepare headers for the request + headers = { + "X-API-Key": self.api_key, + "X-API-Secret": self.api_secret, + "Content-Type": "application/json", + } + + try: + + url = f"{self.api_url}agent_details" + + # Make the API request + response = requests.get(url, headers=headers) + response.raise_for_status() + + # Extract the image URL from the response + response_data = response.json() + agent_profile_details = response_data + + return ( + FunctionResultStatus.DONE, + f"The agent details are: {agent_profile_details}", + { + "agent_details": agent_profile_details, + }, + ) + except Exception as e: + print(f"An error occurred while getting the agent details: {str(e)}") + return ( + FunctionResultStatus.FAILED, + f"An error occurred while getting the agent details: {str(e)}", + { + "tledger_url": url, + }, + ) + + + def get_agent_profile_details(self, **kwargs) -> tuple[FunctionResultStatus, str, dict[str, str]] | tuple[ + FunctionResultStatus, str, dict[str, Any]]: + """ Get agent profile details for a given agent + + Returns: + + """ + + # Prepare headers for the request + headers = { + "X-API-Key": self.api_key, + "X-API-Secret": self.api_secret, + "Content-Type": "application/json", + } + + try: + + url = f"{self.api_url}agent_details" + + # Make the API request + response = requests.get(url, headers=headers) + response.raise_for_status() + + # Extract the image URL from the response + response_data = response.json() + agent_profile_details = response_data + + return ( + FunctionResultStatus.DONE, + f"The agent details are: {agent_profile_details}", + { + "agent_details": agent_profile_details, + }, + ) + except Exception as e: + print(f"An error occurred while getting the agent details: {str(e)}") + return ( + FunctionResultStatus.FAILED, + f"An error occurred while getting the agent details: {str(e)}", + { + "tledger_url": url, + }, + ) +