starklens-ai
v0.0.2
Published
Node.js package that allows you to query swap intents on Starknet using OpenAI's language model.
Downloads
3
Readme
StarkLens Retrieval AI
Node.js package that allows you to query swap intents on Starknet using OpenAI's language model.
Installation
npm install starklens-ai
Usage
import { fetchQueryResponse } from "starklens-ai";
Example
You can use the fetchQueryResponse
function to fetch data from the API. This function takes the following parameters:
question
: The query string you want to ask.apiKey
: Your OpenAI API key.data
: The transaction data you want to query.
const sampleData = swapIntents; // indexer/subgraph
const question = "What are the current swap trades available?";
try {
const result = await fetchQueryResponse(
question,
process.env.OPENAI_API_KEY as string,
sampleData
);
return result;
} catch (error) {
console.error("Error fetching query response:", error);
}
// fetchQueryResponse
// classification: open transaction
{
"text": "Currently, the only open swap trade available is swap-intent-1.",
"attachments": [
{
"id": "swap-intent-1",
"creator": "0x1234567890",
"status": "Open",
"created_at": 1687334400,
"updated_at": 1687334400,
"from": {
"address": "0x1111111111",
"ticker": "usdc",
"amount": 5000
},
"to": {
"address": "0x1111111111",
"ticker": "aero",
"amount": 3000
},
"rate": 1.67,
"min_swap_amount": 1000,
"filled_amount": 0,
"gated": {}
}
]
}
Testing
npm test