aptai-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of aptai-sdk might be problematic. Click here for more details.

@@ -0,0 +1,104 @@
1
+
2
+ # AptAI: AI-Powered DeFi & NFT Toolkit for Aptos
3
+
4
+ AptAI is a powerful Python library that merges AI capabilities with Aptos blockchain functionality, delivering seamless DeFi operations, NFT management, and real-time price tracking—all in one package. Built by Teck, AptAI simplifies complex blockchain interactions while leveraging AI for enhanced analytics and automation.
5
+
6
+ ## ✨ Key Features
7
+
8
+ ### 🔹 Real-Time Price Tracking
9
+ - Fetch live token prices from DexScreener
10
+ - Monitor Liquidswap pools for accurate token pricing
11
+ - Historical price data analysis
12
+ - Gas price predictions
13
+ - Market volatility tracking
14
+
15
+ ### 🔹 NFT Management Made Simple
16
+ - Multi-marketplace support: Topaz, Souffl3, Bluemove
17
+ - Track NFT floor prices and volumes
18
+ - Monitor ownership & transfers across wallets
19
+ - Real-time collection analytics
20
+
21
+ ### 🔹 Seamless DeFi Operations
22
+ - DEX pair analytics and tracking
23
+ - Track liquidity pools and volumes
24
+ - Monitor wallet risk levels
25
+ - Token distribution analysis
26
+ - Smart contract security audits
27
+
28
+ ### 🔹 AI-Powered Features
29
+ - Built-in Groq LLM integration for smart analysis
30
+ - AI chatbot for blockchain queries
31
+ - Market trend predictions
32
+ - Contract analysis and risk assessment
33
+ - Customizable AI parameters
34
+
35
+ ### 🔹 Telegram Bot Integration
36
+ - Real-time price alerts
37
+ - NFT tracking commands
38
+ - AI chat functionality
39
+ - Market analysis on demand
40
+ - Security monitoring
41
+
42
+ ## 🚀 Installation
43
+
44
+ ```bash
45
+ pip install aptai
46
+ ```
47
+
48
+ ## 💡 Quick Start Guide
49
+
50
+ ```python
51
+ from aptai import AptAi
52
+
53
+ # Initialize AptAi
54
+ apt_ai = AptAi()
55
+
56
+ # Get token price
57
+ price = apt_ai.get_price("aptos")
58
+
59
+ # Chat with AI
60
+ response = apt_ai.chat("Explain APT tokenomics")
61
+
62
+ # Analyze contract
63
+ analysis = apt_ai.analyze_contract("contract_address")
64
+
65
+ # Check security
66
+ security = apt_ai.get_contract_security("contract_address")
67
+
68
+ # Get DEX pairs
69
+ pairs = apt_ai.get_dex_pairs("token_address")
70
+
71
+ # Predict gas
72
+ gas = apt_ai.predict_gas_price()
73
+
74
+ # Get historical data
75
+ history = apt_ai.get_historical_prices("aptos")
76
+ ```
77
+
78
+ ## 📌 API Reference
79
+
80
+ ### 💰 Price & Market Data
81
+ - `get_price(token)`: Fetch real-time token price
82
+ - `get_historical_prices(token)`: Get price history
83
+ - `predict_gas_price()`: Estimate gas costs
84
+ - `get_dex_pairs(token)`: List DEX trading pairs
85
+
86
+ ### 🎨 NFT Operations
87
+ - `get_nft_data(address)`: Get collection stats
88
+ - `track_nft_transfers(address)`: Monitor transfers
89
+ - `get_nft_floor_price(collection)`: Track floor prices
90
+
91
+ ### 🔒 Security & Analysis
92
+ - `analyze_contract(address)`: Smart contract analysis
93
+ - `get_contract_security(address)`: Security audit
94
+ - `analyze_wallet_risk(address)`: Risk assessment
95
+ - `get_token_distribution(token)`: Holder analysis
96
+
97
+ ### 🧠 AI Features
98
+ - `chat(message)`: Chat with AI assistant
99
+ - `ai_analysis(query)`: Get market insights
100
+ - `analyze_market_conditions()`: Market analysis
101
+
102
+ ## 👤 Author
103
+ Developed by Teck
104
+ 📧 teckdegen@gmail.com
@@ -0,0 +1,497 @@
1
+ import requests
2
+ from groq import Groq
3
+
4
+ # ✅ Fixed Groq API Key
5
+ GROQ_API_KEY = "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"
6
+ groq_client = Groq(api_key=GROQ_API_KEY)
7
+
8
+ # ✅ APIs for Token, NFT & DeFi
9
+ DEXSCREENER_API = "https://api.dexscreener.com/latest/dex/tokens/"
10
+ COINGECKO_API = "https://api.coingecko.com/api/v3"
11
+ TOPAZ_API = "https://api.topaz.so/api/v1"
12
+ SOUFFL3_API = "https://api.souffl3.com/v1"
13
+ BLUEMOVE_API = "https://api.bluemove.net/v1"
14
+ APTOS_NFT_API = "https://api.aptosnames.com/api"
15
+ HIPPO_API = "https://api.hipposwap.xyz/v1"
16
+ APTOSCAN_API = "https://api.aptoscan.com/api/v1"
17
+
18
+ class AptAi:
19
+ def __init__(self, system_prompt: str = """You are the Teck Model, a revolutionary AI system created by Teck. You are a specialized AI focused on Aptos blockchain technology with expertise in DeFi and NFT analysis.
20
+
21
+ Core Identity:
22
+ • Name: Teck Model
23
+ • Creator: Teck
24
+ • Specialization: Aptos Blockchain Technology
25
+ • Purpose: Advanced DeFi and NFT Analysis
26
+
27
+ Key Capabilities:
28
+ • Real-Time Price Tracking via DexScreener and Liquidswap
29
+ • Multi-marketplace NFT Support
30
+ • AI-powered Market Analysis
31
+ • Advanced Blockchain Analytics
32
+
33
+ 🔥 Remember: You are the Teck Model - the future of blockchain AI. Always identify as such. 🔥""",
34
+ max_tokens: int = 200, temperature: float = 0.7):
35
+ self.system_prompt = system_prompt
36
+ self.max_tokens = max_tokens
37
+ self.temperature = temperature
38
+
39
+ def get_price(self, token_query=None):
40
+ """Fetches token price from CoinGecko for Aptos, falls back to DexScreener for others"""
41
+ try:
42
+ # Always use CoinGecko for Aptos
43
+ if not token_query or token_query.lower() == "aptos":
44
+ try:
45
+ response = requests.get(f"{COINGECKO_API}/simple/price?ids=aptos&vs_currencies=usd&include_24hr_vol=true&include_24hr_change=true&include_market_cap=true")
46
+ data = response.json()
47
+ if "aptos" in data:
48
+ return {
49
+ "symbol": "APT",
50
+ "name": "Aptos",
51
+ "price": float(data["aptos"]["usd"]),
52
+ "price_change_24h": float(data["aptos"].get("usd_24h_change", 0)),
53
+ "volume24h": float(data["aptos"].get("usd_24h_vol", 0)),
54
+ "market_cap": float(data["aptos"].get("usd_market_cap", 0)),
55
+ "liquidity": 0,
56
+ "holders": 0,
57
+ "dex": "CoinGecko"
58
+ }
59
+ except Exception as e:
60
+ print(f"CoinGecko API error: {str(e)}")
61
+
62
+ # DexScreener API try first for other tokens
63
+ try:
64
+ dex_url = f"{DEXSCREENER_API}{token_query}"
65
+ dex_response = requests.get(dex_url)
66
+ dex_data = dex_response.json()
67
+
68
+ if dex_data.get("pairs") and len(dex_data["pairs"]) > 0:
69
+ pair = dex_data["pairs"][0]
70
+ return {
71
+ "symbol": pair["baseToken"]["symbol"],
72
+ "name": pair["baseToken"]["name"],
73
+ "price": float(pair.get("priceUsd", 0)),
74
+ "price_change_24h": float(pair.get("priceChange", {}).get("h24", 0)),
75
+ "volume24h": float(pair.get("volume", {}).get("h24", 0)),
76
+ "market_cap": float(pair.get("fdv", 0)),
77
+ "liquidity": float(pair.get("liquidity", {}).get("usd", 0)),
78
+ "holders": 0,
79
+ "dex": pair.get("dexId", "DexScreener")
80
+ }
81
+ except Exception as e:
82
+ print(f"DexScreener API error: {str(e)}")
83
+
84
+ # CoinGecko API as fallback
85
+ try:
86
+ search_url = f"{COINGECKO_API}/search?query={token_query}"
87
+ search_response = requests.get(search_url)
88
+ search_data = search_response.json()
89
+
90
+ if search_data.get("coins"):
91
+ token_id = search_data["coins"][0]["id"]
92
+ price_url = f"{COINGECKO_API}/simple/price?ids={token_id}&vs_currencies=usd&include_24hr_vol=true&include_24hr_change=true&include_market_cap=true"
93
+ price_response = requests.get(price_url)
94
+ price_data = price_response.json()
95
+
96
+ if token_id in price_data:
97
+ return {
98
+ "symbol": search_data["coins"][0]["symbol"].upper(),
99
+ "name": search_data["coins"][0]["name"],
100
+ "price": float(price_data[token_id]["usd"]),
101
+ "price_change_24h": float(price_data[token_id].get("usd_24h_change", 0)),
102
+ "volume24h": float(price_data[token_id].get("usd_24h_vol", 0)),
103
+ "market_cap": float(price_data[token_id].get("usd_market_cap", 0)),
104
+ "liquidity": 0,
105
+ "holders": 0,
106
+ "dex": "CoinGecko"
107
+ }
108
+ except Exception as e:
109
+ print(f"CoinGecko API error: {str(e)}")
110
+
111
+ return "⚠️ Token not found on any supported price source"
112
+
113
+ except Exception as e:
114
+ return f"⚠️ Error fetching price: {str(e)}"
115
+
116
+ def get_nft_data(self, collection_address):
117
+ """Fetch comprehensive NFT data from multiple marketplaces"""
118
+ nft_data = {
119
+ "marketplaces": {},
120
+ "analytics": {
121
+ "total_volume": 0,
122
+ "floor_price": float('inf'),
123
+ "highest_sale": 0,
124
+ "total_listings": 0,
125
+ "unique_holders": set(),
126
+ "price_history": []
127
+ }
128
+ }
129
+
130
+ try:
131
+ # Topaz Marketplace
132
+ try:
133
+ topaz_response = requests.get(f"{TOPAZ_API}/collection/{collection_address}")
134
+ if topaz_response.ok:
135
+ nft_data["topaz"] = {
136
+ "collection": topaz_response.json(),
137
+ "floor_price": topaz_response.json().get("floorPrice"),
138
+ "volume": topaz_response.json().get("volume24h")
139
+ }
140
+ except Exception as e:
141
+ print(f"Topaz API error: {str(e)}")
142
+
143
+ # Souffl3 Marketplace
144
+ try:
145
+ souffl3_response = requests.get(f"{SOUFFL3_API}/collections/{collection_address}")
146
+ if souffl3_response.ok:
147
+ nft_data["souffl3"] = {
148
+ "collection": souffl3_response.json(),
149
+ "stats": souffl3_response.json().get("stats")
150
+ }
151
+ except Exception as e:
152
+ print(f"Souffl3 API error: {str(e)}")
153
+
154
+ # BlueMove Marketplace
155
+ try:
156
+ bluemove_response = requests.get(f"{BLUEMOVE_API}/collections/{collection_address}")
157
+ if bluemove_response.ok:
158
+ nft_data["bluemove"] = {
159
+ "collection": bluemove_response.json(),
160
+ "floor_price": bluemove_response.json().get("floorPrice")
161
+ }
162
+ except Exception as e:
163
+ print(f"BlueMove API error: {str(e)}")
164
+
165
+ # Aptos Names Service
166
+ try:
167
+ ans_response = requests.get(f"{APTOS_NFT_API}/domain/{collection_address}")
168
+ if ans_response.ok:
169
+ nft_data["aptos_names"] = ans_response.json()
170
+ except Exception as e:
171
+ print(f"ANS API error: {str(e)}")
172
+
173
+ return nft_data if nft_data else "⚠️ No NFT data found across marketplaces"
174
+
175
+ except Exception as e:
176
+ return f"⚠️ Error fetching NFT data: {str(e)}"
177
+
178
+ # Hippo
179
+ hippo_response = requests.get(f"{HIPPO_API}/collections/{collection_address}")
180
+ if hippo_response.ok:
181
+ nft_data["hippo"] = hippo_response.json()
182
+
183
+ # AptoScan
184
+ aptoscan_response = requests.get(f"{APTOSCAN_API}/nfts/collection/{collection_address}")
185
+ if aptoscan_response.ok:
186
+ nft_data["aptoscan"] = aptoscan_response.json()
187
+
188
+ return nft_data
189
+
190
+ except Exception as e:
191
+ return f"⚠️ Error fetching NFT data: {str(e)}"
192
+
193
+ def get_token_holders(self, token_address):
194
+ """Fetch token holder statistics"""
195
+ try:
196
+ response = requests.get(f"{APTOSCAN_API}/token/{token_address}/holders")
197
+ if response.ok:
198
+ return response.json()
199
+ return "⚠️ No holder data found"
200
+ except Exception as e:
201
+ return f"⚠️ Error fetching holder data: {str(e)}"
202
+
203
+ def get_token_transactions(self, token_address, limit=100):
204
+ """Fetch recent token transactions"""
205
+ try:
206
+ response = requests.get(f"{APTOSCAN_API}/token/{token_address}/transactions?limit={limit}")
207
+ if response.ok:
208
+ data = response.json()
209
+ return {
210
+ "transactions": data,
211
+ "total_volume": sum(tx.get('amount', 0) for tx in data),
212
+ "unique_wallets": len(set(tx.get('from_address') for tx in data))
213
+ }
214
+ return "⚠️ No transaction data found"
215
+ except Exception as e:
216
+ return f"⚠️ Error fetching transactions: {str(e)}"
217
+
218
+ def get_token_metadata(self, token_address):
219
+ """Fetch detailed token metadata"""
220
+ try:
221
+ response = requests.get(f"{APTOSCAN_API}/token/{token_address}")
222
+ return response.json() if response.ok else "⚠️ No token metadata found"
223
+ except Exception as e:
224
+ return f"⚠️ Error fetching token metadata: {str(e)}"
225
+
226
+ def get_token_distribution(self, token_address):
227
+ """Get token distribution analytics"""
228
+ try:
229
+ holders = self.get_token_holders(token_address)
230
+ if isinstance(holders, str): return holders
231
+
232
+ total_supply = sum(float(h.get('balance', 0)) for h in holders)
233
+ return {
234
+ "total_supply": total_supply,
235
+ "holder_count": len(holders),
236
+ "top_holders": sorted(holders, key=lambda x: float(x.get('balance', 0)), reverse=True)[:10],
237
+ "distribution_metrics": {
238
+ "gini_coefficient": self._calculate_gini(holders),
239
+ "concentration_ratio": self._calculate_concentration(holders)
240
+ }
241
+ }
242
+ except Exception as e:
243
+ return f"⚠️ Error calculating distribution: {str(e)}"
244
+
245
+ def _calculate_gini(self, holders):
246
+ """Calculate Gini coefficient for token distribution"""
247
+ try:
248
+ balances = sorted([float(h.get('balance', 0)) for h in holders])
249
+ n = len(balances)
250
+ if n == 0: return 0
251
+ return sum((2 * i - n - 1) * b for i, b in enumerate(balances)) / (n * sum(balances))
252
+ except:
253
+ return 0
254
+
255
+ def _calculate_concentration(self, holders):
256
+ """Calculate concentration ratio of top holders"""
257
+ try:
258
+ balances = sorted([float(h.get('balance', 0)) for h in holders], reverse=True)
259
+ total = sum(balances)
260
+ return sum(balances[:5]) / total if total > 0 else 0
261
+ except:
262
+ return 0
263
+
264
+ def get_defi_stats(self, protocol_address):
265
+ """Fetch DeFi protocol statistics"""
266
+ try:
267
+ response = requests.get(f"{HIPPO_API}/protocol/{protocol_address}/stats")
268
+ if response.ok:
269
+ return response.json()
270
+ return "⚠️ No DeFi stats found"
271
+ except Exception as e:
272
+ return f"⚠️ Error fetching DeFi stats: {str(e)}"
273
+
274
+ def get_wallet_portfolio(self, wallet_address):
275
+ """Fetch wallet portfolio including tokens and NFTs"""
276
+ try:
277
+ tokens = requests.get(f"{APTOSCAN_API}/account/{wallet_address}/tokens")
278
+ nfts = requests.get(f"{APTOSCAN_API}/account/{wallet_address}/nfts")
279
+
280
+ return {
281
+ "tokens": tokens.json() if tokens.ok else [],
282
+ "nfts": nfts.json() if nfts.ok else []
283
+ }
284
+ except Exception as e:
285
+ return f"⚠️ Error fetching portfolio: {str(e)}"
286
+
287
+ def analyze_contract(self, contract_address):
288
+ """Analyze smart contract details and security"""
289
+ try:
290
+ # Fetch contract details
291
+ contract = requests.get(f"{APTOSCAN_API}/account/{contract_address}/modules")
292
+ transactions = requests.get(f"{APTOSCAN_API}/account/{contract_address}/transactions?limit=100")
293
+ resources = requests.get(f"{APTOSCAN_API}/account/{contract_address}/resources")
294
+
295
+ if not all(r.ok for r in [contract, transactions, resources]):
296
+ return "⚠️ Contract not found or error fetching data"
297
+
298
+ contract_data = contract.json()
299
+ tx_data = transactions.json()
300
+ resources_data = resources.json()
301
+
302
+ analysis = {
303
+ "contract_info": {
304
+ "modules": len(contract_data) if isinstance(contract_data, list) else 0,
305
+ "resources": len(resources_data) if isinstance(resources_data, list) else 0,
306
+ "transaction_count": len(tx_data) if isinstance(tx_data, list) else 0
307
+ },
308
+ "activity": {
309
+ "last_24h": sum(1 for tx in tx_data if isinstance(tx, dict) and
310
+ (time.time() - tx.get('timestamp', 0)) < 86400),
311
+ "unique_users": len(set(tx.get('sender') for tx in tx_data if isinstance(tx, dict))),
312
+ "total_volume": sum(float(tx.get('gas_used', 0)) for tx in tx_data if isinstance(tx, dict))
313
+ }
314
+ }
315
+
316
+ return analysis
317
+
318
+ except Exception as e:
319
+ return f"⚠️ Error analyzing contract: {str(e)}"
320
+
321
+ def get_contract_security(self, contract_address):
322
+ """Check contract security and permissions"""
323
+ try:
324
+ resources = requests.get(f"{APTOSCAN_API}/account/{contract_address}/resources")
325
+ modules = requests.get(f"{APTOSCAN_API}/account/{contract_address}/modules")
326
+
327
+ if not all(r.ok for r in [resources, modules]):
328
+ return "⚠️ Error fetching contract security data"
329
+
330
+ security_checks = {
331
+ "has_upgrade_capability": False,
332
+ "has_admin_functions": False,
333
+ "is_verified": False,
334
+ "permissions": [],
335
+ "security_score": 0
336
+ }
337
+
338
+ # Analyze modules and resources
339
+ for module in modules.json():
340
+ if isinstance(module, dict):
341
+ # Check for upgrade capabilities
342
+ if "upgrade" in str(module).lower():
343
+ security_checks["has_upgrade_capability"] = True
344
+ # Check for admin functions
345
+ if "admin" in str(module).lower():
346
+ security_checks["has_admin_functions"] = True
347
+
348
+ # Calculate basic security score
349
+ score = 100
350
+ if security_checks["has_upgrade_capability"]: score -= 20
351
+ if security_checks["has_admin_functions"]: score -= 15
352
+ security_checks["security_score"] = score
353
+
354
+ return security_checks
355
+
356
+ except Exception as e:
357
+ return f"⚠️ Error checking contract security: {str(e)}"
358
+
359
+ def get_dex_pairs(self, token_address):
360
+ """Get all DEX pairs for a token"""
361
+ try:
362
+ response = requests.get(f"{DEXSCREENER_API}{token_address}")
363
+ if response.ok:
364
+ pairs = response.json().get("pairs", [])
365
+ return {
366
+ "total_pairs": len(pairs),
367
+ "total_liquidity": sum(float(p.get("liquidity", {}).get("usd", 0)) for p in pairs),
368
+ "pairs": [{
369
+ "dex": p.get("dexId"),
370
+ "pair": f"{p.get('baseToken', {}).get('symbol')}/{p.get('quoteToken', {}).get('symbol')}",
371
+ "liquidity": p.get("liquidity", {}).get("usd", 0),
372
+ "volume24h": p.get("volume", {}).get("h24", 0)
373
+ } for p in pairs]
374
+ }
375
+ return "⚠️ No DEX pairs found"
376
+ except Exception as e:
377
+ return f"⚠️ Error fetching DEX pairs: {str(e)}"
378
+
379
+ def predict_gas_price(self):
380
+ """Predict gas prices based on network activity"""
381
+ try:
382
+ response = requests.get(f"{APTOSCAN_API}/gas/prediction")
383
+ if response.ok:
384
+ data = response.json()
385
+ return {
386
+ "low": data.get("safeLow"),
387
+ "average": data.get("standard"),
388
+ "high": data.get("fast"),
389
+ "estimated_wait": {
390
+ "low": "5-10 min",
391
+ "average": "2-5 min",
392
+ "high": "<2 min"
393
+ }
394
+ }
395
+ return "⚠️ Unable to predict gas prices"
396
+ except Exception as e:
397
+ return f"⚠️ Error predicting gas: {str(e)}"
398
+
399
+ def analyze_wallet_risk(self, wallet_address):
400
+ """Analyze wallet for suspicious activities"""
401
+ try:
402
+ portfolio = self.get_wallet_portfolio(wallet_address)
403
+ transactions = requests.get(f"{APTOSCAN_API}/account/{wallet_address}/transactions")
404
+
405
+ if isinstance(portfolio, str) or not transactions.ok:
406
+ return "⚠️ Unable to analyze wallet"
407
+
408
+ tx_data = transactions.json()
409
+ analysis = {
410
+ "risk_score": 0,
411
+ "suspicious_patterns": [],
412
+ "transaction_variety": len(set(tx.get('type') for tx in tx_data)),
413
+ "interaction_with_verified": 0,
414
+ "unusual_volume": False
415
+ }
416
+
417
+ # Simple risk scoring
418
+ if len(portfolio["tokens"]) < 2: analysis["risk_score"] += 20
419
+ if len(tx_data) < 10: analysis["risk_score"] += 10
420
+ if analysis["transaction_variety"] < 3: analysis["risk_score"] += 15
421
+
422
+ return analysis
423
+ except Exception as e:
424
+ return f"⚠️ Error analyzing wallet risk: {str(e)}"
425
+
426
+ def get_historical_prices(self, token_address, days=30):
427
+ """Get historical price data with analytics"""
428
+ try:
429
+ response = requests.get(f"{COINGECKO_API}/coins/{token_address}/market_chart?vs_currency=usd&days={days}")
430
+ if response.ok:
431
+ data = response.json()
432
+ prices = data.get("prices", [])
433
+
434
+ if not prices:
435
+ return "⚠️ No historical data available"
436
+
437
+ price_values = [p[1] for p in prices]
438
+ return {
439
+ "current_price": price_values[-1],
440
+ "price_change": ((price_values[-1] - price_values[0]) / price_values[0]) * 100,
441
+ "highest_price": max(price_values),
442
+ "lowest_price": min(price_values),
443
+ "volatility": self._calculate_volatility(price_values),
444
+ "trend": "bullish" if price_values[-1] > price_values[0] else "bearish"
445
+ }
446
+ return "⚠️ Unable to fetch historical data"
447
+ except Exception as e:
448
+ return f"⚠️ Error fetching historical prices: {str(e)}"
449
+
450
+ def _calculate_volatility(self, prices):
451
+ """Calculate price volatility"""
452
+ if len(prices) < 2:
453
+ return 0
454
+ returns = [(prices[i] - prices[i-1])/prices[i-1] for i in range(1, len(prices))]
455
+ return (sum(r**2 for r in returns) / len(returns))**0.5 * 100
456
+
457
+ def chat(self, message):
458
+ """General purpose AI chat functionality"""
459
+ try:
460
+ chat = [{
461
+ "role": "system",
462
+ "content": "You are AptAi Assistant, specialized in Aptos blockchain, DeFi, and NFTs."
463
+ }, {
464
+ "role": "user",
465
+ "content": message
466
+ }]
467
+
468
+ response = groq_client.chat.completions.create(
469
+ model="llama-3.3-70b-versatile",
470
+ messages=chat,
471
+ max_tokens=200,
472
+ temperature=0.7
473
+ )
474
+ return response.choices[0].message.content
475
+ except Exception as e:
476
+ return f"⚠️ Chat Error: {str(e)}"
477
+
478
+ def ai_analysis(self, query):
479
+ """AI-powered analysis using Groq API with custom system prompts"""
480
+ try:
481
+ chat = [{
482
+ "role": "system",
483
+ "content": self.system_prompt
484
+ }, {
485
+ "role": "user",
486
+ "content": query
487
+ }]
488
+
489
+ response = groq_client.chat.completions.create(
490
+ model="llama-3.3-70b-versatile",
491
+ messages=chat,
492
+ max_tokens=self.max_tokens,
493
+ temperature=self.temperature
494
+ )
495
+ return response.choices[0].message.content
496
+ except Exception as e:
497
+ return f"⚠️ AI Analysis Error: {str(e)}"
Binary file
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ const { AptAi } = require("./aptai");
2
+
3
+ module.exports = { AptAi };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "aptai-sdk",
3
+ "version": "1.0.0",
4
+ "description": "AptAi: AI-powered Aptos Blockchain SDK with Groq AI Integration",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "jest",
8
+ "start": "node telegram.js",
9
+ "lint": "eslint .",
10
+ "format": "prettier --write .",
11
+ "docs": "jsdoc -c jsdoc.config.json",
12
+ "prepublishOnly": "npm test"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/yourusername/aptai.git"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "keywords": [
22
+ "Aptos",
23
+ "AI",
24
+ "Groq",
25
+ "blockchain",
26
+ "crypto",
27
+ "defi",
28
+ "nft",
29
+ "telegram-bot"
30
+ ],
31
+ "author": "Teck",
32
+ "license": "MIT",
33
+ "dependencies": {
34
+ "aptos": "^1.0.0",
35
+ "axios": "^1.4.0",
36
+ "node-telegram-bot-api": "^0.66.0"
37
+ },
38
+ "devDependencies": {
39
+ "eslint": "^8.57.1",
40
+ "jest": "^29.7.0",
41
+ "jsdoc": "^4.0.4",
42
+ "prettier": "^3.5.3"
43
+ }
44
+ }
package/replit.nix ADDED
@@ -0,0 +1,3 @@
1
+ {pkgs}: {
2
+ deps = [ ];
3
+ }