LlamaIndex ଅର୍ଥପ୍ରଦାନ ଇଣ୍ଟେଗ୍ରେସନ୍।
LlamaIndex package ନାହିଁ, ଏବଂ ଆପଣଙ୍କୁ ତାହା ଦରକାର ମଧ୍ୟ ନାହିଁ। ଆସଲ blockchain0x client କୁ FunctionTool ଭିତରେ wrap କରନ୍ତୁ ଏବଂ ଆପଣଙ୍କ agent Base ଉପରେ USDC move କରିପାରିବ ଏବଂ paid RAG query କୁ gate କରିପାରିବ।
LlamaIndex-ନିର୍ଦ୍ଦିଷ୍ଟ କୌଣସି package ନାହିଁ, ଏବଂ ଆପଣଙ୍କୁ ଦରକାର ମଧ୍ୟ ନାହିଁ। LlamaIndex ସହିତ ସାଧାରଣ function କୁ tool ରେ ପରିଣତ କରେ, ସେଥିପାଇଁ ଆପଣ ସତ୍ୟ Python client କୁ function ଭିତରେ wrap କରି କିମ୍ବା ରେ add କରନ୍ତୁ। agent USDC ପଠାଇପାରେ, invoice settle କରିପାରେ, ଏବଂ wallet ପଢ଼ିପାରେ। ପ୍ରତି RAG query ରେ ଶୁଳ୍କ ନେବାକୁ, ଆପଣଙ୍କ own QueryEngineTool କୁ ସେଇ ଭଳି gate କରନ୍ତୁ। Payments Base ରେ settle ହୁଏ।
RAG ପ୍ରଶ୍ନଗୁଡିକ ମହଙ୍ଗା। ପ୍ରତି ପ୍ରଶ୍ନ ଦେଇ ଚାର୍ଜ୍ କରିବା ଅର୍ଥନୀତିକୁ କାମ କରେ।
LlamaIndex ର strength ହେଉଛି retrieval-augmented generation: proprietary documents (ଆପଣଙ୍କ company ର docs, research dataset, legal corpus) ଉପରେ ଏକ vector index ଅଛି, ଏବଂ agent ସମ୍ପର୍କିତ chunks କୁ retrieve ଏବଂ summarize କରି answer ଦେଇଥାଏ। ପ୍ରତ୍ୟେକ query embeddings, LLM tokens, ଏବଂ ପ୍ରାୟତଃ third-party API calls ରେ ଆସଲ ଟଙ୍କା ଖର୍ଚ୍ଚ କରେ। Free unlimited access budget ଜଳାଇଦିଏ; per-query billing cost shape ସହିତ ମେଳ ଖାଏ।
ଏଥିପାଇଁ shipped helper ନାହିଁ, ଏବଂ ଆପଣଙ୍କୁ ତାହା ଦରକାର ମଧ୍ୟ ନାହିଁ। ଆପଣ ନିଜେ ଏହାକୁ gate କରନ୍ତୁ: ଆପଣଙ୍କ QueryEngineTool ର function ଭିତରେ caller payment କରିଛି କି ନାହିଁ ଯାଞ୍ଚ କରନ୍ତୁ (payment webhook ଦ୍ୱାରା ଫ୍ଲିପ୍ ହୋଇଥିବା ନିଜ flag), ଏବଂ retrieval ଚଳାନ୍ତୁ କିମ୍ବା price ଫେରାନ୍ତୁ। wallet function ଏବଂ gating ଦୁହେଁ ଆସଲ blockchain0x client ଉପରେ କେବଳ କିଛି line, ଯାହା policy - per query, per session, free tier ପରେ paid - ସମ୍ପୂର୍ଣ୍ଣ ଆପଣଙ୍କ ହାତରେ ରଖେ।
LlamaIndex ଏବଂ core SDK ଇନଷ୍ଟଲ୍ କରନ୍ତୁ। ଗୋଟିଏ environment variable।
ଯୋଡିବା ପାଇଁ blockchain0x LlamaIndex package ନାହିଁ। ଆପଣ LlamaIndex (Python 3.10+, modern FunctionAgent / ReActAgent / Workflows APIs) ଏବଂ ଆସଲ blockchain0x core SDK install କରନ୍ତୁ, ତାପରେ ତଳେ ଥିବା function ଲେଖନ୍ତୁ। ଯେକୌଣସି vector store ସହିତ କାମ କରେ - Pinecone, Qdrant, Chroma, Weaviate, LlamaIndex Cloud।
pip install llama-index blockchain0xexport BLOCKCHAIN0X_API_KEY=sk_test_... # sk_test_ = Base Sepolia, sk_live_ = Base mainnet
BLOCKCHAIN0X_API_KEY ହେଉଛି ଆପଣଙ୍କ dashboard ରୁ ମିଳୁଥିବା sk_test_ testnet କିମ୍ବା sk_live_ mainnet key; client ଏହାକୁ environment ରୁ ପଢ଼େ। ଯଦି ଆପଣ paid queries gate କରନ୍ତି, webhook handler କୁ ଅତିରିକ୍ତ ଭାବେ BLOCKCHAIN0X_WEBHOOK_SECRET ଆବଶ୍ୟକ, ଯାହା dashboard webhook create କିମ୍ବା rotate କରିବାବେଳେ ଗୋଟିଏଥର ଦେଉଛି।
ପେ କରୁଥିବା ଏକ function, FunctionTool ଭାବେ wrapped।
ନିମ୍ନରେ ସମ୍ପୂର୍ଣ୍ଣ integration ଅଛି। send_usdc real blockchain0x client କୁ call କରେ; FunctionTool.from_defaults ଏହାକୁ wrap କରେ, ଏବଂ FunctionAgent ଏହାକୁ callable tool ଭାବେ ଧରେ। LlamaIndex schema build କରିବା ପାଇଁ type hints ଏବଂ docstring ପଢେ। ତାଲିକାରେ ନିଜ QueryEngineTool ଯୋଡନ୍ତୁ ଏବଂ ସେହି agent RAG queries ମଧ୍ୟ answer କରିପାରିବ।
from llama_index.core.tools import FunctionTool from llama_index.core.agent.workflow import FunctionAgent from llama_index.llms.openai import OpenAI from blockchain0x import Client blockchain0x = Client() # reads BLOCKCHAIN0X_API_KEY from the environment def send_usdc(agent_id: str, to: str, amount_wei: str) -> str: """Send a USDC payment from an agent wallet. amount_wei is USDC base units (6 decimals), so "10000" is 0.01 USDC. """ return str( blockchain0x.payments.create(body={"agentId": agent_id, "to": to, "amountWei": amount_wei}) ) # Wrap the plain function as a LlamaIndex tool. No dedicated package needed. pay_tool = FunctionTool.from_defaults(fn=send_usdc) agent = FunctionAgent( tools=[pay_tool], # plus your own QueryEngineTool over a RAG index llm=OpenAI(model="gpt-4o"), system_prompt="You pay vendor invoices in USDC within owner-set limits.", ) response = await agent.run( "Pay 0.01 USDC from agent agt_123 to 0xVendor for the dataset." )
When the agent decides to pay, it calls send_usdc, the SDK submits the transfer, and you get a transaction hash back. amount_wei is base units, so 0.01 USDC is "10000". A sk_test_ key keeps it on Base Sepolia until you switch to sk_live_. To charge for a query instead, put the same paid check at the top of your QueryEngineTool's function.
ଯେତେବେଳେ ୱେବହୁକ୍ ଲାଣ୍ଡ୍ କରେ, ଭୁଗତାନ ଝଣ୍ଡାକୁ ଫ୍ଲିପ୍ କରନ୍ତୁ।
ପେମେଣ୍ଟ ସେଟଲ୍ ହେଲେ, Blockchain0x ଆପଣଙ୍କ webhook URL କୁ signed payment.received event POST କରେ। verify helper Node SDK ରେ ship ହୁଏ; Python service ରେ ଆପଣ documented HMAC ସହିତ ହାତେ verify କରନ୍ତି। ଆପଣଙ୍କ ନିଜ store ରେ caller କୁ paid ବୋଲି ଚିହ୍ନଟ କରନ୍ତୁ, ଏବଂ ଆପଣଙ୍କ gated query tool ପରବର୍ତ୍ତୀ call କୁ ଅନୁମତି ଦେଏ। ନିମ୍ନରେ FastAPI example.
import hmac, hashlib, os, time from fastapi import FastAPI, Request, HTTPException app = FastAPI() SECRET = os.environ["BLOCKCHAIN0X_WEBHOOK_SECRET"].encode() @app.post("/webhooks/payment") async def receive(request: Request): raw = await request.body() # RAW bytes - do not parse first sig = request.headers.get("X-Blockchain0x-Signature", "") ts = request.headers.get("X-Blockchain0x-Timestamp", "") parts = dict(p.split("=", 1) for p in sig.split(",") if "=" in p) t, v1 = parts.get("t", ts), parts.get("v1", sig) want = hmac.new(SECRET, t.encode() + b"." + raw, hashlib.sha256).hexdigest() if not hmac.compare_digest(want, v1) or abs(time.time() - int(t)) > 300: raise HTTPException(status_code=401) if request.headers.get("X-Blockchain0x-Event-Type") == "payment.received": await trigger_followup() # USDC landed - serve the paid query return {"ok": True}
algorithm ଟି t.rawBody string ଉପରେ HMAC-SHA256, constant-time compare, ଏବଂ 300-second replay window ବ୍ୟବହାର କରେ। await request.body() ମାଧ୍ୟମରେ raw body ପଢ଼ନ୍ତୁ, କେବେ ମଧ୍ୟ request.json() re-serialized କରନ୍ତୁ ନାହିଁ, କାରଣ ଏହା signature ଆବର୍ତ୍ତିତ bytes କୁ ପରିବର୍ତ୍ତନ କରେ। shipped events ହେଉଛି payment.received, payment.sent, wallet.deployed, ଏବଂ webhook.test। heavy follow-up work ପାଇଁ, job (Celery, arq) enqueue କରନ୍ତୁ ଏବଂ handler କୁ block କରିବା ପେକ୍ଷା ସତ୍ୱର 200 respond କରନ୍ତୁ।
ଆପଣ wrap କରୁଥିବା client open ଅଟେ। ଏହାକୁ ପଢ଼ନ୍ତୁ।
Clone କରିବା ପାଇଁ LlamaIndex starter package ନାହିଁ - ଉପରେ ଥିବା recipe ହିଁ integration। blockchain0x SDKs GitHub ଉପରେ open source ଅଟେ; ଏହି recipe Python SDK (blockchain0x-python) କୁ wrap କରେ, ଏବଂ docs ରେ full method surface ଅଛି। function bodies ପାଇଁ reference ଭାବେ ଏହାକୁ ପଢନ୍ତୁ।
github.com/tosh-labs/blockchain0x-pythonFull SDK method surface ଏବଂ scopes the docs ରେ documented ଅଛି। Base Sepolia ବିରୁଦ୍ଧରେ sk_test_ key ରୁ ଆରମ୍ଭ କରନ୍ତୁ, ପରେ function ଆପଣ ଆଶା କରୁଥିବାଭଳି କାମ କଲେ sk_live_ କୁ switch କରନ୍ତୁ।
ଲ୍ୟାମାଇଣ୍ଡେକ୍ସ-ନିର୍ଦ୍ଦିଷ୍ଟ ଜାଲକୁ ଏଡାଇବାକୁ ପାଞ୍ଚ ଜାଲ।
ଏହାଗୁଡିକ ଆମର ସମର୍ଥନ ଇନବକ୍ସରୁ ଆସିଛି। ପ୍ରତିଟି ଏକ ଘଣ୍ଟାରୁ ଅଧିକ ଡିବଗିଂ ସଂରକ୍ଷଣ କରେ ଯେତେବେଳେ ଆପଣ ଏହା ବିଷୟରେ ଜାଣିଛନ୍ତି।
LlamaIndex package ନାହିଁ - ଆପଣ SDK କୁ wrap କରନ୍ତି
Blockchain0x LangChain ଏବଂ CrewAI ପାଇଁ adapters ସହିତ MCP server ମଧ୍ୟ ship କରେ; LlamaIndex ପାଇଁ dedicated package ନାହିଁ। ଉପରେ ଥିବା recipe ହିଁ path: ଏକ ସାଧାରଣ typed function, ଯାହା real blockchain0x client କୁ call କରେ, ଏବଂ FunctionTool.from_defaults ସହିତ wrapped ହୋଇଥାଏ। LlamaIndex schema build କରିବା ପାଇଁ signature ଏବଂ docstring ପଢେ, ସେଥିପାଇଁ docstring କୁ ସଠିକ୍ ରଖନ୍ତୁ।
ଗେଟ୍ ଏକ QueryEngineTool ନିଜେ - କୌଣସି ସାହାୟକ ଏହା କରେ ନାହିଁ
paid-RAG pattern ପ୍ରକୃତ ଏବଂ ଭଲ, କିନ୍ତୁ paid_query_engine_tool helper ନାହିଁ। ଆପଣ ଏହାକୁ ନିଜେ ତିଆରି କରନ୍ତୁ: ଆପଣଙ୍କ query tool ର function ଭିତରେ, caller ଦେୟ କରିଛି କି ନାହିଁ ଯାଞ୍ଚ କରନ୍ତୁ (ତଳେ webhook ଦ୍ୱାରା update ହୁଏଥିବା ଆପଣଙ୍କ own store) ଏବଂ ଯଦି କରିଛି ତେବେ ମାତ୍ର retrieval ଚଳାନ୍ତୁ, ନଚେତ୍ price ଫେରାନ୍ତୁ। ଏହା କେବଳ କିଛି line, ଏବଂ gating policy ଉପରେ ଆପଣଙ୍କ control ରହେ।
ରାଶିଗୁଡ଼ିକ USDC base units ରେ, string ଭାବେ
payments.create takes amountWei: a string of USDC base units, not a float. USDC has 6 decimals, so 0.01 USDC is "10000" and 5 USDC is "5000000". Type the tool argument as str. LlamaIndex passes tool args through pydantic, which will happily coerce a float and lose precision, so keep it a string end to end.
FunctionAgent.run ଏସିଂକ୍; SDK କଲ୍ ସିଙ୍କ୍
LlamaIndex agents async-first - await agent.run(...). ଆପଣଙ୍କ tool ଭିତରେ blockchain0x client call synchronous, ଯାହା ଏକ ଶୀଘ୍ର payment ପାଇଁ ଠିକ୍, କିନ୍ତୁ load ରେ loop କୁ block କରେ। ଯଦି ଆପଣ ଅନେକ concurrent queries serve କରୁଛନ୍ତି, SDK call କୁ asyncio.to_thread ସହିତ wrap କରନ୍ତୁ ଯାହାଦ୍ୱାରା event loop responsive ରହିବ।
send_payment ପ୍ରାରମ୍ଭରେ 503 ଫେରାଇପାରେ
payments.create default ଭାବରେ retry କରେ ନାହିଁ ଏବଂ chain adapter ଆପଣଙ୍କ network ପାଇଁ wired ହେଉପର୍ଯ୍ୟନ୍ତ 503 ଫେରାଇପାରେ। error କୁ ଆପଣଙ୍କ tool function ଭିତରେ ଧରନ୍ତୁ ଏବଂ model କାର୍ଯ୍ୟ କରିପାରିବା ପାଇଁ ଏକ ସ୍ପଷ୍ଟ message ଫେରାନ୍ତୁ, agent loop କରିବାକୁ ଦିଅନ୍ତୁ ନାହିଁ। auto-minted idempotency key ଅର୍ଥ manual retry ଦୁଇଥର ଭୁଗତାନ କରିବ ନାହିଁ।