olca 0.2.21__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 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
@@ -41,6 +41,17 @@ def list_traces(limit=100, output_dir="../output/traces"):
41
41
  print("---")
42
42
  return traces
43
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
+
44
55
  def add_score_to_a_trace(trace_id, generation_id, name, value, data_type="NUMERIC", comment=""):
45
56
  langfuse.score(
46
57
  trace_id=trace_id,
@@ -51,6 +62,20 @@ def add_score_to_a_trace(trace_id, generation_id, name, value, data_type="NUMERI
51
62
  comment=comment
52
63
  )
53
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
+
54
79
  def create_dataset(name, description="", metadata=None):
55
80
  langfuse.create_dataset(
56
81
  name=name,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: olca
3
- Version: 0.2.21
3
+ Version: 0.2.22
4
4
  Summary: A Python package for experimental usage of Langchain and Human-in-the-Loop
5
5
  Home-page: https://github.com/jgwill/olca
6
6
  Author: Jean GUillaume ISabelle
@@ -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,,
@@ -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=XMqL4C4S2vUfPqyGqzl7-Se84-0p2TXFqSB9V23idt0,2596
4
- olca/olcacli.py,sha256=B3uZcl_873zBy4vmXmcyN6Z8ofQA-anzX2aLuvUTSpk,12281
5
- olca-0.2.21.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
6
- olca-0.2.21.dist-info/METADATA,sha256=IxWbbuiPj85J629ck-UWqBhawS6PZ_yMvFsyrL3xDew,25311
7
- olca-0.2.21.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
8
- olca-0.2.21.dist-info/entry_points.txt,sha256=njL8YpuSEjiYR2mXIholt03mVAfN8ai12UyH-_uUDho,78
9
- olca-0.2.21.dist-info/top_level.txt,sha256=bGDtAReS-xlS0F6MM-DyD0IQUqjNdWmgemnM3vNtrpI,5
10
- olca-0.2.21.dist-info/RECORD,,
File without changes
File without changes