olca 0.2.20__py3-none-any.whl → 0.2.22__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- olca/fusewill_cli.py +44 -0
- olca/fusewill_utils.py +46 -13
- {olca-0.2.20.dist-info → olca-0.2.22.dist-info}/METADATA +1 -1
- olca-0.2.22.dist-info/RECORD +10 -0
- olca-0.2.20.dist-info/RECORD +0 -10
- {olca-0.2.20.dist-info → olca-0.2.22.dist-info}/LICENSE +0 -0
- {olca-0.2.20.dist-info → olca-0.2.22.dist-info}/WHEEL +0 -0
- {olca-0.2.20.dist-info → olca-0.2.22.dist-info}/entry_points.txt +0 -0
- {olca-0.2.20.dist-info → olca-0.2.22.dist-info}/top_level.txt +0 -0
olca/fusewill_cli.py
CHANGED
@@ -52,6 +52,28 @@ def main():
|
|
52
52
|
parser_get_trace = subparsers.add_parser('get_trace_by_id', help='Get a trace by ID')
|
53
53
|
parser_get_trace.add_argument('trace_id', help='Trace ID')
|
54
54
|
|
55
|
+
# new_score command
|
56
|
+
parser_new_score = subparsers.add_parser('new_score', help='Create a new score')
|
57
|
+
parser_new_score.add_argument('name', help='Score name')
|
58
|
+
parser_new_score.add_argument('data_type', help='Data type of the score')
|
59
|
+
parser_new_score.add_argument('--description', default='', help='Description of the score')
|
60
|
+
|
61
|
+
# add_score_to_trace command
|
62
|
+
parser_add_score = subparsers.add_parser('add_score_to_trace', help='Add a score to a trace', aliases=['s2t'])
|
63
|
+
parser_add_score.add_argument('trace_id', help='Trace ID')
|
64
|
+
parser_add_score.add_argument('generation_id', help='Generation ID')
|
65
|
+
parser_add_score.add_argument('name', help='Score name')
|
66
|
+
parser_add_score.add_argument('value', help='Score value')
|
67
|
+
parser_add_score.add_argument('--data_type', default='NUMERIC', help='Data type of the score')
|
68
|
+
parser_add_score.add_argument('--comment', default='', help='Comment for the score')
|
69
|
+
|
70
|
+
# list_traces_by_score command
|
71
|
+
parser_list_by_score = subparsers.add_parser('list_traces_by_score', help='List traces by score')
|
72
|
+
parser_list_by_score.add_argument('score_name', help='Score name')
|
73
|
+
parser_list_by_score.add_argument('--min_value', type=float, help='Minimum score value')
|
74
|
+
parser_list_by_score.add_argument('--max_value', type=float, help='Maximum score value')
|
75
|
+
parser_list_by_score.add_argument('--limit', type=int, default=100, help='Number of traces to fetch')
|
76
|
+
|
55
77
|
args = parser.parse_args()
|
56
78
|
|
57
79
|
if args.command == 'list_traces':
|
@@ -75,6 +97,28 @@ def main():
|
|
75
97
|
elif args.command == 'get_trace_by_id':
|
76
98
|
trace = get_trace_by_id(trace_id=args.trace_id)
|
77
99
|
print(trace)
|
100
|
+
elif args.command == 'new_score':
|
101
|
+
fu.create_score(name=args.name, data_type=args.data_type, description=args.description)
|
102
|
+
elif args.command == 'add_score_to_trace':
|
103
|
+
if not fu.score_exists(name=args.name):
|
104
|
+
fu.create_score(name=args.name, data_type=args.data_type)
|
105
|
+
fu.add_score_to_a_trace(
|
106
|
+
trace_id=args.trace_id,
|
107
|
+
generation_id=args.generation_id,
|
108
|
+
name=args.name,
|
109
|
+
value=args.value,
|
110
|
+
data_type=args.data_type,
|
111
|
+
comment=args.comment
|
112
|
+
)
|
113
|
+
elif args.command == 'list_traces_by_score':
|
114
|
+
traces = fu.list_traces_by_score(
|
115
|
+
score_name=args.score_name,
|
116
|
+
min_value=args.min_value,
|
117
|
+
max_value=args.max_value,
|
118
|
+
limit=args.limit
|
119
|
+
)
|
120
|
+
for trace in traces:
|
121
|
+
print(f"Trace ID: {trace.id}, Name: {trace.name}")
|
78
122
|
else:
|
79
123
|
parser.print_help()
|
80
124
|
|
olca/fusewill_utils.py
CHANGED
@@ -1,26 +1,34 @@
|
|
1
|
-
from langfuse import Langfuse
|
2
1
|
import os
|
3
2
|
import sys
|
4
|
-
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
5
3
|
import json
|
6
|
-
|
7
4
|
import dotenv
|
8
5
|
|
9
|
-
#
|
6
|
+
# Load .env from the current working directory
|
7
|
+
dotenv.load_dotenv(dotenv_path=os.path.join(os.getcwd(), ".env"))
|
8
|
+
|
9
|
+
# Try loading from home directory if variables are still not set
|
10
10
|
if not os.environ.get("LANGFUSE_PUBLIC_KEY") or not os.environ.get("LANGFUSE_SECRET_KEY"):
|
11
|
-
|
12
|
-
dotenv.load_dotenv()
|
11
|
+
dotenv.load_dotenv(dotenv_path=os.path.expanduser("~/.env"))
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
# Final check before exiting
|
14
|
+
missing_vars = []
|
15
|
+
if not os.environ.get("LANGFUSE_PUBLIC_KEY"):
|
16
|
+
missing_vars.append("LANGFUSE_PUBLIC_KEY")
|
17
|
+
if not os.environ.get("LANGFUSE_SECRET_KEY"):
|
18
|
+
missing_vars.append("LANGFUSE_SECRET_KEY")
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
print("Error: LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY not found.")
|
20
|
+
if missing_vars:
|
21
|
+
print(f"Error: {', '.join(missing_vars)} not found.")
|
22
22
|
sys.exit(1)
|
23
23
|
|
24
|
+
from langfuse import Langfuse
|
25
|
+
import os
|
26
|
+
import sys
|
27
|
+
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
28
|
+
import json
|
29
|
+
|
30
|
+
import dotenv
|
31
|
+
|
24
32
|
langfuse = Langfuse()
|
25
33
|
|
26
34
|
def list_traces(limit=100, output_dir="../output/traces"):
|
@@ -33,6 +41,17 @@ def list_traces(limit=100, output_dir="../output/traces"):
|
|
33
41
|
print("---")
|
34
42
|
return traces
|
35
43
|
|
44
|
+
def list_traces_by_score(score_name, min_value=None, max_value=None, limit=100):
|
45
|
+
traces = langfuse.get_traces(limit=limit)
|
46
|
+
filtered_traces = []
|
47
|
+
for trace in traces.data:
|
48
|
+
for score in trace.scores:
|
49
|
+
if score.name == score_name:
|
50
|
+
if (min_value is None or score.value >= min_value) and (max_value is None or score.value <= max_value):
|
51
|
+
filtered_traces.append(trace)
|
52
|
+
break
|
53
|
+
return filtered_traces
|
54
|
+
|
36
55
|
def add_score_to_a_trace(trace_id, generation_id, name, value, data_type="NUMERIC", comment=""):
|
37
56
|
langfuse.score(
|
38
57
|
trace_id=trace_id,
|
@@ -43,6 +62,20 @@ def add_score_to_a_trace(trace_id, generation_id, name, value, data_type="NUMERI
|
|
43
62
|
comment=comment
|
44
63
|
)
|
45
64
|
|
65
|
+
def create_score(name, data_type, description=""):
|
66
|
+
langfuse.create_score(
|
67
|
+
name=name,
|
68
|
+
data_type=data_type,
|
69
|
+
description=description
|
70
|
+
)
|
71
|
+
|
72
|
+
def score_exists(name):
|
73
|
+
scores = langfuse.get_scores()
|
74
|
+
for score in scores.data:
|
75
|
+
if score.name == name:
|
76
|
+
return True
|
77
|
+
return False
|
78
|
+
|
46
79
|
def create_dataset(name, description="", metadata=None):
|
47
80
|
langfuse.create_dataset(
|
48
81
|
name=name,
|
@@ -0,0 +1,10 @@
|
|
1
|
+
olca/__init__.py,sha256=3QyLLAys_KiiDIe-cfO_7QyY7di_qCaCS-sVziW2BOw,23
|
2
|
+
olca/fusewill_cli.py,sha256=ZFW2Oeq-gQpAaTIxzsztQWDMv7-R9WJTVcSspbTxpPk,5926
|
3
|
+
olca/fusewill_utils.py,sha256=TyyCVRkWeXaS14vh0BXGK-tj0ZPZ3_uQNnAOM-IE9FA,3405
|
4
|
+
olca/olcacli.py,sha256=B3uZcl_873zBy4vmXmcyN6Z8ofQA-anzX2aLuvUTSpk,12281
|
5
|
+
olca-0.2.22.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
6
|
+
olca-0.2.22.dist-info/METADATA,sha256=1VrwuDzlx0q2JJpnWWyBVsnmTJr80hJPops4F5m7ZqE,25311
|
7
|
+
olca-0.2.22.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
8
|
+
olca-0.2.22.dist-info/entry_points.txt,sha256=njL8YpuSEjiYR2mXIholt03mVAfN8ai12UyH-_uUDho,78
|
9
|
+
olca-0.2.22.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
|
10
|
+
olca-0.2.22.dist-info/RECORD,,
|
olca-0.2.20.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
olca/__init__.py,sha256=3QyLLAys_KiiDIe-cfO_7QyY7di_qCaCS-sVziW2BOw,23
|
2
|
-
olca/fusewill_cli.py,sha256=TGItRWPGTzhzX587zuep-HKO-L3plifY4jYxHd5gvdo,3592
|
3
|
-
olca/fusewill_utils.py,sha256=13c8kFDp5OK8-S1K9vLVX1HD3ip2uCvmW8LytDHva3k,2528
|
4
|
-
olca/olcacli.py,sha256=B3uZcl_873zBy4vmXmcyN6Z8ofQA-anzX2aLuvUTSpk,12281
|
5
|
-
olca-0.2.20.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
|
6
|
-
olca-0.2.20.dist-info/METADATA,sha256=irk6iWGcDxUjoxi_eN9ViLzDKQU29i2yCxtFnyiZEDQ,25311
|
7
|
-
olca-0.2.20.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
8
|
-
olca-0.2.20.dist-info/entry_points.txt,sha256=njL8YpuSEjiYR2mXIholt03mVAfN8ai12UyH-_uUDho,78
|
9
|
-
olca-0.2.20.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
|
10
|
-
olca-0.2.20.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|