olca 0.2.21__tar.gz → 0.2.23__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: olca
3
- Version: 0.2.21
3
+ Version: 0.2.23
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
@@ -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
 
@@ -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.23
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
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "olca"
10
- version = "0.2.21"
10
+ version = "0.2.23"
11
11
 
12
12
  description = "A Python package for experimental usage of Langchain and Human-in-the-Loop"
13
13
  readme = "README.md"
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='olca',
5
- version = "0.2.21",
5
+ version = "0.2.23",
6
6
  author='Jean GUillaume ISabelle',
7
7
  author_email='jgi@jgwill.com',
8
8
  description='A Python package for experimenting with Langchain agent and interactivity in Terminal modalities.',
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes