solana-agent 27.2.0__tar.gz → 27.3.1__tar.gz
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.
- {solana_agent-27.2.0 → solana_agent-27.3.1}/PKG-INFO +177 -15
- {solana_agent-27.2.0 → solana_agent-27.3.1}/README.md +171 -13
- {solana_agent-27.2.0 → solana_agent-27.3.1}/pyproject.toml +6 -2
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/adapters/openai_adapter.py +59 -5
- solana_agent-27.3.1/solana_agent/adapters/pinecone_adapter.py +496 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/client/solana_agent.py +145 -1
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/factories/agent_factory.py +73 -7
- solana_agent-27.3.1/solana_agent/interfaces/client/client.py +115 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/providers/llm.py +20 -0
- solana_agent-27.3.1/solana_agent/interfaces/providers/vector_storage.py +59 -0
- solana_agent-27.3.1/solana_agent/interfaces/services/knowledge_base.py +86 -0
- solana_agent-27.3.1/solana_agent/services/knowledge_base.py +771 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/services/query.py +33 -2
- solana_agent-27.2.0/solana_agent/interfaces/client/client.py +0 -45
- {solana_agent-27.2.0 → solana_agent-27.3.1}/LICENSE +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/adapters/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/adapters/mongodb_adapter.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/client/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/domains/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/domains/agent.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/domains/routing.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/factories/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/plugins/plugins.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/providers/data_storage.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/providers/memory.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/services/agent.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/services/query.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/interfaces/services/routing.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/plugins/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/plugins/manager.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/plugins/registry.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/plugins/tools/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/plugins/tools/auto_tool.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/repositories/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/repositories/memory.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/services/__init__.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/services/agent.py +0 -0
- {solana_agent-27.2.0 → solana_agent-27.3.1}/solana_agent/services/routing.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: solana-agent
|
3
|
-
Version: 27.
|
3
|
+
Version: 27.3.1
|
4
4
|
Summary: Agentic IQ
|
5
5
|
License: MIT
|
6
6
|
Keywords: ai,openai,ai agents,agi
|
@@ -15,9 +15,13 @@ Classifier: Programming Language :: Python :: 3.12
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.13
|
16
16
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
17
17
|
Requires-Dist: instructor (>=1.7.9,<2.0.0)
|
18
|
+
Requires-Dist: llama-index-core (>=0.12.30,<0.13.0)
|
19
|
+
Requires-Dist: llama-index-embeddings-openai (>=0.3.1,<0.4.0)
|
18
20
|
Requires-Dist: openai (>=1.74.0,<2.0.0)
|
19
|
-
Requires-Dist:
|
21
|
+
Requires-Dist: pinecone (>=6.0.2,<7.0.0)
|
22
|
+
Requires-Dist: pydantic (>=2)
|
20
23
|
Requires-Dist: pymongo (>=4.12.0,<5.0.0)
|
24
|
+
Requires-Dist: pypdf (>=5.4.0,<6.0.0)
|
21
25
|
Requires-Dist: zep-cloud (>=2.10.1,<3.0.0)
|
22
26
|
Project-URL: Documentation, https://docs.solana-agent.com
|
23
27
|
Project-URL: Repository, https://github.com/truemagic-coder/solana-agent
|
@@ -43,6 +47,7 @@ Build your AI business in three lines of code!
|
|
43
47
|
## Why?
|
44
48
|
* Three lines of code setup
|
45
49
|
* Fast Responses
|
50
|
+
* Solana Integration
|
46
51
|
* Multi-Agent Swarm
|
47
52
|
* Multi-Modal Streaming (Text & Audio)
|
48
53
|
* Conversational Memory & History
|
@@ -51,6 +56,7 @@ Build your AI business in three lines of code!
|
|
51
56
|
* Business Alignment
|
52
57
|
* Extensible Tooling
|
53
58
|
* Simple Business Definition
|
59
|
+
* Knowledge Base with PDF support
|
54
60
|
* Tested & Secure
|
55
61
|
* Built in Python
|
56
62
|
* Powers [CometHeart](https://cometheart.com) & [WalletBubbles](https://walletbubbles.com)
|
@@ -59,6 +65,7 @@ Build your AI business in three lines of code!
|
|
59
65
|
|
60
66
|
* Easy three lines of code setup
|
61
67
|
* Fast AI responses
|
68
|
+
* Solana Integration via [AgentiPy](https://github.com/niceberginc/agentipy)
|
62
69
|
* Designed for a multi-agent swarm
|
63
70
|
* Seamless text and audio streaming with real-time multi-modal processing
|
64
71
|
* Configurable audio voice characteristics via prompting
|
@@ -70,6 +77,7 @@ Build your AI business in three lines of code!
|
|
70
77
|
* Powerful tool integration using standard Python packages and/or inline tools
|
71
78
|
* Assigned tools are utilized by agents automatically and effectively
|
72
79
|
* Simple business definition using JSON
|
80
|
+
* Integrated Knowledge Base with semantic search and automatic PDF chunking
|
73
81
|
|
74
82
|
## Stack
|
75
83
|
|
@@ -79,15 +87,17 @@ Build your AI business in three lines of code!
|
|
79
87
|
* [OpenAI](https://openai.com), [Google](https://ai.google.dev), [xAI](https://x.ai) - LLM Providers
|
80
88
|
* [MongoDB](https://mongodb.com) - Conversational History (optional)
|
81
89
|
* [Zep Cloud](https://getzep.com) - Conversational Memory (optional)
|
90
|
+
* [Pinecone](https://pinecone.io) - Knowledge Base (optional)
|
82
91
|
|
83
92
|
### LLMs
|
84
93
|
|
85
94
|
* [gpt-4.1-mini](https://platform.openai.com/docs/models/gpt-4.1-mini) (agent)
|
86
95
|
* [gpt-4.1-nano](https://platform.openai.com/docs/models/gpt-4.1-nano) (router)
|
87
|
-
* [
|
88
|
-
* [grok-3-mini-fast-beta](https://docs.x.ai/docs/models#models-and-pricing) (optional)
|
96
|
+
* [text-embedding-3-large](https://platform.openai.com/docs/models/text-embedding-3-large) or [text-embedding-3-small](https://platform.openai.com/docs/models/text-embedding-3-small) (embedding)
|
89
97
|
* [tts-1](https://platform.openai.com/docs/models/tts-1) (audio TTS)
|
90
98
|
* [gpt-4o-mini-transcribe](https://platform.openai.com/docs/models/gpt-4o-mini-transcribe) (audio transcription)
|
99
|
+
* [gemini-2.0-flash](https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash) (optional)
|
100
|
+
* [grok-3-mini-fast-beta](https://docs.x.ai/docs/models#models-and-pricing) (optional)
|
91
101
|
|
92
102
|
## Installation
|
93
103
|
|
@@ -196,7 +206,7 @@ config = {
|
|
196
206
|
|
197
207
|
solana_agent = SolanaAgent(config=config)
|
198
208
|
|
199
|
-
audio_content = audio_file.read()
|
209
|
+
audio_content = await audio_file.read()
|
200
210
|
|
201
211
|
async for response in solana_agent.process("user123", audio_content, output_format="audio", audio_voice="nova", audio_input_format="webm", audio_output_format="aac"):
|
202
212
|
print(response, end="")
|
@@ -256,7 +266,7 @@ config = {
|
|
256
266
|
|
257
267
|
solana_agent = SolanaAgent(config=config)
|
258
268
|
|
259
|
-
audio_content = audio_file.read()
|
269
|
+
audio_content = await audio_file.read()
|
260
270
|
|
261
271
|
async for response in solana_agent.process("user123", audio_content, audio_input_format="aac"):
|
262
272
|
print(response, end="")
|
@@ -327,6 +337,114 @@ config = {
|
|
327
337
|
}
|
328
338
|
```
|
329
339
|
|
340
|
+
### Knowledge Base
|
341
|
+
|
342
|
+
The Knowledge Base (KB) is meant to store text values and/or small PDFs.
|
343
|
+
|
344
|
+
```python
|
345
|
+
config = {
|
346
|
+
"knowledge_base": {
|
347
|
+
"pinecone": {
|
348
|
+
"api_key": "your-pinecone-api-key",
|
349
|
+
"index_name": "your-pinecone-index-name",
|
350
|
+
}
|
351
|
+
},
|
352
|
+
"mongo": {
|
353
|
+
"connection_string": "your-mongo-connection-string",
|
354
|
+
"database": "your-database-name"
|
355
|
+
},
|
356
|
+
}
|
357
|
+
```
|
358
|
+
|
359
|
+
#### Example for KB (text)
|
360
|
+
|
361
|
+
```python
|
362
|
+
from solana_agent import SolanaAgent
|
363
|
+
|
364
|
+
config = {
|
365
|
+
"openai": {
|
366
|
+
"api_key": "your-openai-api-key",
|
367
|
+
},
|
368
|
+
"knowledge_base": {
|
369
|
+
"pinecone": {
|
370
|
+
"api_key": "your-pinecone-api-key",
|
371
|
+
"index_name": "your-pinecone-index-name",
|
372
|
+
}
|
373
|
+
},
|
374
|
+
"mongo": {
|
375
|
+
"connection_string": "your-mongo-connection-string",
|
376
|
+
"database": "your-database-name"
|
377
|
+
},
|
378
|
+
"agents": [
|
379
|
+
{
|
380
|
+
"name": "kb_expert",
|
381
|
+
"instructions": "You answer questions based on the provided knowledge base documents.",
|
382
|
+
"specialization": "Company Knowledge",
|
383
|
+
}
|
384
|
+
]
|
385
|
+
}
|
386
|
+
|
387
|
+
solana_agent = SolanaAgent(config=config)
|
388
|
+
|
389
|
+
doc_text = "Solana Agent is a Python framework for building multi-agent AI systems."
|
390
|
+
doc_metadata = {
|
391
|
+
"source": "internal_docs",
|
392
|
+
"version": "1.0",
|
393
|
+
"tags": ["framework", "python", "ai"]
|
394
|
+
}
|
395
|
+
await solana_agent.kb_add_document(text=doc_text, metadata=doc_metadata)
|
396
|
+
|
397
|
+
async for response in solana_agent.process("user123", "What is Solana Agent?"):
|
398
|
+
print(response, end="")
|
399
|
+
```
|
400
|
+
|
401
|
+
#### Example for KB (pdf)
|
402
|
+
|
403
|
+
```python
|
404
|
+
from solana_agent import SolanaAgent
|
405
|
+
|
406
|
+
config = {
|
407
|
+
"openai": {
|
408
|
+
"api_key": "your-openai-api-key",
|
409
|
+
},
|
410
|
+
"knowledge_base": {
|
411
|
+
"pinecone": {
|
412
|
+
"api_key": "your-pinecone-api-key",
|
413
|
+
"index_name": "your-pinecone-index-name",
|
414
|
+
}
|
415
|
+
},
|
416
|
+
"mongo": {
|
417
|
+
"connection_string": "your-mongo-connection-string",
|
418
|
+
"database": "your-database-name"
|
419
|
+
},
|
420
|
+
"agents": [
|
421
|
+
{
|
422
|
+
"name": "kb_expert",
|
423
|
+
"instructions": "You answer questions based on the provided knowledge base documents.",
|
424
|
+
"specialization": "Company Knowledge",
|
425
|
+
}
|
426
|
+
]
|
427
|
+
}
|
428
|
+
|
429
|
+
solana_agent = SolanaAgent(config=config)
|
430
|
+
|
431
|
+
pdf_bytes = await pdf_file.read()
|
432
|
+
|
433
|
+
pdf_metadata = {
|
434
|
+
"source": "annual_report_2024.pdf",
|
435
|
+
"year": 2024,
|
436
|
+
"tags": ["finance", "report"]
|
437
|
+
}
|
438
|
+
|
439
|
+
await solana_agent.kb_add_pdf_document(
|
440
|
+
pdf_data=pdf_bytes,
|
441
|
+
metadata=pdf_metadata,
|
442
|
+
)
|
443
|
+
|
444
|
+
async for response in solana_agent.process("user123", "Summarize the annual report for 2024."):
|
445
|
+
print(response, end="")
|
446
|
+
```
|
447
|
+
|
330
448
|
## Tools
|
331
449
|
|
332
450
|
Tools can be used from plugins like Solana Agent Kit (sakit) or via inline tools. Tools available via plugins integrate automatically with Solana Agent.
|
@@ -336,7 +454,7 @@ Tools can be used from plugins like Solana Agent Kit (sakit) or via inline tools
|
|
336
454
|
* Solana Agent doesn't use OpenAI function calling (tools) as they don't support async functions
|
337
455
|
* Solana Agent tools are async functions
|
338
456
|
|
339
|
-
### Internet Search
|
457
|
+
### Internet Search
|
340
458
|
|
341
459
|
`pip install sakit`
|
342
460
|
|
@@ -366,10 +484,58 @@ config = {
|
|
366
484
|
}
|
367
485
|
],
|
368
486
|
}
|
487
|
+
```
|
488
|
+
|
489
|
+
### Solana Actions
|
490
|
+
|
491
|
+
`pip install sakit`
|
492
|
+
|
493
|
+
```python
|
494
|
+
config = {
|
495
|
+
"tools": {
|
496
|
+
"solana": {
|
497
|
+
# Core Solana Settings
|
498
|
+
"private_key": "YOUR_SOLANA_WALLET_PRIVATE_KEY", # Required (unless generate_wallet=True): Your wallet's private key (base58 encoded string).
|
499
|
+
"rpc_url": "https://api.mainnet-beta.solana.com", # Optional: Defaults to Solana mainnet RPC.
|
500
|
+
"generate_wallet": False, # Optional: If True, ignores private_key and generates a new wallet. Defaults to False.
|
501
|
+
|
502
|
+
# Optional RPC/Service API Keys & URLs
|
503
|
+
"helius_api_key": "YOUR_HELIUS_API_KEY", # Optional: Helius API key for enhanced data/RPC.
|
504
|
+
"helius_rpc_url": "YOUR_HELIUS_RPC_URL", # Optional: Specific Helius RPC URL.
|
505
|
+
"quicknode_rpc_url": "YOUR_QUICKNODE_RPC_URL", # Optional: QuickNode RPC URL.
|
506
|
+
"jito_block_engine_url": "YOUR_JITO_BLOCK_ENGINE_URL", # Optional: Jito block engine URL for bundles.
|
507
|
+
"jito_uuid": "YOUR_JITO_UUID", # Optional: Jito authentication UUID.
|
508
|
+
|
509
|
+
# Optional Integration API Keys
|
510
|
+
"openai_api_key": "YOUR_OPENAI_API_KEY", # Optional: OpenAI API key (if needed by specific agentipy features).
|
511
|
+
"backpack_api_key": "YOUR_BACKPACK_API_KEY", # Optional: Backpack Exchange API key.
|
512
|
+
"backpack_api_secret": "YOUR_BACKPACK_API_SECRET", # Optional: Backpack Exchange API secret.
|
513
|
+
"stork_api_key": "YOUR_STORK_API_KEY", # Optional: Stork oracle API key.
|
514
|
+
"coingecko_api_key": "YOUR_COINGECKO_PRO_API_KEY", # Optional: CoinGecko Pro API key.
|
515
|
+
"coingecko_demo_api_key": "YOUR_COINGECKO_DEMO_KEY", # Optional: CoinGecko Demo API key.
|
516
|
+
"elfa_ai_api_key": "YOUR_ELFA_AI_API_KEY", # Optional: Elfa AI API key.
|
517
|
+
"flexland_api_key": "YOUR_FLEXLAND_API_KEY", # Optional: Flexlend API key.
|
518
|
+
"allora_api_key": "YOUR_ALLORA_API_KEY", # Optional: Allora Network API key.
|
519
|
+
"solutiofi_api_key": "YOUR_SOLUTIOFI_API_KEY" # Optional: Solutio Finance API key.
|
520
|
+
},
|
521
|
+
},
|
522
|
+
"ai_agents": [
|
523
|
+
{
|
524
|
+
"name": "solana_expert",
|
525
|
+
"instructions": """
|
526
|
+
You are an expert Solana blockchain assistant.
|
527
|
+
Use the solana tool to perform any action on the Solana blockchain.
|
528
|
+
Always perform the solana tool actions when requested and not use your memory.
|
529
|
+
""",
|
530
|
+
"specialization": "Solana blockchain interaction",
|
531
|
+
"tools": ["solana"], # Enable the tool for this agent
|
532
|
+
}
|
533
|
+
]
|
534
|
+
}
|
369
535
|
|
370
536
|
solana_agent = SolanaAgent(config=config)
|
371
537
|
|
372
|
-
async for response in solana_agent.process("user123", "What
|
538
|
+
async for response in solana_agent.process("user123", "What is my SOL balance?"):
|
373
539
|
print(response, end="")
|
374
540
|
```
|
375
541
|
|
@@ -453,13 +619,9 @@ async for response in solana_agent.process("user123", "What are the latest AI de
|
|
453
619
|
print(response, end="")
|
454
620
|
```
|
455
621
|
|
456
|
-
##
|
457
|
-
|
458
|
-
Many use cases for Solana Agent require training your agents on your company data.
|
459
|
-
|
460
|
-
This can be accomplished via runtime prompt injection. Integrations that work well with this method are vector stores like Pinecone and FAQs.
|
622
|
+
## Advanced Customization
|
461
623
|
|
462
|
-
|
624
|
+
### Runtime Prompt Injection
|
463
625
|
|
464
626
|
```python
|
465
627
|
from solana_agent import SolanaAgent
|
@@ -483,7 +645,7 @@ async for response in solana_agent.process("user123", "How do replace the latch
|
|
483
645
|
print(response, end="")
|
484
646
|
```
|
485
647
|
|
486
|
-
|
648
|
+
### Custom Routing
|
487
649
|
|
488
650
|
In advanced cases like implementing a ticketing system on-top of Solana Agent - you can use your own router.
|
489
651
|
|
@@ -18,6 +18,7 @@ Build your AI business in three lines of code!
|
|
18
18
|
## Why?
|
19
19
|
* Three lines of code setup
|
20
20
|
* Fast Responses
|
21
|
+
* Solana Integration
|
21
22
|
* Multi-Agent Swarm
|
22
23
|
* Multi-Modal Streaming (Text & Audio)
|
23
24
|
* Conversational Memory & History
|
@@ -26,6 +27,7 @@ Build your AI business in three lines of code!
|
|
26
27
|
* Business Alignment
|
27
28
|
* Extensible Tooling
|
28
29
|
* Simple Business Definition
|
30
|
+
* Knowledge Base with PDF support
|
29
31
|
* Tested & Secure
|
30
32
|
* Built in Python
|
31
33
|
* Powers [CometHeart](https://cometheart.com) & [WalletBubbles](https://walletbubbles.com)
|
@@ -34,6 +36,7 @@ Build your AI business in three lines of code!
|
|
34
36
|
|
35
37
|
* Easy three lines of code setup
|
36
38
|
* Fast AI responses
|
39
|
+
* Solana Integration via [AgentiPy](https://github.com/niceberginc/agentipy)
|
37
40
|
* Designed for a multi-agent swarm
|
38
41
|
* Seamless text and audio streaming with real-time multi-modal processing
|
39
42
|
* Configurable audio voice characteristics via prompting
|
@@ -45,6 +48,7 @@ Build your AI business in three lines of code!
|
|
45
48
|
* Powerful tool integration using standard Python packages and/or inline tools
|
46
49
|
* Assigned tools are utilized by agents automatically and effectively
|
47
50
|
* Simple business definition using JSON
|
51
|
+
* Integrated Knowledge Base with semantic search and automatic PDF chunking
|
48
52
|
|
49
53
|
## Stack
|
50
54
|
|
@@ -54,15 +58,17 @@ Build your AI business in three lines of code!
|
|
54
58
|
* [OpenAI](https://openai.com), [Google](https://ai.google.dev), [xAI](https://x.ai) - LLM Providers
|
55
59
|
* [MongoDB](https://mongodb.com) - Conversational History (optional)
|
56
60
|
* [Zep Cloud](https://getzep.com) - Conversational Memory (optional)
|
61
|
+
* [Pinecone](https://pinecone.io) - Knowledge Base (optional)
|
57
62
|
|
58
63
|
### LLMs
|
59
64
|
|
60
65
|
* [gpt-4.1-mini](https://platform.openai.com/docs/models/gpt-4.1-mini) (agent)
|
61
66
|
* [gpt-4.1-nano](https://platform.openai.com/docs/models/gpt-4.1-nano) (router)
|
62
|
-
* [
|
63
|
-
* [grok-3-mini-fast-beta](https://docs.x.ai/docs/models#models-and-pricing) (optional)
|
67
|
+
* [text-embedding-3-large](https://platform.openai.com/docs/models/text-embedding-3-large) or [text-embedding-3-small](https://platform.openai.com/docs/models/text-embedding-3-small) (embedding)
|
64
68
|
* [tts-1](https://platform.openai.com/docs/models/tts-1) (audio TTS)
|
65
69
|
* [gpt-4o-mini-transcribe](https://platform.openai.com/docs/models/gpt-4o-mini-transcribe) (audio transcription)
|
70
|
+
* [gemini-2.0-flash](https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash) (optional)
|
71
|
+
* [grok-3-mini-fast-beta](https://docs.x.ai/docs/models#models-and-pricing) (optional)
|
66
72
|
|
67
73
|
## Installation
|
68
74
|
|
@@ -171,7 +177,7 @@ config = {
|
|
171
177
|
|
172
178
|
solana_agent = SolanaAgent(config=config)
|
173
179
|
|
174
|
-
audio_content = audio_file.read()
|
180
|
+
audio_content = await audio_file.read()
|
175
181
|
|
176
182
|
async for response in solana_agent.process("user123", audio_content, output_format="audio", audio_voice="nova", audio_input_format="webm", audio_output_format="aac"):
|
177
183
|
print(response, end="")
|
@@ -231,7 +237,7 @@ config = {
|
|
231
237
|
|
232
238
|
solana_agent = SolanaAgent(config=config)
|
233
239
|
|
234
|
-
audio_content = audio_file.read()
|
240
|
+
audio_content = await audio_file.read()
|
235
241
|
|
236
242
|
async for response in solana_agent.process("user123", audio_content, audio_input_format="aac"):
|
237
243
|
print(response, end="")
|
@@ -302,6 +308,114 @@ config = {
|
|
302
308
|
}
|
303
309
|
```
|
304
310
|
|
311
|
+
### Knowledge Base
|
312
|
+
|
313
|
+
The Knowledge Base (KB) is meant to store text values and/or small PDFs.
|
314
|
+
|
315
|
+
```python
|
316
|
+
config = {
|
317
|
+
"knowledge_base": {
|
318
|
+
"pinecone": {
|
319
|
+
"api_key": "your-pinecone-api-key",
|
320
|
+
"index_name": "your-pinecone-index-name",
|
321
|
+
}
|
322
|
+
},
|
323
|
+
"mongo": {
|
324
|
+
"connection_string": "your-mongo-connection-string",
|
325
|
+
"database": "your-database-name"
|
326
|
+
},
|
327
|
+
}
|
328
|
+
```
|
329
|
+
|
330
|
+
#### Example for KB (text)
|
331
|
+
|
332
|
+
```python
|
333
|
+
from solana_agent import SolanaAgent
|
334
|
+
|
335
|
+
config = {
|
336
|
+
"openai": {
|
337
|
+
"api_key": "your-openai-api-key",
|
338
|
+
},
|
339
|
+
"knowledge_base": {
|
340
|
+
"pinecone": {
|
341
|
+
"api_key": "your-pinecone-api-key",
|
342
|
+
"index_name": "your-pinecone-index-name",
|
343
|
+
}
|
344
|
+
},
|
345
|
+
"mongo": {
|
346
|
+
"connection_string": "your-mongo-connection-string",
|
347
|
+
"database": "your-database-name"
|
348
|
+
},
|
349
|
+
"agents": [
|
350
|
+
{
|
351
|
+
"name": "kb_expert",
|
352
|
+
"instructions": "You answer questions based on the provided knowledge base documents.",
|
353
|
+
"specialization": "Company Knowledge",
|
354
|
+
}
|
355
|
+
]
|
356
|
+
}
|
357
|
+
|
358
|
+
solana_agent = SolanaAgent(config=config)
|
359
|
+
|
360
|
+
doc_text = "Solana Agent is a Python framework for building multi-agent AI systems."
|
361
|
+
doc_metadata = {
|
362
|
+
"source": "internal_docs",
|
363
|
+
"version": "1.0",
|
364
|
+
"tags": ["framework", "python", "ai"]
|
365
|
+
}
|
366
|
+
await solana_agent.kb_add_document(text=doc_text, metadata=doc_metadata)
|
367
|
+
|
368
|
+
async for response in solana_agent.process("user123", "What is Solana Agent?"):
|
369
|
+
print(response, end="")
|
370
|
+
```
|
371
|
+
|
372
|
+
#### Example for KB (pdf)
|
373
|
+
|
374
|
+
```python
|
375
|
+
from solana_agent import SolanaAgent
|
376
|
+
|
377
|
+
config = {
|
378
|
+
"openai": {
|
379
|
+
"api_key": "your-openai-api-key",
|
380
|
+
},
|
381
|
+
"knowledge_base": {
|
382
|
+
"pinecone": {
|
383
|
+
"api_key": "your-pinecone-api-key",
|
384
|
+
"index_name": "your-pinecone-index-name",
|
385
|
+
}
|
386
|
+
},
|
387
|
+
"mongo": {
|
388
|
+
"connection_string": "your-mongo-connection-string",
|
389
|
+
"database": "your-database-name"
|
390
|
+
},
|
391
|
+
"agents": [
|
392
|
+
{
|
393
|
+
"name": "kb_expert",
|
394
|
+
"instructions": "You answer questions based on the provided knowledge base documents.",
|
395
|
+
"specialization": "Company Knowledge",
|
396
|
+
}
|
397
|
+
]
|
398
|
+
}
|
399
|
+
|
400
|
+
solana_agent = SolanaAgent(config=config)
|
401
|
+
|
402
|
+
pdf_bytes = await pdf_file.read()
|
403
|
+
|
404
|
+
pdf_metadata = {
|
405
|
+
"source": "annual_report_2024.pdf",
|
406
|
+
"year": 2024,
|
407
|
+
"tags": ["finance", "report"]
|
408
|
+
}
|
409
|
+
|
410
|
+
await solana_agent.kb_add_pdf_document(
|
411
|
+
pdf_data=pdf_bytes,
|
412
|
+
metadata=pdf_metadata,
|
413
|
+
)
|
414
|
+
|
415
|
+
async for response in solana_agent.process("user123", "Summarize the annual report for 2024."):
|
416
|
+
print(response, end="")
|
417
|
+
```
|
418
|
+
|
305
419
|
## Tools
|
306
420
|
|
307
421
|
Tools can be used from plugins like Solana Agent Kit (sakit) or via inline tools. Tools available via plugins integrate automatically with Solana Agent.
|
@@ -311,7 +425,7 @@ Tools can be used from plugins like Solana Agent Kit (sakit) or via inline tools
|
|
311
425
|
* Solana Agent doesn't use OpenAI function calling (tools) as they don't support async functions
|
312
426
|
* Solana Agent tools are async functions
|
313
427
|
|
314
|
-
### Internet Search
|
428
|
+
### Internet Search
|
315
429
|
|
316
430
|
`pip install sakit`
|
317
431
|
|
@@ -341,10 +455,58 @@ config = {
|
|
341
455
|
}
|
342
456
|
],
|
343
457
|
}
|
458
|
+
```
|
459
|
+
|
460
|
+
### Solana Actions
|
461
|
+
|
462
|
+
`pip install sakit`
|
463
|
+
|
464
|
+
```python
|
465
|
+
config = {
|
466
|
+
"tools": {
|
467
|
+
"solana": {
|
468
|
+
# Core Solana Settings
|
469
|
+
"private_key": "YOUR_SOLANA_WALLET_PRIVATE_KEY", # Required (unless generate_wallet=True): Your wallet's private key (base58 encoded string).
|
470
|
+
"rpc_url": "https://api.mainnet-beta.solana.com", # Optional: Defaults to Solana mainnet RPC.
|
471
|
+
"generate_wallet": False, # Optional: If True, ignores private_key and generates a new wallet. Defaults to False.
|
472
|
+
|
473
|
+
# Optional RPC/Service API Keys & URLs
|
474
|
+
"helius_api_key": "YOUR_HELIUS_API_KEY", # Optional: Helius API key for enhanced data/RPC.
|
475
|
+
"helius_rpc_url": "YOUR_HELIUS_RPC_URL", # Optional: Specific Helius RPC URL.
|
476
|
+
"quicknode_rpc_url": "YOUR_QUICKNODE_RPC_URL", # Optional: QuickNode RPC URL.
|
477
|
+
"jito_block_engine_url": "YOUR_JITO_BLOCK_ENGINE_URL", # Optional: Jito block engine URL for bundles.
|
478
|
+
"jito_uuid": "YOUR_JITO_UUID", # Optional: Jito authentication UUID.
|
479
|
+
|
480
|
+
# Optional Integration API Keys
|
481
|
+
"openai_api_key": "YOUR_OPENAI_API_KEY", # Optional: OpenAI API key (if needed by specific agentipy features).
|
482
|
+
"backpack_api_key": "YOUR_BACKPACK_API_KEY", # Optional: Backpack Exchange API key.
|
483
|
+
"backpack_api_secret": "YOUR_BACKPACK_API_SECRET", # Optional: Backpack Exchange API secret.
|
484
|
+
"stork_api_key": "YOUR_STORK_API_KEY", # Optional: Stork oracle API key.
|
485
|
+
"coingecko_api_key": "YOUR_COINGECKO_PRO_API_KEY", # Optional: CoinGecko Pro API key.
|
486
|
+
"coingecko_demo_api_key": "YOUR_COINGECKO_DEMO_KEY", # Optional: CoinGecko Demo API key.
|
487
|
+
"elfa_ai_api_key": "YOUR_ELFA_AI_API_KEY", # Optional: Elfa AI API key.
|
488
|
+
"flexland_api_key": "YOUR_FLEXLAND_API_KEY", # Optional: Flexlend API key.
|
489
|
+
"allora_api_key": "YOUR_ALLORA_API_KEY", # Optional: Allora Network API key.
|
490
|
+
"solutiofi_api_key": "YOUR_SOLUTIOFI_API_KEY" # Optional: Solutio Finance API key.
|
491
|
+
},
|
492
|
+
},
|
493
|
+
"ai_agents": [
|
494
|
+
{
|
495
|
+
"name": "solana_expert",
|
496
|
+
"instructions": """
|
497
|
+
You are an expert Solana blockchain assistant.
|
498
|
+
Use the solana tool to perform any action on the Solana blockchain.
|
499
|
+
Always perform the solana tool actions when requested and not use your memory.
|
500
|
+
""",
|
501
|
+
"specialization": "Solana blockchain interaction",
|
502
|
+
"tools": ["solana"], # Enable the tool for this agent
|
503
|
+
}
|
504
|
+
]
|
505
|
+
}
|
344
506
|
|
345
507
|
solana_agent = SolanaAgent(config=config)
|
346
508
|
|
347
|
-
async for response in solana_agent.process("user123", "What
|
509
|
+
async for response in solana_agent.process("user123", "What is my SOL balance?"):
|
348
510
|
print(response, end="")
|
349
511
|
```
|
350
512
|
|
@@ -428,13 +590,9 @@ async for response in solana_agent.process("user123", "What are the latest AI de
|
|
428
590
|
print(response, end="")
|
429
591
|
```
|
430
592
|
|
431
|
-
##
|
432
|
-
|
433
|
-
Many use cases for Solana Agent require training your agents on your company data.
|
434
|
-
|
435
|
-
This can be accomplished via runtime prompt injection. Integrations that work well with this method are vector stores like Pinecone and FAQs.
|
593
|
+
## Advanced Customization
|
436
594
|
|
437
|
-
|
595
|
+
### Runtime Prompt Injection
|
438
596
|
|
439
597
|
```python
|
440
598
|
from solana_agent import SolanaAgent
|
@@ -458,7 +616,7 @@ async for response in solana_agent.process("user123", "How do replace the latch
|
|
458
616
|
print(response, end="")
|
459
617
|
```
|
460
618
|
|
461
|
-
|
619
|
+
### Custom Routing
|
462
620
|
|
463
621
|
In advanced cases like implementing a ticketing system on-top of Solana Agent - you can use your own router.
|
464
622
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "solana-agent"
|
3
|
-
version = "27.
|
3
|
+
version = "27.3.1"
|
4
4
|
description = "Agentic IQ"
|
5
5
|
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
|
6
6
|
license = "MIT"
|
@@ -24,10 +24,14 @@ python_paths = [".", "tests"]
|
|
24
24
|
[tool.poetry.dependencies]
|
25
25
|
python = ">=3.12,<4.0"
|
26
26
|
openai = "^1.74.0"
|
27
|
-
pydantic = "
|
27
|
+
pydantic = ">=2"
|
28
28
|
pymongo = "^4.12.0"
|
29
29
|
zep-cloud = "^2.10.1"
|
30
30
|
instructor = "^1.7.9"
|
31
|
+
pinecone = "^6.0.2"
|
32
|
+
llama-index-core = "^0.12.30"
|
33
|
+
llama-index-embeddings-openai = "^0.3.1"
|
34
|
+
pypdf = "^5.4.0"
|
31
35
|
|
32
36
|
[tool.poetry.group.dev.dependencies]
|
33
37
|
pytest = "^8.3.5"
|
@@ -3,7 +3,7 @@ LLM provider adapters for the Solana Agent system.
|
|
3
3
|
|
4
4
|
These adapters implement the LLMProvider interface for different LLM services.
|
5
5
|
"""
|
6
|
-
from typing import AsyncGenerator, Literal, Optional, Type, TypeVar
|
6
|
+
from typing import AsyncGenerator, List, Literal, Optional, Type, TypeVar
|
7
7
|
|
8
8
|
from openai import AsyncOpenAI
|
9
9
|
from pydantic import BaseModel
|
@@ -14,16 +14,25 @@ from solana_agent.interfaces.providers.llm import LLMProvider
|
|
14
14
|
|
15
15
|
T = TypeVar('T', bound=BaseModel)
|
16
16
|
|
17
|
+
DEFAULT_CHAT_MODEL = "gpt-4.1-mini"
|
18
|
+
DEFAULT_PARSE_MODEL = "gpt-4.1-nano"
|
19
|
+
DEFAULT_EMBEDDING_MODEL = "text-embedding-3-large"
|
20
|
+
DEFAULT_EMBEDDING_DIMENSIONS = 3072
|
21
|
+
DEFAULT_TRANSCRIPTION_MODEL = "gpt-4o-mini-transcribe"
|
22
|
+
DEFAULT_TTS_MODEL = "tts-1"
|
23
|
+
|
17
24
|
|
18
25
|
class OpenAIAdapter(LLMProvider):
|
19
26
|
"""OpenAI implementation of LLMProvider with web search capabilities."""
|
20
27
|
|
21
28
|
def __init__(self, api_key: str):
|
22
29
|
self.client = AsyncOpenAI(api_key=api_key)
|
23
|
-
self.parse_model =
|
24
|
-
self.text_model =
|
25
|
-
self.transcription_model =
|
26
|
-
self.tts_model =
|
30
|
+
self.parse_model = DEFAULT_PARSE_MODEL
|
31
|
+
self.text_model = DEFAULT_CHAT_MODEL
|
32
|
+
self.transcription_model = DEFAULT_TRANSCRIPTION_MODEL
|
33
|
+
self.tts_model = DEFAULT_TTS_MODEL
|
34
|
+
self.embedding_model = DEFAULT_EMBEDDING_MODEL
|
35
|
+
self.embedding_dimensions = DEFAULT_EMBEDDING_DIMENSIONS
|
27
36
|
|
28
37
|
async def tts(
|
29
38
|
self,
|
@@ -248,3 +257,48 @@ class OpenAIAdapter(LLMProvider):
|
|
248
257
|
raise ValueError(
|
249
258
|
f"Failed to generate structured output: {e}. All fallbacks failed."
|
250
259
|
) from e
|
260
|
+
|
261
|
+
async def embed_text(
|
262
|
+
self,
|
263
|
+
text: str,
|
264
|
+
model: Optional[str] = None,
|
265
|
+
dimensions: Optional[int] = None
|
266
|
+
) -> List[float]: # pragma: no cover
|
267
|
+
"""Generate an embedding for the given text using OpenAI.
|
268
|
+
|
269
|
+
Args:
|
270
|
+
text: The text to embed.
|
271
|
+
model: The embedding model to use (defaults to text-embedding-3-large).
|
272
|
+
dimensions: Desired output dimensions for the embedding.
|
273
|
+
|
274
|
+
Returns:
|
275
|
+
A list of floats representing the embedding vector.
|
276
|
+
"""
|
277
|
+
if not text:
|
278
|
+
raise ValueError("Text cannot be empty")
|
279
|
+
|
280
|
+
try:
|
281
|
+
# Use provided model/dimensions or fall back to defaults
|
282
|
+
embedding_model = model or self.embedding_model
|
283
|
+
embedding_dimensions = dimensions or self.embedding_dimensions
|
284
|
+
|
285
|
+
# Replace newlines with spaces as recommended by OpenAI
|
286
|
+
text = text.replace("\n", " ")
|
287
|
+
|
288
|
+
response = await self.client.embeddings.create(
|
289
|
+
input=[text],
|
290
|
+
model=embedding_model,
|
291
|
+
dimensions=embedding_dimensions
|
292
|
+
)
|
293
|
+
|
294
|
+
if response.data and response.data[0].embedding:
|
295
|
+
return response.data[0].embedding
|
296
|
+
else:
|
297
|
+
raise ValueError(
|
298
|
+
"Failed to retrieve embedding from OpenAI response")
|
299
|
+
|
300
|
+
except Exception as e:
|
301
|
+
print(f"Error generating embedding: {e}")
|
302
|
+
import traceback
|
303
|
+
print(traceback.format_exc())
|
304
|
+
raise
|