### Start Web Interface for Chess Board Visualization Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_chess_game/README.md Starts a local web server to provide a real-time visualization of the chess board. The interface automatically updates every 3 seconds, allowing users to monitor the game's progress via a web browser. ```bash uv run app.py ``` -------------------------------- ### Start gRPC Mock Tool Server Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_tools/README.md This command-line snippet shows how to start the gRPC mock tool server. It navigates to the `examples/aip_tools` directory and then executes the `grpc_mock_tool.py` script using `uv run`, making the gRPC server available for other agents. ```shell cd examples/aip_tools uv run grpc_mock_tool.py ``` -------------------------------- ### Install Python Requests Library Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md Command to install the `requests` library, a common HTTP client for Python, using pip. This library is required for making API calls in the provided Python examples. ```bash python -m pip install requests ``` -------------------------------- ### Start Chess Game Player Agents Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_chess_game/README.md Launches individual player agents. Each player registers on the blockchain, joins the designated task, connects to the moderator, and plays their assigned color (black or white). The game commences once two players have successfully registered. ```bash uv run role.py --moderator= uv run role.py --moderator= ``` -------------------------------- ### Run an Example AIP Agent Source: https://github.com/unibaseio/aip-agent/blob/main/README.md Navigates to the examples directory within the AIP Agent SDK and executes a full-featured gRPC agent script using uv. This demonstrates blockchain identity registration, Memory Hub connection, and live agent-to-agent or agent-to-tool interactions. ```bash cd examples/aip_agents uv run grpc_full_agent_gradio.py ``` -------------------------------- ### Install AIP Agent SDK by cloning repository Source: https://github.com/unibaseio/aip-agent/blob/main/README.md Clones the AIP Agent SDK repository locally, navigates into the directory, creates a virtual environment using uv, and installs all development dependencies, preparing the environment for local development and contributions. ```bash git clone https://github.com/unibaseio/aip-agent.git cd aip-agent uv venv uv sync --dev --all-extras ``` -------------------------------- ### Install AIP Agent SDK via pip Source: https://github.com/unibaseio/aip-agent/blob/main/README.md Installs the AIP Agent SDK directly from its GitHub repository using pip, allowing immediate access to the protocol's functionalities and libraries. ```bash pip install git+https://github.com/unibaseio/aip-agent.git ``` -------------------------------- ### Install System and Python Dependencies for AIP DEX Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md This sequence of bash commands installs necessary system libraries (`libpq-dev`, `python3-dev`) and then uses `pip` to install Python dependencies from `requirements.txt`. This is a prerequisite for setting up the AIP DEX project. ```bash sudo apt update sudo apt install -y libpq-dev python3-dev cd examples/aip_dex pip install -r requirements.txt ``` -------------------------------- ### Start SSE Mock Tool Server with Default Settings Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_tools/README.md This command-line snippet demonstrates how to start the SSE mock tool server using its default settings. It first changes the directory to `examples/aip_tools` and then runs the `sse_mock_tool.py` script, making the server available for real-time event-driven access. ```shell cd examples/aip_tools uv run sse_mock_tool.py ``` -------------------------------- ### Start AIP Personal Agent in Single User Mode Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/README.md This command initiates the AIP Personal Agent in single-user mode, optimized for interacting with a specific Twitter/X account. It requires the 'uv' package manager to be installed and a target Twitter username. The '--verbose' flag enables detailed logging, and '--address' specifies the GRPC server endpoint. ```bash uv run personal_agent_gradio.py --x_account ``` -------------------------------- ### Start the Chess Game Moderator Agent Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_chess_game/README.md Initiates the moderator agent, which is responsible for registering on the blockchain, creating a new game task, waiting for players to join, managing the game's progression, and distributing rewards upon completion. ```bash uv run main.py ``` -------------------------------- ### Start SSE Mock Tool Server on Custom Port Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_tools/README.md This command-line snippet shows how to start the SSE mock tool server on a custom port. After navigating to the `examples/aip_tools` directory (implied by context), it executes the `sse_mock_tool.py` script and specifies the desired port using the `--port` argument. ```shell uv run sse_mock_tool.py --port= ``` -------------------------------- ### cURL: Interact with AIP Agent API Endpoints Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md This cURL example provides command-line instructions for interacting with the AIP agent API. It illustrates how to perform GET and POST requests, including setting authorization headers and sending JSON payloads, for tasks like listing users, getting user details, and initiating a chat. ```bash # List all users curl -X GET "http://localhost:5001/api/list_users" \ -H "Authorization: Bearer your_bearer_token" # Get user info curl -X GET "http://localhost:5001/api/get_info?username=example_user" \ -H "Authorization: Bearer your_bearer_token" # Chat with user curl -X POST "http://localhost:5001/api/chat" \ -H "Authorization: Bearer your_bearer_token" \ -H "Content-Type: application/json" \ -d '{"username": "example_user", "message": "Hello!"}' ``` -------------------------------- ### Run FastAPI Application Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md This snippet shows the command to start the FastAPI application using `uvicorn` (or `uv`). It specifies the module to run (`core.fastapi`) and the port to listen on (5001). This command is essential for local development and testing of the API. ```bash uv run -m core.fastapi --port=5001 ``` -------------------------------- ### Start AIP DEX API Service Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md These commands demonstrate how to start the AIP DEX API service. The first command runs the application directly using Python, while the second uses `uvicorn` for a production-ready ASGI server, enabling hot-reloading and specifying host and port. ```python python main.py ``` ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` -------------------------------- ### Prepare Docker Environment File for AIP Trader Agent Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_trader_agents/README.md Copy the example environment file to `.env` to provide configuration values for the Dockerized AIP Trader Agent. This file will be used by Docker Compose. ```shell cp .env.example .env ``` -------------------------------- ### API Reference: Get Web3 & AI News Report Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Detailed API specification for the `/api/get_report` endpoint, which retrieves daily Web3 & AI news reports. It outlines the method, required headers, optional parameters for date, language, and format, and provides example responses for both text and JSON output types. Authentication via a bearer token is mandatory. ```APIDOC Endpoint: /api/get_report Method: GET Headers: Authorization: Bearer Parameters: date_str: Optional date string in format 'YYYY-MM-DD'. If not specified, returns the latest report. language: Optional language for the report (default: "Chinese", alternative: "English"). format: Optional output format (default: "text", alternative: "json"). Error Cases: If report not found for specified date: 404 error with "News report for date {date_str} not found" If latest report not found: 404 error with "Latest news report not found" If unsupported language provided: 400 error with "Unsupported language. Available options: Chinese, English" If unsupported format provided: 400 error with "Unsupported format. Available options: text, json" If server error occurs: 500 error with error message ``` ```json { "success": true, "data": "# Web3 & AI Daily Report\n[2023-06-15]\n\n## Brief\n* Summary of the latest news in 150 words...\n\n## Hot Topics\n1. Trending Topics\n * List of specific topics being discussed by KOLs...\n\n[...full report content...]" } ``` ```json { "success": true, "data": { "title": "Web3 & AI Daily Report", "Brief": [ "Summary of the latest news in 150 words..." ], "Hot Topics": [ "Trending Topics", "List of specific topics being discussed by KOLs..." ] } } ``` -------------------------------- ### Build and Start AIP Trader Agent Docker Containers Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_trader_agents/README.md Use Docker Compose to build the necessary images and start the AIP Trader Agent services in detached mode. The `--build` flag ensures images are rebuilt if changes have occurred. ```shell docker compose up -d --build ``` -------------------------------- ### Execute System Tests for AIP DEX Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md This bash command runs the system tests for the AIP DEX project. It's an important step to verify the correct setup and functionality of the application components before starting the main service. ```bash python test_system.py ``` -------------------------------- ### Navigate to AIP Trader Agent Project Directory Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_trader_agents/README.md Change the current directory to the location of the AIP Trader Agent example project before running the application locally. ```shell cd examples/aip_trader_agents ``` -------------------------------- ### Configure Environment Variables for Chess Game Agents Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_chess_game/README.md Sets up essential environment variables required for both the moderator and player agents to connect to the Membase service. This includes a shared task ID, a unique Membase ID for each participant, and their respective account credentials. ```bash export MEMBASE_TASK_ID="" export MEMBASE_ID="" export MEMBASE_ACCOUNT="" export MEMBASE_SECRET_KEY="" ``` -------------------------------- ### Example Environment Variables for AIP DEX Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md This snippet provides an example of the `.env` file structure, detailing the required environment variables for database connection, API keys for external services, and an API bearer token. These variables are crucial for the application's functionality. ```env DATABASE_URL=postgresql://username:password@localhost/aip_dex OPENAI_API_KEY=your_openai_api_key_here COINGECKO_API_KEY=your_coingecko_api_key_here MORALIS_API_KEY=your_moralis_api_key_here BIRDEYE_API_KEY=your_birdeye_api_key_here API_BEARER_TOKEN=your_secure_bearer_token_here ``` -------------------------------- ### Example Backend Response for Token Analysis Query Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md A JSON snippet demonstrating the structured response from the backend, providing the token's signal, a human-readable reason, and key real-time metrics. ```JSON { "token": "DOGE", "signal": "Watch", "reason": "RSI is 68, approaching overbought. MA7 > MA30, but volume is flat. Momentum slowing.", "metrics": { "price": 0.091, "rsi": 68, "ma_7d": 0.089, "ma_30d": 0.084, "volume_24h": 32000000 } } ``` -------------------------------- ### Fetch ERC20 Token Holder Statistics (Moralis API, Python) Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md Python code using the `requests` library to retrieve comprehensive holder statistics for an ERC20 token from the Moralis Deep Index API. Examples are provided for both Ethereum and BSC chains, demonstrating how to get total holders, acquisition methods, and distribution. ```python import requests url = "https://deep-index.moralis.io/api/v2.2/erc20/0x6982508145454ce325ddbe47a25d4ec3d2311933/holders?chain=eth" headers = { "Accept": "application/json", "X-API-Key": "YOUR_API_KEY" } response = requests.request("GET", url, headers=headers) print(response.text) ``` ```python # Dependencies to install: # $ python -m pip install requests import requests url = "https://deep-index.moralis.io/api/v2.2/erc20/0x238950013FA29A3575EB7a3D99C00304047a77b5/holders?chain=bsc" headers = { "Accept": "application/json", "X-API-Key": "YOUR_API_KEY" } response = requests.request("GET", url, headers=headers) print(response.text) ``` -------------------------------- ### Configure Environment Variables for AIP DEX Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md This bash command copies the example environment file to `.env`, which is then used to configure critical settings like database connection strings and API keys for various services (OpenAI, CoinGecko, Moralis, BirdEye) and a bearer token for API security. ```bash cp env.example .env ``` -------------------------------- ### Run AIP Trader Agent Locally Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_trader_agents/README.md Execute the `trader_agent_gradio.py` script using `uv` to start the AIP Trader Agent and its Gradio web interface on your local machine. ```shell uv run trader_agent_gradio.py ``` -------------------------------- ### Initialize Chat Application on DOM Load Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/chat/index.html Ensures that the `ChatApp` class is instantiated and the chat application starts running only after the entire HTML document has been fully loaded and parsed, preventing issues with accessing non-existent DOM elements. ```javascript document.addEventListener('DOMContentLoaded', () => { new ChatApp(); }); ``` -------------------------------- ### API Endpoint: List All User Information Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Detailed documentation for the `/api/list_info` endpoint, including its purpose, HTTP method, required headers, parameters with their options, and an example of a successful JSON response. This endpoint allows retrieving comprehensive information for all available users, with optional sorting. ```APIDOC Endpoint: /api/list_info Description: Get a list of all available users with their complete information Method: GET Headers: Authorization: Bearer Parameters: sort_by: Type: string (Optional) Description: Optional sorting field (default: "score") Values: "name" (Sort by username), "score" (Sort by total_score) order: Type: string (Optional) Description: Optional sort order (default: "desc") Values: "asc" (Ascending order), "desc" (Descending order) Response Example: { "success": true, "data": [ { "username": "user1", "summary": { "detailed_analysis": {}, "personal_brief": "", "long_description": "", "personal_tags": { "keywords": [ "#Bitcoin", "Strategic Reserve", "BTC Yield" ] } }, "xinfo": {}, "scores": { "total_score": 67, "engagement_score": 22, "influence_score": 23, "project_score": 0, "quality_score": 22, "authenticity_factor": 1, "detail": {} } } ] } Error Cases: Invalid sort_by parameter: 400 error with "Invalid sort_by parameter. Must be 'name' or 'score'" Server error: 500 error with error message ``` -------------------------------- ### Example Response: Token Analytics API Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md A JSON example illustrating the data structure returned by the Moralis Deep Index API when requesting token analytics. It includes various metrics like total buy/sell volume, number of buyers/sellers, price change, and liquidity. ```json { "tokenAddress": "0x238950013fa29a3575eb7a3d99c00304047a77b5", "totalBuyVolume": { "5m": 0, "1h": 0, "6h": 36.08441127519937, "24h": 145.31766518635527 }, "totalSellVolume": { "5m": 0, "1h": 0, "6h": 23.61049011135401, "24h": 151.1848144618685 }, "totalBuyers": { "5m": 0, "1h": 0, "6h": 5, "24h": 19 }, "totalSellers": { "5m": 0, "1h": 0, "6h": 4, "24h": 21 }, "totalBuys": { "5m": 0, "1h": 0, "6h": 5, "24h": 21 }, "totalSells": { "5m": 0, "1h": 0, "6h": 4, "24h": 26 }, "uniqueWallets": { "5m": 0, "1h": 0, "6h": 8, "24h": 25 }, "pricePercentChange": { "5m": 0, "1h": 0, "6h": 0.20572543374533, "24h": 0.14180992701153 }, "usdPrice": "0.000228710596262586", "totalLiquidityUsd": "170546.99", "totalFullyDilutedValuation": "2287469.14578223" } ``` -------------------------------- ### Example Response: ERC20 Holder Statistics API Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md A JSON example illustrating the data structure returned by the Moralis Deep Index API when requesting ERC20 token holder statistics. It includes total holders, holder change over time, supply distribution by top holders, and holder distribution by type (whales, sharks, etc.). ```json { "totalHolders": 6541, "holdersByAcquisition": { "swap": 1044, "transfer": 5496, "airdrop": 1 }, "holderChange": { "5min": { "change": 0, "changePercent": 0 }, "1h": { "change": 0, "changePercent": 0 }, "6h": { "change": 2, "changePercent": 0.031 }, ``` -------------------------------- ### Set Environment Variables for AIP Tool Servers Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_tools/README.md This snippet shows the essential environment variables required before starting any AIP tool server. These variables include credentials for Membase and the public endpoint URL for SSE tools, ensuring proper server operation and communication. ```shell export MEMBASE_ID="" export MEMBASE_ACCOUNT="" export MEMBASE_SECRET_KEY="" export MEMBASE_SSE_URL="public endpoint URL" #Required for SSE tools ``` -------------------------------- ### Start AIP Personal Agent in Multi User Mode Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/README.md This command launches the AIP Personal Agent in multi-user mode, enabling the management and switching between multiple Twitter/X accounts. It leverages the 'uv' package manager. Optional parameters include '--verbose' for verbose logging and '--address' to specify the GRPC server address. ```bash uv run personal_agent_multiple_gradio.py ``` -------------------------------- ### Example User Input for Token Analysis Chat Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md A JSON snippet representing a user's natural language query to the chat system, asking for an outlook on a specific cryptocurrency token. ```JSON { "message": "What's the outlook on $DOGE?" } ``` -------------------------------- ### Get Complete User Info API Endpoint Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Retrieves comprehensive information for a specified username, including profile, summary, and XInfo. This GET request requires an Authorization header with a Bearer token and a mandatory `username` parameter. Possible errors include user not found, missing parameters, or server issues, as well as specific messages for users being built or lacking sufficient information. ```APIDOC Endpoint: /api/get_info Method: GET Headers: Authorization: Bearer Parameters: username: Username (required) Error Cases: If user is being built: {"success": false, "data": "Building..."} If user not found: 404 error If username parameter missing: 400 error If xinfo not found: 404 error If server error occurs: 500 error with error message If user has no tweets, personal_brief is "No enough information or still in building..." ``` ```json { "success": true, "data": { "username": "user1", "xinfo": { // Twitter information details }, "summary": { "detailed_analysis": {}, "personal_brief": "", "long_description": "", "personal_tags": { "keywords": [] } }, "scores": { "total_score": 100 } } } ``` -------------------------------- ### List All Available Users API Endpoint Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Fetches a list of all registered users. This GET request requires an Authorization header with a Bearer token. It returns an array of usernames, which are Twitter handles. Server errors are possible. ```APIDOC Endpoint: /api/list_users Method: GET Headers: Authorization: Bearer Error Cases: If server error occurs: 500 error with error message ``` ```json { "success": true, "data": ["user1", "user2", "user3"] } ``` -------------------------------- ### External API Key Setup and Sources Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md This section provides a list of external services requiring API keys for the system's operation. It specifies the platforms where users can obtain the necessary credentials for OpenAI, CoinGecko, Moralis, and BirdEye to ensure full system functionality. ```APIDOC OpenAI: platform.openai.com\nCoinGecko: coingecko.com/api\nMoralis: moralis.io\nBirdEye: birdeye.so - Get API key from BirdEye dashboard ``` -------------------------------- ### Example Parsed Intent from User Chat Input Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md A JSON snippet showing the structured intent extracted from the user's natural language input, identifying the action (token analysis) and the target token. ```JSON { "intent": "token_analysis", "token": { "ticker": "DOGE" } } ``` -------------------------------- ### Fetch Token List using BirdEye API (Python) Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md This Python code snippet demonstrates how to make a GET request to the BirdEye public API to retrieve a list of tokens. It includes necessary headers for authentication and chain selection. The response contains token details like address, liquidity, name, symbol, and price. ```python import requests url = "https://public-api.birdeye.so/defi/tokenlist?sort_by=v24hUSD&sort_type=desc&offset=0&limit=50&min_liquidity=100" headers = { "accept": "application/json", "x-chain": "bsc", "X-API-KEY": "3079160b0c4b47cdb972014a615efb47" } response = requests.get(url, headers=headers) print(response.text) ``` -------------------------------- ### DEX Screener API: Get Token Information by Address Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md Documents the API endpoint for fetching detailed information about tokens, including price, liquidity, and transaction data, given a chain ID and token addresses. The response provides a comprehensive view of the token's market status on various decentralized exchanges. ```APIDOC baseurl: https://api.dexscreener.com Endpoint: /tokens/v1/{chainId}/{tokenAddresses} Description: Retrieve detailed information for one or more tokens on a specific blockchain. Parameters: chainId: string (path) - The ID of the blockchain (e.g., "bsc"). tokenAddresses: string (path) - Comma-separated list of token addresses. ``` ```json [ { "chainId": "bsc", "dexId": "pancakeswap", "url": "https://dexscreener.com/bsc/0x4ba556e9754a9dedc0f108960283f0535f4c5ff4", "pairAddress": "0x4Ba556E9754a9dedC0F108960283f0535f4c5FF4", "labels": [ "v3" ], "baseToken": { "address": "0x238950013FA29A3575EB7a3D99C00304047a77b5", "name": "Beeper Coin", "symbol": "BEEPER" }, "quoteToken": { "address": "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c", "name": "Wrapped BNB", "symbol": "WBNB" }, "priceNative": "0.0000003488", "priceUsd": "0.0002283", "txns": { "m5": { "buys": 0, "sells": 1 }, "h1": { "buys": 0, "sells": 1 }, "h6": { "buys": 4, "sells": 11 }, "h24": { "buys": 28, "sells": 38 } }, "volume": { "h24": 435.3, "h6": 117.69, "h1": 3.68, "m5": 3.68 }, "priceChange": { "m5": 0.52, "h1": 0.52, "h6": 1.03, "h24": 0.44 }, "liquidity": { "usd": 170298.58, "base": 379990799, "quote": 127.5722 }, "fdv": 2283867, "marketCap": 2283867, "pairCreatedAt": 1735779663000, "info": { "imageUrl": "https://dd.dexscreener.com/ds-data/tokens/bsc/0x238950013fa29a3575eb7a3d99c00304047a77b5.png?key=43bae0", "header": "https://dd.dexscreener.com/ds-data/tokens/bsc/0x238950013fa29a3575eb7a3d99c00304047a77b5/header.png?key=43bae0", "openGraph": "https://cdn.dexscreener.com/token-images/og/bsc/0x238950013fa29a3575eb7a3d99c00304047a77b5?timestamp=1750054500000", "websites": [ { "label": "Website", "url": "https://beeper.fun/" } ], "socials": [ { "type": "twitter", "url": "https://x.com/BeeperBoss" }, { "type": "telegram", "url": "https://t.me/beeper_ai" } ] } } ] ``` -------------------------------- ### Get User Profile API Endpoint Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Retrieves the profile details for a specific username. This GET request requires an Authorization header with a Bearer token and a mandatory `username` parameter. It handles cases where the profile is still building, the user is not found, or parameters are missing. ```APIDOC Endpoint: /api/get_profile Method: GET Headers: Authorization: Bearer Parameters: username: Username (required) Error Cases: If profile is being built: {"success": false, "data": "building..."} If user not found: 404 error If username parameter missing: 400 error If server error occurs: 500 error with error message ``` ```json { "success": true, "data": { // User profile details } } ``` -------------------------------- ### Get User Conversation History API Endpoint Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Retrieves the conversation history for a specified username. This GET request requires an Authorization header with a Bearer token. The `username` parameter is required, and `conversation_id` and `recent_n_messages` are optional. It handles cases of memory not found or missing username. ```APIDOC Endpoint: /api/get_conversation Method: GET Headers: Authorization: Bearer Parameters: username: Username (required) conversation_id: Optional conversation ID (default: ${membase_id}_${username}) recent_n_messages: Optional number of recent messages to retrieve (default: 128) Error Cases: If memory not found: 404 error If username parameter missing: 400 error If server error occurs: 500 error with error message ``` ```json { "success": true, "data": [ { "role": "user", "content": "Hello" }, { "role": "assistant", "content": "Hi there!" } ] } ``` -------------------------------- ### Get Twitter Information (XInfo) API Endpoint Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md Obtains detailed Twitter-related information (XInfo) for a given username. This GET request requires an Authorization header with a Bearer token and a mandatory `username` parameter. It addresses errors like user info not found, building status, or missing parameters. ```APIDOC Endpoint: /api/get_xinfo Method: GET Headers: Authorization: Bearer Parameters: username: Username (required) Error Cases: If user is being built: {"success": false, "data": "Building..."} If user info not found: 404 error If username parameter missing: 400 error If server error occurs: 500 error with error message ``` ```json { "success": true, "data": { // User information details "coverPicture": "https://pbs.twimg.com/profile_banners/44196397/1739948056", "createdAt": "Tue Jun 02 20:12:29 +0000 2009", "favouritesCount": 141046, "followers": 219094983, "following": 1106, "hasCustomTimelines": true, "id": "44196397", "isAutomated": false, "isBlueVerified": true, "isTranslator": false, "isVerified": false, "location": "", "mediaCount": 3775, "name": "Elon Musk", "pinnedTweetIds": [ "1911625269003112683" ], "possiblySensitive": false, "profilePicture": "https://pbs.twimg.com/profile_images/1893803697185910784/Na5lOWi5_normal.jpg", "status": "", "statusesCount": 76951, "twitterUrl": "https://twitter.com/elonmusk", "type": "user", "url": "https://x.com/elonmusk", "userName": "elonmusk" } } ``` -------------------------------- ### Configure AIP Personal Agents Environment Variables Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/README.md This section outlines the essential environment variables required for configuring the AIP Personal Agents system. It includes API keys for various services like Membase, Apify, and OpenAI, along with server settings for Gradio and a bearer token for dashboard access. Users must replace placeholder values with their actual credentials for the system to operate correctly. ```APIDOC MEMBASE_ACCOUNT: string Description: Your Membase account address. MEMBASE_SECRET_KEY: string Description: Your Membase private key. MEMBASE_ID: string Description: Your agent ID. APIFY_API_TOKEN: string Description: Your Apify API token. OPENAI_API_KEY: string Description: Your OpenAI API key. GRADIO_SERVER_NAME: string Description: The IP address for the Gradio server. Default: 127.0.0.1 GRADIO_SERVER_PORT: integer Description: The port for the Gradio server. Default: 7860 BEARER_TOKEN: string Description: Required bearer token for accessing the report dashboard. ``` -------------------------------- ### OpenAI Web3 Trading Assistant Prompt Template Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md This text-based prompt template is used to instruct the OpenAI LLM to act as a Web3 trading assistant. It defines the input variables for token metrics (price, volume, RSI, MAs) and specifies the desired output format: a trading signal and a reason. ```txt You are a Web3 trading assistant. Given the following token metrics, output a trading signal and explain why. Token: ${{token}} Price: ${{price}} 24H Volume: ${{volume_24h}} RSI: {{rsi}} MA7: {{ma7}} MA30: {{ma30}} Return: - Signal (Strong Buy, Buy, Watch, Hold, Sell, Strong Sell) - Reason (based on above metrics) ``` -------------------------------- ### Get User Status API Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md This endpoint retrieves the status information for a specific user. It allows fetching either a single status value by key or the entire status object. ```APIDOC Endpoint: /api/get_status Method: GET Headers: Authorization: Bearer Parameters: username: Username (required) key: Optional key to get specific status value. If not specified, returns entire status object Response Example: ```json // When key is specified { "success": true, "data": "status_value" } // When key is not specified, all status key/value is returned { "success": true, "data": { "one_key": "one_value", "other_key": "other_value" } } ``` Error Cases: If user not found: 404 error If username parameter missing: 400 error If server error occurs: 500 error with error message ``` -------------------------------- ### API Endpoint Summary List Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md A comprehensive list of all available API endpoints, their HTTP methods, expected parameters, and a brief description of their functionality. This table provides a quick overview of the API's capabilities. ```APIDOC Endpoint Summary: /api/list_info: Method: GET Parameters: sort_by, order Description: Get list of all user information /api/get_info: Method: GET Parameters: username Description: Get complete information of specific user /api/list_users: Method: GET Parameters: None Description: List all available users /api/get_xinfo: Method: GET Parameters: username Description: Get user Twitter information /api/get_profile: Method: GET Parameters: username Description: Get user raw profile /api/get_conversation: Method: GET Parameters: username, conversation_id, recent_n_messages Description: Get conversation history /api/set_status: Method: POST Parameters: username, key, value Description: Set user status /api/get_status: Method: GET Parameters: username, key Description: Get user status /api/generate: Method: POST Parameters: username Description: Generate profile for a new user /api/chat: Method: POST Parameters: username, message, prompt, prompt_mode, conversation_id Description: Chat with user personal agent /api/generate_tweet: Method: POST Parameters: username, message, conversation_id Description: Generate tweets based on user profile and input message /api/get_report: Method: GET Parameters: date_str, language, format Description: Get news report for the latest or specific date ``` -------------------------------- ### Retrieve All Tokens via API with Authentication Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/README.md This `curl` command performs a GET request to the `/api/v1/tokens` endpoint to retrieve a list of all available tokens. It requires a Bearer token for authentication, which must be provided in the 'Authorization' header. ```bash curl -X GET \"http://localhost:8000/api/v1/tokens\" \\ -H \"Authorization: Bearer ${API_TOKEN}\" ``` -------------------------------- ### PostgreSQL Schema for Token and Pool Metrics Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/design.md Defines the multi-tiered database schema for storing cryptocurrency token base information, token pools on various DEXs, real-time pool metrics, aggregated token metrics, and historical pool data. Includes table definitions and performance indexes. ```SQL -- Tier 1: Token Base Information CREATE TABLE tokens ( id UUID PRIMARY KEY, name TEXT NOT NULL, symbol TEXT NOT NULL, symbol_lower TEXT NOT NULL, -- for case-insensitive queries contract_address TEXT NOT NULL, chain TEXT NOT NULL, decimals INTEGER DEFAULT 18, image_url TEXT, created_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW(), UNIQUE(contract_address, chain) ); -- Tier 2: Token Pools (Token Pairs on Different DEXs) CREATE TABLE token_pools ( id UUID PRIMARY KEY, base_token_id UUID REFERENCES tokens(id), quote_token_id UUID REFERENCES tokens(id), dex TEXT NOT NULL, -- e.g., 'uniswap-v3', 'pancakeswap' chain TEXT NOT NULL, pair_address TEXT NOT NULL, fee_tier INTEGER, -- e.g., 3000 for 0.3% pool_version TEXT, -- e.g., 'v2', 'v3' created_at TIMESTAMP DEFAULT NOW(), is_active BOOLEAN DEFAULT TRUE, UNIQUE(pair_address, chain, dex) ); -- Tier 3: Pool Metrics (Real-time Pool Data) CREATE TABLE pool_metrics ( id UUID PRIMARY KEY, pool_id UUID REFERENCES token_pools(id), price_usd DECIMAL(20, 10), price_native DECIMAL(30, 18), volume_1h DECIMAL(20, 2), volume_24h DECIMAL(20, 2), liquidity_usd DECIMAL(20, 2), liquidity_base DECIMAL(30, 18), liquidity_quote DECIMAL(30, 18), price_change_1h DECIMAL(10, 4), price_change_24h DECIMAL(10, 4), txns_1h_buys INTEGER DEFAULT 0, txns_1h_sells INTEGER DEFAULT 0, txns_24h_buys INTEGER DEFAULT 0, txns_24h_sells INTEGER DEFAULT 0, market_cap DECIMAL(20, 2), fdv DECIMAL(20, 2), -- Fully Diluted Valuation data_source TEXT, -- 'dexscreener', 'moralis', 'birdeye' updated_at TIMESTAMP DEFAULT NOW() ); -- Tier 4: Token Metrics (Aggregated from All Pools) CREATE TABLE token_metrics ( id UUID PRIMARY KEY, token_id UUID REFERENCES tokens(id), -- Aggregated Price Data avg_price_usd DECIMAL(20, 10), weighted_price_usd DECIMAL(20, 10), -- Volume weighted total_volume_24h DECIMAL(20, 2), total_liquidity_usd DECIMAL(20, 2), market_cap DECIMAL(20, 2), -- Technical Indicators rsi_14d FLOAT, ma_7d FLOAT, ma_30d FLOAT, volatility_24h FLOAT, -- On-chain Metrics holder_count INTEGER, unique_traders_24h INTEGER, -- Signals breakout_signal BOOLEAN DEFAULT FALSE, trend_direction TEXT CHECK (trend_direction IN ('bullish', 'bearish', 'sideways')), signal_strength FLOAT CHECK (signal_strength >= 0 AND signal_strength <= 1), -- Meta pools_count INTEGER DEFAULT 0, last_calculation_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW() ); -- Historical Data for Time Series Analysis CREATE TABLE pool_metrics_history ( id UUID PRIMARY KEY, pool_id UUID REFERENCES token_pools(id), price_usd DECIMAL(20, 10), volume_24h DECIMAL(20, 2), liquidity_usd DECIMAL(20, 2), recorded_at TIMESTAMP NOT NULL ); -- Indexes for Performance CREATE INDEX idx_tokens_symbol_lower ON tokens(symbol_lower); CREATE INDEX idx_tokens_contract_chain ON tokens(contract_address, chain); CREATE INDEX idx_pool_metrics_pool_updated ON pool_metrics(pool_id, updated_at); CREATE INDEX idx_pool_metrics_history_recorded ON pool_metrics_history(pool_id, recorded_at); CREATE INDEX idx_token_metrics_updated ON token_metrics(token_id, updated_at); ``` -------------------------------- ### Configure Legacy MCP Tool Server in AIP Agent YAML Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_tools/README.md This YAML configuration snippet demonstrates how to integrate a legacy MCP tool server into the `aip_agent.config.yaml` file. It defines server details like transport, URL, and command-line arguments for running the Membase MCP server, along with specific environment variables for its operation. ```yaml mcp: servers: agent_hub: transport: "aip-sse" url: "http://127.0.0.1:8080" membase: command: uv args: [ "--directory", "../../../membase-mcp", "run", "src/membase_mcp/server.py", ] env: MEMBASE_ACCOUNT: membase-mcp-test MEMBASE_CONVERSATION_ID: conversation_test MEMBASE_ID: mcp ``` -------------------------------- ### Python Project Dependency List Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_dex/requirements.txt This snippet details the Python packages and their exact version constraints necessary for the `/unibaseio/aip-agent` project. This list is typically found in a `requirements.txt` file and is crucial for setting up a consistent and reproducible development and deployment environment. ```Python fastapi==0.104.1 uvicorn==0.24.0 sqlalchemy==2.0.23 sqlalchemy_utils==0.41.2 psycopg2-binary==2.9.9 alembic==1.12.1 openai==1.3.5 httpx==0.25.2 python-dotenv==1.0.0 pydantic==2.5.0 pandas==2.1.4 numpy==1.25.2 ``` -------------------------------- ### API Reference: GET /api/get_report Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/templates/report.html Documentation for the backend API endpoint used to retrieve various types of reports. This endpoint supports filtering by date, language, format, and type, and requires authentication via a bearer token. ```APIDOC GET /api/get_report Description: Retrieves a report based on specified criteria. Query Parameters: language (string, required): The language of the report (e.g., 'en', 'es'). format (string, required): The desired format of the report (e.g., 'json', 'markdown'). type (string, required): The type of report to retrieve (e.g., 'daily', 'weekly', 'monthly'). date_str (string, optional): A specific date for the report in 'YYYY-MM-DD' format. If omitted, the latest report is returned. Headers: Authorization (string, required): Bearer token for authentication. Example: 'Bearer YOUR_TOKEN_HERE' Content-Type (string, required): Must be 'application/json'. Responses: 200 OK: success (boolean): True if the report was fetched successfully. data (object | string): The report content, formatted as specified by the 'format' parameter. 400 Bad Request: detail (string): Error message indicating invalid parameters. 401 Unauthorized: detail (string): Error message indicating missing or invalid authentication token. 500 Internal Server Error: detail (string): Generic server error message. ``` -------------------------------- ### Python: Interact with AIP Agent API Endpoints Source: https://github.com/unibaseio/aip-agent/blob/main/examples/aip_personal_agents/api.md This Python script demonstrates how to make authenticated API calls to the AIP agent. It covers common operations such as listing users, fetching specific user information, and sending chat messages, utilizing the `requests` library for HTTP requests and bearer token authentication. ```python import requests BASE_URL = "http://localhost:5001" TOKEN = "your_bearer_token" headers = { "Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json" } # List all users response = requests.get(f"{BASE_URL}/api/list_users", headers=headers) users = response.json()["data"] # Get user info username = "example_user" response = requests.get(f"{BASE_URL}/api/get_info?username={username}", headers=headers) user_info = response.json()["data"] # Chat with user chat_data = { "username": username, "message": "Hello!", "conversation_id": "optional_conversation_id" } response = requests.post(f"{BASE_URL}/api/chat", headers=headers, json=chat_data) chat_response = response.json()["data"] ```