solana-agent 17.0.2__py3-none-any.whl → 17.0.3__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 +30 -13
- solana_agent/services/query.py +33 -27
- {solana_agent-17.0.2.dist-info → solana_agent-17.0.3.dist-info}/METADATA +1 -1
- {solana_agent-17.0.2.dist-info → solana_agent-17.0.3.dist-info}/RECORD +6 -6
- {solana_agent-17.0.2.dist-info → solana_agent-17.0.3.dist-info}/LICENSE +0 -0
- {solana_agent-17.0.2.dist-info → solana_agent-17.0.3.dist-info}/WHEEL +0 -0
solana_agent/services/agent.py
CHANGED
@@ -39,6 +39,7 @@ class AgentService(AgentServiceInterface):
|
|
39
39
|
self.agent_repository = agent_repository
|
40
40
|
self.organization_mission = organization_mission
|
41
41
|
self.config = config or {}
|
42
|
+
self.last_text_response = ""
|
42
43
|
|
43
44
|
# Initialize tool registry with concrete implementation
|
44
45
|
if tool_registry:
|
@@ -247,6 +248,8 @@ class AgentService(AgentServiceInterface):
|
|
247
248
|
if memory_context:
|
248
249
|
system_prompt += f"\n\nMemory Context: {memory_context}"
|
249
250
|
|
251
|
+
# Keep track of the complete text response
|
252
|
+
complete_text_response = ""
|
250
253
|
json_buffer = ""
|
251
254
|
is_json = False
|
252
255
|
text_buffer = ""
|
@@ -277,6 +280,9 @@ class AgentService(AgentServiceInterface):
|
|
277
280
|
json_chunk=json_buffer
|
278
281
|
)
|
279
282
|
|
283
|
+
# Add to complete text response
|
284
|
+
complete_text_response += response_text
|
285
|
+
|
280
286
|
# Output response based on format
|
281
287
|
if output_format == "audio":
|
282
288
|
async for audio_chunk in self.llm_provider.tts(
|
@@ -288,7 +294,9 @@ class AgentService(AgentServiceInterface):
|
|
288
294
|
else:
|
289
295
|
yield response_text
|
290
296
|
else:
|
291
|
-
#
|
297
|
+
# For non-tool JSON, still capture the text
|
298
|
+
complete_text_response += json_buffer
|
299
|
+
|
292
300
|
if output_format == "audio":
|
293
301
|
async for audio_chunk in self.llm_provider.tts(
|
294
302
|
text=json_buffer,
|
@@ -304,10 +312,12 @@ class AgentService(AgentServiceInterface):
|
|
304
312
|
json_buffer = ""
|
305
313
|
|
306
314
|
except json.JSONDecodeError:
|
307
|
-
# Incomplete JSON, continue collecting
|
308
315
|
pass
|
309
316
|
else:
|
310
|
-
#
|
317
|
+
# For regular text, always add to the complete response
|
318
|
+
complete_text_response += chunk
|
319
|
+
|
320
|
+
# Handle audio buffering or direct text output
|
311
321
|
if output_format == "audio":
|
312
322
|
text_buffer += chunk
|
313
323
|
if any(punct in chunk for punct in ".!?"):
|
@@ -326,18 +336,25 @@ class AgentService(AgentServiceInterface):
|
|
326
336
|
if text_buffer:
|
327
337
|
remaining_text += text_buffer
|
328
338
|
if is_json and json_buffer:
|
329
|
-
# If we have incomplete JSON at the end, yield it as text
|
330
339
|
remaining_text += json_buffer
|
331
340
|
|
332
|
-
if remaining_text
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
+
if remaining_text:
|
342
|
+
# Add remaining text to complete response
|
343
|
+
complete_text_response += remaining_text
|
344
|
+
|
345
|
+
if output_format == "audio":
|
346
|
+
async for audio_chunk in self.llm_provider.tts(
|
347
|
+
text=remaining_text,
|
348
|
+
voice=audio_voice,
|
349
|
+
response_format=audio_output_format
|
350
|
+
):
|
351
|
+
yield audio_chunk
|
352
|
+
else:
|
353
|
+
yield remaining_text
|
354
|
+
|
355
|
+
# Store the complete text response for the caller to access
|
356
|
+
# This needs to be done in the query service using the self.last_text_response
|
357
|
+
self.last_text_response = complete_text_response
|
341
358
|
|
342
359
|
except Exception as e:
|
343
360
|
error_msg = f"I apologize, but I encountered an error: {str(e)}"
|
solana_agent/services/query.py
CHANGED
@@ -52,11 +52,8 @@ class QueryService(QueryServiceInterface):
|
|
52
52
|
Args:
|
53
53
|
user_id: User ID
|
54
54
|
query: Text query or audio bytes
|
55
|
-
output_format: Response format ("text" or "audio")
|
56
|
-
|
57
|
-
audio_instructions: Optional instructions for audio synthesis
|
58
|
-
audio_output_format: Audio output format
|
59
|
-
audio_input_format: Audio input format
|
55
|
+
output_format: Response format ("text" or "audio")
|
56
|
+
voice: Voice to use for audio output
|
60
57
|
|
61
58
|
Yields:
|
62
59
|
Response chunks (text strings or audio bytes)
|
@@ -74,7 +71,11 @@ class QueryService(QueryServiceInterface):
|
|
74
71
|
if user_text.strip().lower() in ["test", "hello", "hi", "hey", "ping"]:
|
75
72
|
response = "Hello! How can I help you today?"
|
76
73
|
if output_format == "audio":
|
77
|
-
async for chunk in self.agent_service.llm_provider.tts(
|
74
|
+
async for chunk in self.agent_service.llm_provider.tts(
|
75
|
+
text=response,
|
76
|
+
voice=audio_voice,
|
77
|
+
response_format=audio_output_format
|
78
|
+
):
|
78
79
|
yield chunk
|
79
80
|
else:
|
80
81
|
yield response
|
@@ -91,42 +92,47 @@ class QueryService(QueryServiceInterface):
|
|
91
92
|
|
92
93
|
# Route query to appropriate agent
|
93
94
|
agent_name = await self.routing_service.route_query(user_text)
|
95
|
+
print(f"DEBUG: Routed to agent: {agent_name}")
|
94
96
|
|
95
|
-
#
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
yield chunk
|
107
|
-
if output_format == "text":
|
97
|
+
# For text output, we can directly collect and yield chunks
|
98
|
+
if output_format == "text":
|
99
|
+
full_response = ""
|
100
|
+
async for chunk in self.agent_service.generate_response(
|
101
|
+
agent_name=agent_name,
|
102
|
+
user_id=user_id,
|
103
|
+
query=user_text,
|
104
|
+
memory_context=memory_context,
|
105
|
+
output_format="text",
|
106
|
+
):
|
107
|
+
yield chunk
|
108
108
|
full_response += chunk
|
109
109
|
|
110
|
-
# For audio
|
111
|
-
|
112
|
-
# Re-generate response in text format for storage
|
110
|
+
# For audio output, we'll yield audio chunks while collecting text separately
|
111
|
+
else:
|
113
112
|
async for chunk in self.agent_service.generate_response(
|
114
113
|
agent_name=agent_name,
|
115
114
|
user_id=user_id,
|
116
115
|
query=user_text,
|
117
116
|
memory_context=memory_context,
|
118
|
-
output_format="
|
117
|
+
output_format="audio",
|
118
|
+
audio_input_format=audio_input_format,
|
119
|
+
audio_output_format=audio_output_format,
|
120
|
+
audio_voice=audio_voice,
|
119
121
|
):
|
120
|
-
|
122
|
+
yield chunk
|
121
123
|
|
122
|
-
# Store conversation
|
124
|
+
# Store conversation with the full text response
|
123
125
|
if self.memory_provider:
|
124
|
-
await self._store_conversation(user_id, user_text,
|
126
|
+
await self._store_conversation(user_id, user_text, self.agent_service.last_text_response)
|
125
127
|
|
126
128
|
except Exception as e:
|
127
129
|
error_msg = f"I apologize for the technical difficulty. {str(e)}"
|
128
130
|
if output_format == "audio":
|
129
|
-
async for chunk in self.agent_service.llm_provider.tts(
|
131
|
+
async for chunk in self.agent_service.llm_provider.tts(
|
132
|
+
text=error_msg,
|
133
|
+
voice=audio_voice,
|
134
|
+
response_format=audio_output_format
|
135
|
+
):
|
130
136
|
yield chunk
|
131
137
|
else:
|
132
138
|
yield error_msg
|
@@ -28,10 +28,10 @@ solana_agent/repositories/__init__.py,sha256=fP83w83CGzXLnSdq-C5wbw9EhWTYtqE2lQT
|
|
28
28
|
solana_agent/repositories/agent.py,sha256=e1rnsQiigkKwJNLKro86a3b6TBiky3GMfmCRc5b_jPw,3187
|
29
29
|
solana_agent/repositories/memory.py,sha256=GABGwaz00thjviHewLvb18NeKE8dkBROxy_stsiiWrE,4722
|
30
30
|
solana_agent/services/__init__.py,sha256=ab_NXJmwYUCmCrCzuTlZ47bJZINW0Y0F5jfQ9OovidU,163
|
31
|
-
solana_agent/services/agent.py,sha256=
|
32
|
-
solana_agent/services/query.py,sha256=
|
31
|
+
solana_agent/services/agent.py,sha256=j0aI_BGaY5Nhkb9ga0r4BqI3qMKu5TOc4QPQsU3NHyQ,17000
|
32
|
+
solana_agent/services/query.py,sha256=1BAb4UjpydwtJjut8oq724BJohe9ceMigMX-rkI5j7s,10820
|
33
33
|
solana_agent/services/routing.py,sha256=TPJ2Pas4acE93QzMEV6ZP670OtTNrVEPa76fz6urEV4,4996
|
34
|
-
solana_agent-17.0.
|
35
|
-
solana_agent-17.0.
|
36
|
-
solana_agent-17.0.
|
37
|
-
solana_agent-17.0.
|
34
|
+
solana_agent-17.0.3.dist-info/LICENSE,sha256=BnSRc-NSFuyF2s496l_4EyrwAP6YimvxWcjPiJ0J7g4,1057
|
35
|
+
solana_agent-17.0.3.dist-info/METADATA,sha256=kioM7hvaI97S8skANaI4oAcS2gnKgGMvI2jKTTHf5vg,4888
|
36
|
+
solana_agent-17.0.3.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
37
|
+
solana_agent-17.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|