solana-agent 22.0.2__py3-none-any.whl → 22.0.4__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.
- solana_agent/services/agent.py +47 -13
- {solana_agent-22.0.2.dist-info → solana_agent-22.0.4.dist-info}/METADATA +1 -1
- {solana_agent-22.0.2.dist-info → solana_agent-22.0.4.dist-info}/RECORD +5 -5
- {solana_agent-22.0.2.dist-info → solana_agent-22.0.4.dist-info}/LICENSE +0 -0
- {solana_agent-22.0.2.dist-info → solana_agent-22.0.4.dist-info}/WHEEL +0 -0
solana_agent/services/agent.py
CHANGED
@@ -5,6 +5,7 @@ This service manages AI and human agents, their registration, tool assignments,
|
|
5
5
|
and response generation.
|
6
6
|
"""
|
7
7
|
import asyncio
|
8
|
+
from copy import deepcopy
|
8
9
|
import datetime as main_datetime
|
9
10
|
from datetime import datetime
|
10
11
|
import json
|
@@ -199,12 +200,8 @@ class AgentService(AgentServiceInterface):
|
|
199
200
|
else:
|
200
201
|
query_text = query
|
201
202
|
|
202
|
-
# Get system prompt
|
203
|
+
# Get system prompt
|
203
204
|
system_prompt = self.get_agent_system_prompt(agent_name)
|
204
|
-
if self.tool_registry:
|
205
|
-
tool_usage_prompt = self._get_tool_usage_prompt(agent_name)
|
206
|
-
if tool_usage_prompt:
|
207
|
-
system_prompt = f"{system_prompt}\n\n{tool_usage_prompt}"
|
208
205
|
|
209
206
|
# Add User ID and memory context
|
210
207
|
system_prompt += f"\n\nUser ID: {user_id}"
|
@@ -213,6 +210,13 @@ class AgentService(AgentServiceInterface):
|
|
213
210
|
if prompt:
|
214
211
|
system_prompt += f"\n\nADDITIONAL PROMPT: {prompt}"
|
215
212
|
|
213
|
+
# make tool calling prompt
|
214
|
+
tool_calling_system_prompt = deepcopy(system_prompt)
|
215
|
+
if self.tool_registry:
|
216
|
+
tool_usage_prompt = self._get_tool_usage_prompt(agent_name)
|
217
|
+
if tool_usage_prompt:
|
218
|
+
tool_calling_system_prompt += f"\n\nTOOL CALLING PROMPT: {tool_usage_prompt}"
|
219
|
+
|
216
220
|
# Variables for tracking the response
|
217
221
|
complete_text_response = ""
|
218
222
|
|
@@ -226,7 +230,7 @@ class AgentService(AgentServiceInterface):
|
|
226
230
|
# Generate and stream response
|
227
231
|
async for chunk in self.llm_provider.generate_text(
|
228
232
|
prompt=query_text,
|
229
|
-
system_prompt=
|
233
|
+
system_prompt=tool_calling_system_prompt,
|
230
234
|
internet_search=internet_search,
|
231
235
|
):
|
232
236
|
# Check if the chunk is JSON or a tool call
|
@@ -276,7 +280,7 @@ class AgentService(AgentServiceInterface):
|
|
276
280
|
tool_response += processed_chunk
|
277
281
|
|
278
282
|
# Add to our complete text record and full audio buffer
|
279
|
-
tool_response = self.
|
283
|
+
tool_response = self._clean_for_audio(
|
280
284
|
tool_response)
|
281
285
|
complete_text_response += tool_response
|
282
286
|
full_response_buffer += tool_response
|
@@ -318,8 +322,8 @@ class AgentService(AgentServiceInterface):
|
|
318
322
|
|
319
323
|
# For audio output, now process the complete response
|
320
324
|
if output_format == "audio" and full_response_buffer:
|
321
|
-
# Clean
|
322
|
-
full_response_buffer = self.
|
325
|
+
# Clean text before TTS
|
326
|
+
full_response_buffer = self._clean_for_audio(
|
323
327
|
full_response_buffer)
|
324
328
|
|
325
329
|
# Process the entire response with TTS
|
@@ -427,14 +431,14 @@ class AgentService(AgentServiceInterface):
|
|
427
431
|
- Use exact tool names as shown in AVAILABLE TOOLS
|
428
432
|
"""
|
429
433
|
|
430
|
-
def
|
431
|
-
"""Remove Markdown formatting and
|
434
|
+
def _clean_for_audio(self, text: str) -> str:
|
435
|
+
"""Remove Markdown formatting, emojis, and non-pronounceable characters from text.
|
432
436
|
|
433
437
|
Args:
|
434
|
-
text: Input text with potential Markdown formatting
|
438
|
+
text: Input text with potential Markdown formatting and special characters
|
435
439
|
|
436
440
|
Returns:
|
437
|
-
Clean text without Markdown
|
441
|
+
Clean text without Markdown, emojis, and special characters
|
438
442
|
"""
|
439
443
|
import re
|
440
444
|
|
@@ -469,4 +473,34 @@ class AgentService(AgentServiceInterface):
|
|
469
473
|
# Remove multiple consecutive newlines (keep just one)
|
470
474
|
text = re.sub(r'\n{3,}', '\n\n', text)
|
471
475
|
|
476
|
+
# Remove emojis and other non-pronounceable characters
|
477
|
+
# Common emoji Unicode ranges
|
478
|
+
emoji_pattern = re.compile(
|
479
|
+
"["
|
480
|
+
"\U0001F600-\U0001F64F" # emoticons
|
481
|
+
"\U0001F300-\U0001F5FF" # symbols & pictographs
|
482
|
+
"\U0001F680-\U0001F6FF" # transport & map symbols
|
483
|
+
"\U0001F700-\U0001F77F" # alchemical symbols
|
484
|
+
"\U0001F780-\U0001F7FF" # Geometric Shapes
|
485
|
+
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
|
486
|
+
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
|
487
|
+
"\U0001FA00-\U0001FA6F" # Chess Symbols
|
488
|
+
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
|
489
|
+
"\U00002702-\U000027B0" # Dingbats
|
490
|
+
"\U000024C2-\U0000257F" # Enclosed characters
|
491
|
+
"\U00002600-\U000026FF" # Miscellaneous Symbols
|
492
|
+
"\U00002700-\U000027BF" # Dingbats
|
493
|
+
"\U0000FE00-\U0000FE0F" # Variation Selectors
|
494
|
+
"\U0001F1E0-\U0001F1FF" # Flags (iOS)
|
495
|
+
"]+",
|
496
|
+
flags=re.UNICODE
|
497
|
+
)
|
498
|
+
text = emoji_pattern.sub(r' ', text)
|
499
|
+
|
500
|
+
# Replace special characters that can cause issues with TTS
|
501
|
+
text = re.sub(r'[^\w\s\.\,\;\:\?\!\'\"\-\(\)]', ' ', text)
|
502
|
+
|
503
|
+
# Replace multiple spaces with a single space
|
504
|
+
text = re.sub(r'\s+', ' ', text)
|
505
|
+
|
472
506
|
return text.strip()
|
@@ -26,10 +26,10 @@ solana_agent/plugins/tools/auto_tool.py,sha256=DgES_cZ6xKSf_HJpFINpvJxrjVlk5oeqa
|
|
26
26
|
solana_agent/repositories/__init__.py,sha256=fP83w83CGzXLnSdq-C5wbw9EhWTYtqE2lQTgp46-X_4,163
|
27
27
|
solana_agent/repositories/memory.py,sha256=mrpmNSQ0D_eLebNY-cBqtecVVpIGXE7s9jCzOWEAuR4,6984
|
28
28
|
solana_agent/services/__init__.py,sha256=ab_NXJmwYUCmCrCzuTlZ47bJZINW0Y0F5jfQ9OovidU,163
|
29
|
-
solana_agent/services/agent.py,sha256=
|
29
|
+
solana_agent/services/agent.py,sha256=bIVC4VGCv8qS5AF0nh_hfUjz8nu70Owll-VuvHJ9X48,20047
|
30
30
|
solana_agent/services/query.py,sha256=os_LRkDIwXQuWW_zJMtm__n0Lvi-AvItdanpCs1bXv0,11362
|
31
31
|
solana_agent/services/routing.py,sha256=PMCSG5m3uLMaHMj3dxNvNfcFZaeaDi7kMr7AEBCzwDE,6499
|
32
|
-
solana_agent-22.0.
|
33
|
-
solana_agent-22.0.
|
34
|
-
solana_agent-22.0.
|
35
|
-
solana_agent-22.0.
|
32
|
+
solana_agent-22.0.4.dist-info/LICENSE,sha256=BnSRc-NSFuyF2s496l_4EyrwAP6YimvxWcjPiJ0J7g4,1057
|
33
|
+
solana_agent-22.0.4.dist-info/METADATA,sha256=1Ek0Si7v2t-LuLMC0YUnoKF8sxATs728NhjPoDT4OMc,14882
|
34
|
+
solana_agent-22.0.4.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
35
|
+
solana_agent-22.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|