sunholo 0.140.9__py3-none-any.whl → 0.140.10__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.
- sunholo/agents/flask/vac_routes.py +15 -30
- {sunholo-0.140.9.dist-info → sunholo-0.140.10.dist-info}/METADATA +1 -1
- {sunholo-0.140.9.dist-info → sunholo-0.140.10.dist-info}/RECORD +7 -7
- {sunholo-0.140.9.dist-info → sunholo-0.140.10.dist-info}/WHEEL +0 -0
- {sunholo-0.140.9.dist-info → sunholo-0.140.10.dist-info}/entry_points.txt +0 -0
- {sunholo-0.140.9.dist-info → sunholo-0.140.10.dist-info}/licenses/LICENSE.txt +0 -0
- {sunholo-0.140.9.dist-info → sunholo-0.140.10.dist-info}/top_level.txt +0 -0
@@ -286,30 +286,20 @@ if __name__ == "__main__":
|
|
286
286
|
log.warning(f"Background trace finalization failed: {e}")
|
287
287
|
|
288
288
|
def handle_stream_vac(self, vector_name):
|
289
|
-
request_start = time.time()
|
290
289
|
observed_stream_interpreter = self.stream_interpreter
|
291
290
|
is_async = inspect.iscoroutinefunction(self.stream_interpreter)
|
292
291
|
|
293
292
|
if is_async:
|
294
293
|
log.info(f"Stream interpreter is async: {observed_stream_interpreter}")
|
295
294
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
log.error(f"prep_vac failed: {e}")
|
301
|
-
error_response = {'error': f'Prep error: {str(e)}'}
|
302
|
-
return jsonify(error_response), 500
|
303
|
-
|
304
|
-
log.info(f"Processing prep completed in {time.time() - request_start:.3f}s")
|
305
|
-
|
306
|
-
trace = prep.get("trace")
|
307
|
-
span = prep.get("span")
|
295
|
+
prep = self.prep_vac(request, vector_name)
|
296
|
+
log.info(f"Processing prep: {prep}")
|
297
|
+
trace = prep["trace"]
|
298
|
+
span = prep["span"]
|
308
299
|
vac_config = prep["vac_config"]
|
309
300
|
all_input = prep["all_input"]
|
310
301
|
|
311
|
-
log.info(f'
|
312
|
-
|
302
|
+
log.info(f'Streaming data with: {all_input}')
|
313
303
|
if span:
|
314
304
|
span.update(
|
315
305
|
name="start_streaming_chat",
|
@@ -320,7 +310,7 @@ if __name__ == "__main__":
|
|
320
310
|
def generate_response_content():
|
321
311
|
try:
|
322
312
|
if is_async:
|
323
|
-
from queue import Queue
|
313
|
+
from queue import Queue, Empty
|
324
314
|
result_queue = Queue()
|
325
315
|
import threading
|
326
316
|
|
@@ -337,7 +327,7 @@ if __name__ == "__main__":
|
|
337
327
|
trace_id=trace.id if trace else None,
|
338
328
|
**all_input["kwargs"]
|
339
329
|
)
|
340
|
-
|
330
|
+
log.info(f"{async_gen=}")
|
341
331
|
async for chunk in async_gen:
|
342
332
|
if isinstance(chunk, dict) and 'answer' in chunk:
|
343
333
|
if trace:
|
@@ -350,12 +340,9 @@ if __name__ == "__main__":
|
|
350
340
|
else:
|
351
341
|
result_queue.put(chunk)
|
352
342
|
except Exception as e:
|
353
|
-
|
354
|
-
log.error(error_msg)
|
355
|
-
result_queue.put(error_msg)
|
343
|
+
result_queue.put(f"Streaming Error: {str(e)} {traceback.format_exc()}")
|
356
344
|
finally:
|
357
345
|
result_queue.put(None) # Sentinel
|
358
|
-
|
359
346
|
asyncio.run(process_async())
|
360
347
|
|
361
348
|
thread = threading.Thread(target=run_async)
|
@@ -370,7 +357,7 @@ if __name__ == "__main__":
|
|
370
357
|
|
371
358
|
thread.join()
|
372
359
|
else:
|
373
|
-
log.info("
|
360
|
+
log.info("sync streaming response")
|
374
361
|
for chunk in start_streaming_chat(
|
375
362
|
question=all_input["user_input"],
|
376
363
|
vector_name=vector_name,
|
@@ -394,19 +381,17 @@ if __name__ == "__main__":
|
|
394
381
|
yield chunk
|
395
382
|
|
396
383
|
except Exception as e:
|
397
|
-
|
398
|
-
log.error(error_msg)
|
399
|
-
yield error_msg
|
384
|
+
yield f"Streaming Error: {str(e)} {traceback.format_exc()}"
|
400
385
|
|
401
|
-
#
|
386
|
+
# Here, the generator function will handle streaming the content to the client.
|
402
387
|
response = Response(generate_response_content(), content_type='text/plain; charset=utf-8')
|
403
388
|
response.headers['Transfer-Encoding'] = 'chunked'
|
404
389
|
|
405
|
-
log.
|
406
|
-
|
407
|
-
# Do final trace operations in background (don't block the response)
|
390
|
+
log.debug(f"streaming response: {response}")
|
408
391
|
if trace:
|
409
|
-
|
392
|
+
span.end(output=response)
|
393
|
+
trace.update(output=response)
|
394
|
+
self.langfuse_eval_response(trace_id=trace.id, eval_percent=all_input.get('eval_percent'))
|
410
395
|
|
411
396
|
return response
|
412
397
|
|
@@ -14,7 +14,7 @@ sunholo/agents/fastapi/base.py,sha256=W-cyF8ZDUH40rc-c-Apw3-_8IIi2e4Y9qRtnoVnsc1
|
|
14
14
|
sunholo/agents/fastapi/qna_routes.py,sha256=lKHkXPmwltu9EH3RMwmD153-J6pE7kWQ4BhBlV3to-s,3864
|
15
15
|
sunholo/agents/flask/__init__.py,sha256=dEoByI3gDNUOjpX1uVKP7uPjhfFHJubbiaAv3xLopnk,63
|
16
16
|
sunholo/agents/flask/base.py,sha256=vnpxFEOnCmt9humqj-jYPLfJcdwzsop9NorgkJ-tSaU,1756
|
17
|
-
sunholo/agents/flask/vac_routes.py,sha256=
|
17
|
+
sunholo/agents/flask/vac_routes.py,sha256=QfM1nChWLAXhZ4_YYAsiXMss2CeQgxVI0GPD2fNLkmE,34541
|
18
18
|
sunholo/archive/__init__.py,sha256=qNHWm5rGPVOlxZBZCpA1wTYPbalizRT7f8X4rs2t290,31
|
19
19
|
sunholo/archive/archive.py,sha256=PxVfDtO2_2ZEEbnhXSCbXLdeoHoQVImo4y3Jr2XkCFY,1204
|
20
20
|
sunholo/auth/__init__.py,sha256=TeP-OY0XGxYV_8AQcVGoh35bvyWhNUcMRfhuD5l44Sk,91
|
@@ -168,9 +168,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
168
168
|
sunholo/vertex/memory_tools.py,sha256=tBZxqVZ4InTmdBvLlOYwoSEWu4-kGquc-gxDwZCC4FA,7667
|
169
169
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
170
170
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
171
|
-
sunholo-0.140.
|
172
|
-
sunholo-0.140.
|
173
|
-
sunholo-0.140.
|
174
|
-
sunholo-0.140.
|
175
|
-
sunholo-0.140.
|
176
|
-
sunholo-0.140.
|
171
|
+
sunholo-0.140.10.dist-info/licenses/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
172
|
+
sunholo-0.140.10.dist-info/METADATA,sha256=EfU0N2go-DI1A6WaL5p_K9TtXwf8PkZCdUWZOoM7j4c,10068
|
173
|
+
sunholo-0.140.10.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
174
|
+
sunholo-0.140.10.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
175
|
+
sunholo-0.140.10.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
176
|
+
sunholo-0.140.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|