solana-agent 27.2.0__py3-none-any.whl → 27.3.0__py3-none-any.whl

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.
@@ -11,6 +11,7 @@ from solana_agent.interfaces.services.query import QueryService as QueryServiceI
11
11
  from solana_agent.interfaces.services.routing import RoutingService as RoutingServiceInterface
12
12
  from solana_agent.services.agent import AgentService
13
13
  from solana_agent.services.routing import RoutingService
14
+ from solana_agent.services.knowledge_base import KnowledgeBaseService
14
15
  from solana_agent.interfaces.providers.memory import MemoryProvider
15
16
 
16
17
 
@@ -22,6 +23,8 @@ class QueryService(QueryServiceInterface):
22
23
  agent_service: AgentService,
23
24
  routing_service: RoutingService,
24
25
  memory_provider: Optional[MemoryProvider] = None,
26
+ knowledge_base: Optional[KnowledgeBaseService] = None,
27
+ kb_results_count: int = 3,
25
28
  ):
26
29
  """Initialize the query service.
27
30
 
@@ -33,6 +36,8 @@ class QueryService(QueryServiceInterface):
33
36
  self.agent_service = agent_service
34
37
  self.routing_service = routing_service
35
38
  self.memory_provider = memory_provider
39
+ self.knowledge_base = knowledge_base
40
+ self.kb_results_count = kb_results_count
36
41
 
37
42
  async def process(
38
43
  self,
@@ -99,12 +104,38 @@ class QueryService(QueryServiceInterface):
99
104
  if self.memory_provider:
100
105
  memory_context = await self.memory_provider.retrieve(user_id)
101
106
 
107
+ # Retrieve relevant knowledge from the KB
108
+ kb_context = ""
109
+ if self.knowledge_base:
110
+ try:
111
+ kb_results = await self.knowledge_base.query(
112
+ query_text=user_text,
113
+ top_k=self.kb_results_count,
114
+ include_content=True,
115
+ include_metadata=False
116
+ )
117
+
118
+ if kb_results:
119
+ kb_context = "**KNOWLEDGE BASE (CRITICAL: MAKE THIS INFORMATION THE TOP PRIORITY):**\n"
120
+ for i, result in enumerate(kb_results, 1):
121
+ content = result.get("content", "").strip()
122
+ kb_context += f"[{i}] {content}\n\n"
123
+ except Exception as e:
124
+ print(f"Error retrieving knowledge: {e}")
125
+
102
126
  # Route query to appropriate agent
103
127
  if router:
104
128
  agent_name = await router.route_query(user_text)
105
129
  else:
106
130
  agent_name = await self.routing_service.route_query(user_text)
107
131
 
132
+ # Combine context from memory and knowledge base
133
+ combined_context = ""
134
+ if memory_context:
135
+ combined_context += f"CONVERSATION HISTORY:\n{memory_context}\n\n"
136
+ if kb_context:
137
+ combined_context += f"{kb_context}\n"
138
+
108
139
  print(f"Routed to agent: {agent_name}")
109
140
 
110
141
  # Generate response
@@ -113,7 +144,7 @@ class QueryService(QueryServiceInterface):
113
144
  agent_name=agent_name,
114
145
  user_id=user_id,
115
146
  query=user_text,
116
- memory_context=memory_context,
147
+ memory_context=combined_context,
117
148
  output_format="audio",
118
149
  audio_voice=audio_voice,
119
150
  audio_output_format=audio_output_format,
@@ -134,7 +165,7 @@ class QueryService(QueryServiceInterface):
134
165
  agent_name=agent_name,
135
166
  user_id=user_id,
136
167
  query=user_text,
137
- memory_context=memory_context,
168
+ memory_context=combined_context,
138
169
  output_format="text",
139
170
  prompt=prompt,
140
171
  ):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: solana-agent
3
- Version: 27.2.0
3
+ Version: 27.3.0
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)
21
+ Requires-Dist: pinecone (>=6.0.2,<7.0.0)
19
22
  Requires-Dist: pydantic (>=2.11.3,<3.0.0)
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
@@ -51,6 +55,7 @@ Build your AI business in three lines of code!
51
55
  * Business Alignment
52
56
  * Extensible Tooling
53
57
  * Simple Business Definition
58
+ * Knowledge Base with PDF support
54
59
  * Tested & Secure
55
60
  * Built in Python
56
61
  * Powers [CometHeart](https://cometheart.com) & [WalletBubbles](https://walletbubbles.com)
@@ -70,6 +75,7 @@ Build your AI business in three lines of code!
70
75
  * Powerful tool integration using standard Python packages and/or inline tools
71
76
  * Assigned tools are utilized by agents automatically and effectively
72
77
  * Simple business definition using JSON
78
+ * Integrated Knowledge Base with semantic search and automatic PDF chunking
73
79
 
74
80
  ## Stack
75
81
 
@@ -79,15 +85,17 @@ Build your AI business in three lines of code!
79
85
  * [OpenAI](https://openai.com), [Google](https://ai.google.dev), [xAI](https://x.ai) - LLM Providers
80
86
  * [MongoDB](https://mongodb.com) - Conversational History (optional)
81
87
  * [Zep Cloud](https://getzep.com) - Conversational Memory (optional)
88
+ * [Pinecone](https://pinecone.io) - Knowledge Base (optional)
82
89
 
83
90
  ### LLMs
84
91
 
85
92
  * [gpt-4.1-mini](https://platform.openai.com/docs/models/gpt-4.1-mini) (agent)
86
93
  * [gpt-4.1-nano](https://platform.openai.com/docs/models/gpt-4.1-nano) (router)
87
- * [gemini-2.0-flash](https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash) (optional)
88
- * [grok-3-mini-fast-beta](https://docs.x.ai/docs/models#models-and-pricing) (optional)
94
+ * [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
95
  * [tts-1](https://platform.openai.com/docs/models/tts-1) (audio TTS)
90
96
  * [gpt-4o-mini-transcribe](https://platform.openai.com/docs/models/gpt-4o-mini-transcribe) (audio transcription)
97
+ * [gemini-2.0-flash](https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash) (optional)
98
+ * [grok-3-mini-fast-beta](https://docs.x.ai/docs/models#models-and-pricing) (optional)
91
99
 
92
100
  ## Installation
93
101
 
@@ -196,7 +204,7 @@ config = {
196
204
 
197
205
  solana_agent = SolanaAgent(config=config)
198
206
 
199
- audio_content = audio_file.read()
207
+ audio_content = await audio_file.read()
200
208
 
201
209
  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
210
  print(response, end="")
@@ -256,7 +264,7 @@ config = {
256
264
 
257
265
  solana_agent = SolanaAgent(config=config)
258
266
 
259
- audio_content = audio_file.read()
267
+ audio_content = await audio_file.read()
260
268
 
261
269
  async for response in solana_agent.process("user123", audio_content, audio_input_format="aac"):
262
270
  print(response, end="")
@@ -327,6 +335,114 @@ config = {
327
335
  }
328
336
  ```
329
337
 
338
+ ### Knowledge Base
339
+
340
+ The Knowledge Base (KB) is meant to store text values and/or small PDFs.
341
+
342
+ ```python
343
+ config = {
344
+ "knowledge_base": {
345
+ "pinecone": {
346
+ "api_key": "your-pinecone-api-key",
347
+ "index_name": "your-pinecone-index-name",
348
+ }
349
+ },
350
+ "mongo": {
351
+ "connection_string": "your-mongo-connection-string",
352
+ "database": "your-database-name"
353
+ },
354
+ }
355
+ ```
356
+
357
+ #### Example for KB (text)
358
+
359
+ ```python
360
+ from solana_agent import SolanaAgent
361
+
362
+ config = {
363
+ "openai": {
364
+ "api_key": "your-openai-api-key",
365
+ },
366
+ "knowledge_base": {
367
+ "pinecone": {
368
+ "api_key": "your-pinecone-api-key",
369
+ "index_name": "your-pinecone-index-name",
370
+ }
371
+ },
372
+ "mongo": {
373
+ "connection_string": "your-mongo-connection-string",
374
+ "database": "your-database-name"
375
+ },
376
+ "agents": [
377
+ {
378
+ "name": "kb_expert",
379
+ "instructions": "You answer questions based on the provided knowledge base documents.",
380
+ "specialization": "Company Knowledge",
381
+ }
382
+ ]
383
+ }
384
+
385
+ solana_agent = SolanaAgent(config=config)
386
+
387
+ doc_text = "Solana Agent is a Python framework for building multi-agent AI systems."
388
+ doc_metadata = {
389
+ "source": "internal_docs",
390
+ "version": "1.0",
391
+ "tags": ["framework", "python", "ai"]
392
+ }
393
+ await solana_agent.kb_add_document(text=doc_text, metadata=doc_metadata)
394
+
395
+ async for response in solana_agent.process("user123", "What is Solana Agent?"):
396
+ print(response, end="")
397
+ ```
398
+
399
+ #### Example for KB (pdf)
400
+
401
+ ```python
402
+ from solana_agent import SolanaAgent
403
+
404
+ config = {
405
+ "openai": {
406
+ "api_key": "your-openai-api-key",
407
+ },
408
+ "knowledge_base": {
409
+ "pinecone": {
410
+ "api_key": "your-pinecone-api-key",
411
+ "index_name": "your-pinecone-index-name",
412
+ }
413
+ },
414
+ "mongo": {
415
+ "connection_string": "your-mongo-connection-string",
416
+ "database": "your-database-name"
417
+ },
418
+ "agents": [
419
+ {
420
+ "name": "kb_expert",
421
+ "instructions": "You answer questions based on the provided knowledge base documents.",
422
+ "specialization": "Company Knowledge",
423
+ }
424
+ ]
425
+ }
426
+
427
+ solana_agent = SolanaAgent(config=config)
428
+
429
+ pdf_bytes = await pdf_file.read()
430
+
431
+ pdf_metadata = {
432
+ "source": "annual_report_2024.pdf",
433
+ "year": 2024,
434
+ "tags": ["finance", "report"]
435
+ }
436
+
437
+ await solana_agent.kb_add_pdf_document(
438
+ pdf_data=pdf_bytes,
439
+ metadata=pdf_metadata,
440
+ )
441
+
442
+ async for response in solana_agent.process("user123", "Summarize the annual report for 2024."):
443
+ print(response, end="")
444
+ ```
445
+
330
446
  ## Tools
331
447
 
332
448
  Tools can be used from plugins like Solana Agent Kit (sakit) or via inline tools. Tools available via plugins integrate automatically with Solana Agent.
@@ -453,13 +569,9 @@ async for response in solana_agent.process("user123", "What are the latest AI de
453
569
  print(response, end="")
454
570
  ```
455
571
 
456
- ## Agent Training
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.
572
+ ## Advanced Customization
461
573
 
462
- This knowledge is accessible to all your AI agents.
574
+ ### Runtime Prompt Injection
463
575
 
464
576
  ```python
465
577
  from solana_agent import SolanaAgent
@@ -483,7 +595,7 @@ async for response in solana_agent.process("user123", "How do replace the latch
483
595
  print(response, end="")
484
596
  ```
485
597
 
486
- ## Custom Routing
598
+ ### Custom Routing
487
599
 
488
600
  In advanced cases like implementing a ticketing system on-top of Solana Agent - you can use your own router.
489
601
 
@@ -1,21 +1,24 @@
1
1
  solana_agent/__init__.py,sha256=ceYeUpjIitpln8YK1r0JVJU8mzG6cRPYu-HLny3d-Tw,887
2
2
  solana_agent/adapters/__init__.py,sha256=tiEEuuy0NF3ngc_tGEcRTt71zVI58v3dYY9RvMrF2Cg,204
3
3
  solana_agent/adapters/mongodb_adapter.py,sha256=qqEFbY_v1XGyFXBmwd5HSXSSHnA9wWo-Hm1vGEyIG0k,2718
4
- solana_agent/adapters/openai_adapter.py,sha256=MVd5rLDcjDIFvNo9eh96NzreeDIE5FhpvYyjfhiRLag,9052
4
+ solana_agent/adapters/openai_adapter.py,sha256=-GS_ujZIF3OVq3LDWb30a4zEvUADvfECDo7GO1lQnqM,10997
5
+ solana_agent/adapters/pinecone_adapter.py,sha256=xn_353EoFYD8KCTckOOO4e0OKzukeBWpyhGUmDawURw,22591
5
6
  solana_agent/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- solana_agent/client/solana_agent.py,sha256=cjzTUYIaCpH152XlkX7YxeY6z3Jja7KNfkAFdTxmZyc,5208
7
+ solana_agent/client/solana_agent.py,sha256=gARyoQkWStre3bwaTrR1AoAqdCpI3sw_p0hl6z6kkmA,9982
7
8
  solana_agent/domains/__init__.py,sha256=HiC94wVPRy-QDJSSRywCRrhrFfTBeHjfi5z-QfZv46U,168
8
9
  solana_agent/domains/agent.py,sha256=WTo-pEc66V6D_35cpDE-kTsw1SJM-dtylPZ7em5em7Q,2659
9
10
  solana_agent/domains/routing.py,sha256=UDlgTjUoC9xIBVYu_dnf9-KG_bBgdEXAv_UtDOrYo0w,650
10
11
  solana_agent/factories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- solana_agent/factories/agent_factory.py,sha256=e7eDVMDWKoKCwm9vWY_KSF957QgWT1m06uXgmYRmq1o,7900
12
+ solana_agent/factories/agent_factory.py,sha256=7O1WdWA9etV2Wk8DRJUf7qTiFD3GOhBN2T278sfRegM,11536
12
13
  solana_agent/interfaces/__init__.py,sha256=IQs1WIM1FeKP1-kY2FEfyhol_dB-I-VAe2rD6jrVF6k,355
13
- solana_agent/interfaces/client/client.py,sha256=CB8YuSsn-Lvinrb12huyIVaFpJqVDh8EHsHJi9SVXM4,1690
14
+ solana_agent/interfaces/client/client.py,sha256=rIZQXFenEpoSWUvZrCMNE-FWwYwZMCBvXSFC8vCWksg,3610
14
15
  solana_agent/interfaces/plugins/plugins.py,sha256=T8HPBsekmzVwfU_Rizp-vtzAeYkMlKMYD7U9d0Wjq9c,3338
15
16
  solana_agent/interfaces/providers/data_storage.py,sha256=NqGeFvAzhz9rr-liLPRNCGjooB2EIhe-EVsMmX__b0M,1658
16
- solana_agent/interfaces/providers/llm.py,sha256=DA1vPWfZPhmZuJOwD5j9VxQmXEEEmyaqKVvbphCnyds,1830
17
+ solana_agent/interfaces/providers/llm.py,sha256=gcZeu8ErLoSmdXWKiBVZuNl31c0KIUhGwX3wPBD_xuI,2356
17
18
  solana_agent/interfaces/providers/memory.py,sha256=oNOH8WZXVW8assDigIWZAWiwkxbpDiKupxA2RB6tQvQ,1010
19
+ solana_agent/interfaces/providers/vector_storage.py,sha256=zgdlzQuXCRREVSlB-g7QKKNjVoshSe2AFoAt4CHCAB0,1606
18
20
  solana_agent/interfaces/services/agent.py,sha256=tVs2piqWVfO1JiRd58e29oP1GWgYuCzberRSfaFfH4M,1979
21
+ solana_agent/interfaces/services/knowledge_base.py,sha256=J4jGeWcxpKL3XpcrqdNuV1xyd5dj2d-hyAmx4AZ272w,2103
19
22
  solana_agent/interfaces/services/query.py,sha256=yo2JZPJSy2iwxtkUlMz0emm9u_27xNgnrAFJRHQoulQ,1480
20
23
  solana_agent/interfaces/services/routing.py,sha256=UzJC-z-Q9puTWPFGEo2_CAhIxuxP5IRnze7S66NSrsI,397
21
24
  solana_agent/plugins/__init__.py,sha256=coZdgJKq1ExOaj6qB810i3rEhbjdVlrkN76ozt_Ojgo,193
@@ -27,9 +30,10 @@ solana_agent/repositories/__init__.py,sha256=fP83w83CGzXLnSdq-C5wbw9EhWTYtqE2lQT
27
30
  solana_agent/repositories/memory.py,sha256=0S3oJIwrJgLokFZHc5nL6Wva_CLdnkwJKfAwmMcpa9E,7853
28
31
  solana_agent/services/__init__.py,sha256=ab_NXJmwYUCmCrCzuTlZ47bJZINW0Y0F5jfQ9OovidU,163
29
32
  solana_agent/services/agent.py,sha256=M1Aukr9xKGP9mL0jM_JqdRdWSqG4LxF0y0PDAzE_fpY,24608
30
- solana_agent/services/query.py,sha256=bhB6bZKWqsEf_fLXfsSC57q0CtmeDI6jUlxc9a0LGJw,11099
33
+ solana_agent/services/knowledge_base.py,sha256=bvoLZHSrfp6BhT8i4fKhxOkaUkYGCFedLp2uTzL-7xI,32379
34
+ solana_agent/services/query.py,sha256=TAPwgeQViCEg71q9u8oaqD0-W5sR1ipDlPAFkqGlRA8,12528
31
35
  solana_agent/services/routing.py,sha256=hC5t98KZPHty9kMX27KcuxcmZlwjm0g59uMkR8n7k_w,6818
32
- solana_agent-27.2.0.dist-info/LICENSE,sha256=BnSRc-NSFuyF2s496l_4EyrwAP6YimvxWcjPiJ0J7g4,1057
33
- solana_agent-27.2.0.dist-info/METADATA,sha256=6LjVC0gu7_Lv9lkt35s8wv-Wl1TfHWebN9j_NDoxc74,19260
34
- solana_agent-27.2.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
35
- solana_agent-27.2.0.dist-info/RECORD,,
36
+ solana_agent-27.3.0.dist-info/LICENSE,sha256=BnSRc-NSFuyF2s496l_4EyrwAP6YimvxWcjPiJ0J7g4,1057
37
+ solana_agent-27.3.0.dist-info/METADATA,sha256=Rij3Z-DwLTDbKX0Max2mmuOE7LcbDLyOPC6dey7tJwU,22183
38
+ solana_agent-27.3.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
39
+ solana_agent-27.3.0.dist-info/RECORD,,