sunholo 0.89.2__py3-none-any.whl → 0.89.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.
- sunholo/agents/flask/vac_routes.py +35 -3
- sunholo/langfuse/evals.py +5 -4
- {sunholo-0.89.2.dist-info → sunholo-0.89.4.dist-info}/METADATA +2 -2
- {sunholo-0.89.2.dist-info → sunholo-0.89.4.dist-info}/RECORD +8 -8
- {sunholo-0.89.2.dist-info → sunholo-0.89.4.dist-info}/LICENSE.txt +0 -0
- {sunholo-0.89.2.dist-info → sunholo-0.89.4.dist-info}/WHEEL +0 -0
- {sunholo-0.89.2.dist-info → sunholo-0.89.4.dist-info}/entry_points.txt +0 -0
- {sunholo-0.89.2.dist-info → sunholo-0.89.4.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@ import json
|
|
|
2
2
|
import traceback
|
|
3
3
|
import datetime
|
|
4
4
|
import uuid
|
|
5
|
+
import random
|
|
5
6
|
|
|
6
7
|
from ...agents import extract_chat_history, handle_special_commands
|
|
7
8
|
from ...qna.parsers import parse_output
|
|
@@ -18,12 +19,12 @@ from datetime import timedelta
|
|
|
18
19
|
try:
|
|
19
20
|
from flask import request, jsonify, Response
|
|
20
21
|
except ImportError:
|
|
21
|
-
pass
|
|
22
|
+
pass
|
|
22
23
|
|
|
23
24
|
try:
|
|
24
|
-
from
|
|
25
|
+
from ..pubsub import PubSubManager
|
|
25
26
|
except ImportError:
|
|
26
|
-
|
|
27
|
+
PubSubManager = None
|
|
27
28
|
|
|
28
29
|
# Cache dictionary to store validated API keys
|
|
29
30
|
api_key_cache = {}
|
|
@@ -221,8 +222,38 @@ if __name__ == "__main__":
|
|
|
221
222
|
generation.end(output=response)
|
|
222
223
|
span.end(output=response)
|
|
223
224
|
trace.update(output=response)
|
|
225
|
+
self.langfuse_eval_response(trace.id, all_input.get('eval_percent', 0.01))
|
|
224
226
|
|
|
225
227
|
return response
|
|
228
|
+
|
|
229
|
+
def langfuse_eval_response(trace_id, eval_percent=0.01):
|
|
230
|
+
"""
|
|
231
|
+
Sends an evaluation message based on a probability defined by eval_percent.
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
eval_percent (float): The probability (0 to 1) of triggering the evaluation.
|
|
235
|
+
trace_id (str): The trace identifier for the evaluation.
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
None
|
|
239
|
+
"""
|
|
240
|
+
if eval_percent > 1 or eval_percent < 0:
|
|
241
|
+
raise ValueError("eval_percent must be a float between 0 and 1.")
|
|
242
|
+
|
|
243
|
+
# Generate a random float between 0 and 1
|
|
244
|
+
random_value = random.random()
|
|
245
|
+
|
|
246
|
+
# Check if evaluation should be triggered
|
|
247
|
+
if random_value < eval_percent:
|
|
248
|
+
if PubSubManager:
|
|
249
|
+
try:
|
|
250
|
+
pubsub_manager = PubSubManager("langfuse_evals", pubsub_topic="topicid-to-langfuse-eval")
|
|
251
|
+
the_data = {"trace_id": trace_id}
|
|
252
|
+
pubsub_manager.publish_message(the_data)
|
|
253
|
+
except Exception as e:
|
|
254
|
+
log.warning(f"Could not publish message for 'langfuse_evals' to topicid-to-langfuse-eval - {str(e)}")
|
|
255
|
+
else:
|
|
256
|
+
log.info(f"Did not do Langfuse eval due to random sampling not passed: {eval_percent=}")
|
|
226
257
|
|
|
227
258
|
def handle_process_vac(self, vector_name):
|
|
228
259
|
observed_vac_interpreter = self.vac_interpreter
|
|
@@ -268,6 +299,7 @@ if __name__ == "__main__":
|
|
|
268
299
|
if trace:
|
|
269
300
|
span.end(output=jsonify(bot_output))
|
|
270
301
|
trace.update(output=jsonify(bot_output))
|
|
302
|
+
self.langfuse_eval_response(trace.id, all_input.get('eval_percent', 0.01))
|
|
271
303
|
|
|
272
304
|
# {'answer': 'output'}
|
|
273
305
|
return jsonify(bot_output)
|
sunholo/langfuse/evals.py
CHANGED
|
@@ -38,8 +38,9 @@ def pubsub_to_evals(data: dict, eval_funcs: list=[eval_length]) -> dict:
|
|
|
38
38
|
def direct_langfuse_evals(data, eval_funcs: list=[eval_length]):
|
|
39
39
|
if 'trace_id' not in data:
|
|
40
40
|
raise ValueError('No trace_id found in data')
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
trace_id = data.pop('trace_id', None)
|
|
42
|
+
|
|
43
|
+
return do_evals(trace_id, eval_funcs, **data)
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
def do_evals(trace_id, eval_funcs: list=[eval_length], **kwargs) -> dict:
|
|
@@ -51,7 +52,7 @@ def do_evals(trace_id, eval_funcs: list=[eval_length], **kwargs) -> dict:
|
|
|
51
52
|
)
|
|
52
53
|
|
|
53
54
|
# Fetch the latest trace (or modify as needed to fetch a specific trace)
|
|
54
|
-
trace = langfuse.
|
|
55
|
+
trace = langfuse.get_trace(id=trace_id)
|
|
55
56
|
|
|
56
57
|
if trace.output is None:
|
|
57
58
|
raise ValueError("Trace {trace.name} had no generated output, it was skipped")
|
|
@@ -64,7 +65,7 @@ def do_evals(trace_id, eval_funcs: list=[eval_length], **kwargs) -> dict:
|
|
|
64
65
|
|
|
65
66
|
eval_name = eval_func.__name__
|
|
66
67
|
|
|
67
|
-
if 'score'
|
|
68
|
+
if 'score' and 'reason' not in eval_result:
|
|
68
69
|
raise ValueError(f"Trace {trace.name} using {eval_name=} did not return a dict with 'score' and 'reason': {eval_result=}")
|
|
69
70
|
|
|
70
71
|
log.info(f"TraceId {trace.id} with name {trace.name} had {eval_name=} with score {eval_result=}")
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sunholo
|
|
3
|
-
Version: 0.89.
|
|
3
|
+
Version: 0.89.4
|
|
4
4
|
Summary: Large Language Model DevOps - a package to help deploy LLMs to the Cloud.
|
|
5
5
|
Home-page: https://github.com/sunholo-data/sunholo-py
|
|
6
|
-
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.89.
|
|
6
|
+
Download-URL: https://github.com/sunholo-data/sunholo-py/archive/refs/tags/v0.89.4.tar.gz
|
|
7
7
|
Author: Holosun ApS
|
|
8
8
|
Author-email: multivac@sunholo.com
|
|
9
9
|
License: Apache License, Version 2.0
|
|
@@ -14,7 +14,7 @@ sunholo/agents/fastapi/qna_routes.py,sha256=lKHkXPmwltu9EH3RMwmD153-J6pE7kWQ4BhB
|
|
|
14
14
|
sunholo/agents/flask/__init__.py,sha256=poJDKMr2qj8qMb99JqCvCPSiEt1tj2tLQ3hKW3f2aVw,107
|
|
15
15
|
sunholo/agents/flask/base.py,sha256=FgSaCODyoTtlstJtsqlLPScdgRUtv9_plxftdzHdVFo,809
|
|
16
16
|
sunholo/agents/flask/qna_routes.py,sha256=uwUD1yrzOPH27m2AXpiQrPk_2VfJOQOM6dAynOWQtoQ,22532
|
|
17
|
-
sunholo/agents/flask/vac_routes.py,sha256=
|
|
17
|
+
sunholo/agents/flask/vac_routes.py,sha256=U5JH1mj-3i2BbIVirnyUs_0s5oZ0tX1IWGkV_g7WW5k,22538
|
|
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
|
|
@@ -94,7 +94,7 @@ sunholo/invoke/direct_vac_func.py,sha256=fuTJlH5PsqWhN_yVMaWisHCTZU1JEUz8I8yVbWs
|
|
|
94
94
|
sunholo/invoke/invoke_vac_utils.py,sha256=sJc1edHTHMzMGXjji1N67c3iUaP7BmAL5nj82Qof63M,2053
|
|
95
95
|
sunholo/langfuse/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
96
96
|
sunholo/langfuse/callback.py,sha256=jl0SZsFS53uMW9DGeM9SOL_EsRZsba0wwFGLqKzu9_U,1684
|
|
97
|
-
sunholo/langfuse/evals.py,sha256=
|
|
97
|
+
sunholo/langfuse/evals.py,sha256=aGrU2DOR2hmI0ST613gBIT0v6IhEF1MIK1aOpuD2yR0,2909
|
|
98
98
|
sunholo/langfuse/prompts.py,sha256=27BsVfihM6-h1jscbkGSO4HsATl-d4ZN6tcNCVztWoY,1300
|
|
99
99
|
sunholo/llamaindex/__init__.py,sha256=DlY_cHWCsVEV1C5WBgDdHRgOMlJc8pDoCRukUJ8PT9w,88
|
|
100
100
|
sunholo/llamaindex/get_files.py,sha256=6rhXCDqQ_lrIapISQ_OYQDjiSATXvS_9m3qq53-oIl0,781
|
|
@@ -144,9 +144,9 @@ sunholo/vertex/init.py,sha256=1OQwcPBKZYBTDPdyU7IM4X4OmiXLdsNV30C-fee2scQ,2875
|
|
|
144
144
|
sunholo/vertex/memory_tools.py,sha256=q_phxgGX2TG2j2MXNULF2xGzQnQPENwjPN9nZ_A9Gh0,7526
|
|
145
145
|
sunholo/vertex/safety.py,sha256=S9PgQT1O_BQAkcqauWncRJaydiP8Q_Jzmu9gxYfy1VA,2482
|
|
146
146
|
sunholo/vertex/type_dict_to_json.py,sha256=uTzL4o9tJRao4u-gJOFcACgWGkBOtqACmb6ihvCErL8,4694
|
|
147
|
-
sunholo-0.89.
|
|
148
|
-
sunholo-0.89.
|
|
149
|
-
sunholo-0.89.
|
|
150
|
-
sunholo-0.89.
|
|
151
|
-
sunholo-0.89.
|
|
152
|
-
sunholo-0.89.
|
|
147
|
+
sunholo-0.89.4.dist-info/LICENSE.txt,sha256=SdE3QjnD3GEmqqg9EX3TM9f7WmtOzqS1KJve8rhbYmU,11345
|
|
148
|
+
sunholo-0.89.4.dist-info/METADATA,sha256=vp8lN-BGsMZzN8sUmHdoQuctkysZB_Iv52vLacNaAZg,7706
|
|
149
|
+
sunholo-0.89.4.dist-info/WHEEL,sha256=UvcQYKBHoFqaQd6LKyqHw9fxEolWLQnlzP0h_LgJAfI,91
|
|
150
|
+
sunholo-0.89.4.dist-info/entry_points.txt,sha256=bZuN5AIHingMPt4Ro1b_T-FnQvZ3teBes-3OyO0asl4,49
|
|
151
|
+
sunholo-0.89.4.dist-info/top_level.txt,sha256=wt5tadn5--5JrZsjJz2LceoUvcrIvxjHJe-RxuudxAk,8
|
|
152
|
+
sunholo-0.89.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|