olca 0.2.59__tar.gz → 0.2.60__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {olca-0.2.59 → olca-0.2.60}/PKG-INFO +1 -1
- {olca-0.2.59 → olca-0.2.60}/olca/fusewill_cli.py +23 -1
- {olca-0.2.59 → olca-0.2.60}/olca/fusewill_utils.py +101 -5
- {olca-0.2.59 → olca-0.2.60}/olca/prompts.py +5 -0
- {olca-0.2.59 → olca-0.2.60}/olca.egg-info/PKG-INFO +1 -1
- {olca-0.2.59 → olca-0.2.60}/pyproject.toml +1 -1
- {olca-0.2.59 → olca-0.2.60}/setup.py +1 -1
- {olca-0.2.59 → olca-0.2.60}/LICENSE +0 -0
- {olca-0.2.59 → olca-0.2.60}/README.md +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca/__init__.py +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca/olcacli.py +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca/olcahelper.py +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca/tracing.py +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca/utils.py +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca.egg-info/SOURCES.txt +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca.egg-info/dependency_links.txt +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca.egg-info/entry_points.txt +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca.egg-info/requires.txt +0 -0
- {olca-0.2.59 → olca-0.2.60}/olca.egg-info/top_level.txt +0 -0
- {olca-0.2.59 → olca-0.2.60}/setup.cfg +0 -0
@@ -14,7 +14,9 @@ from fusewill_utils import (
|
|
14
14
|
open_trace_in_browser,
|
15
15
|
print_traces,
|
16
16
|
print_trace,
|
17
|
-
list_traces_by_score # Ensure the updated function is imported
|
17
|
+
list_traces_by_score, # Ensure the updated function is imported
|
18
|
+
export_traces,
|
19
|
+
import_traces
|
18
20
|
)
|
19
21
|
import dotenv
|
20
22
|
import json
|
@@ -106,6 +108,18 @@ def main():
|
|
106
108
|
parser_search.add_argument('-L', '--limit', type=int, default=100, help='Number of traces to fetch')
|
107
109
|
parser_search.add_argument('-o', '--output', type=str, help='Output JSON file path')
|
108
110
|
|
111
|
+
# export_traces command
|
112
|
+
parser_export = subparsers.add_parser('export_traces', help='Export traces', aliases=['et'])
|
113
|
+
parser_export.add_argument('--format', choices=['json','csv'], default='json', help='Export format')
|
114
|
+
parser_export.add_argument('-o','--output', type=str, help='Output file path')
|
115
|
+
parser_export.add_argument('--start_date', type=str, help='Start date in ISO format (e.g., 2024-01-01)')
|
116
|
+
parser_export.add_argument('--end_date', type=str, help='End date in ISO format (e.g., 2024-12-31)')
|
117
|
+
|
118
|
+
# import_traces command
|
119
|
+
parser_import = subparsers.add_parser('import_traces', help='Import traces', aliases=['it'])
|
120
|
+
parser_import.add_argument('--format', choices=['json','csv'], default='json', help='Import format')
|
121
|
+
parser_import.add_argument('--input', type=str, required=True, help='Input file path to read from')
|
122
|
+
|
109
123
|
args = parser.parse_args()
|
110
124
|
|
111
125
|
if args.command == 'list_traces' or args.command == 'lt':
|
@@ -219,6 +233,14 @@ def main():
|
|
219
233
|
fu.print_trace(trace)
|
220
234
|
else:
|
221
235
|
print("No traces found matching the criteria.")
|
236
|
+
elif args.command == 'export_traces' or args.command == 'et':
|
237
|
+
output_path = args.output
|
238
|
+
if output_path:
|
239
|
+
if not output_path.endswith(f".{args.format}"):
|
240
|
+
output_path += f".{args.format}"
|
241
|
+
fu.export_traces(format=args.format, output_path=output_path, start_date=args.start_date, end_date=args.end_date)
|
242
|
+
elif args.command == 'import_traces' or args.command == 'it':
|
243
|
+
fu.import_traces(format=args.format, input_path=args.input)
|
222
244
|
else:
|
223
245
|
parser.print_help()
|
224
246
|
exit(1)
|
@@ -8,11 +8,11 @@ import datetime # Add this import
|
|
8
8
|
import pytz # Add this import
|
9
9
|
|
10
10
|
# Load .env from the current working directory
|
11
|
-
dotenv.load_dotenv(dotenv_path=os.path.join(os.getcwd(), ".env"))
|
11
|
+
dotenv.load_dotenv(dotenv_path=os.path.join(os.getcwd(), ".env"), override=True)
|
12
12
|
|
13
13
|
# Try loading from home directory if variables are still not set
|
14
14
|
if not os.environ.get("LANGFUSE_PUBLIC_KEY") or not os.environ.get("LANGFUSE_SECRET_KEY") or not os.environ.get("LANGFUSE_HOST"):
|
15
|
-
dotenv.load_dotenv(dotenv_path=os.path.expanduser("~/.env"))
|
15
|
+
dotenv.load_dotenv(dotenv_path=os.path.expanduser("~/.env"), override=True)
|
16
16
|
|
17
17
|
# Final check before exiting
|
18
18
|
missing_vars = []
|
@@ -33,7 +33,6 @@ import sys
|
|
33
33
|
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
34
34
|
import json
|
35
35
|
|
36
|
-
import dotenv
|
37
36
|
_DEBUG_=False
|
38
37
|
if _DEBUG_:
|
39
38
|
print(os.environ.get("LANGFUSE_PUBLIC_KEY"))
|
@@ -43,7 +42,8 @@ if _DEBUG_:
|
|
43
42
|
langfuse = Langfuse(
|
44
43
|
public_key=os.environ.get("LANGFUSE_PUBLIC_KEY"),
|
45
44
|
secret_key=os.environ.get("LANGFUSE_SECRET_KEY"),
|
46
|
-
host=os.environ.get("LANGFUSE_HOST")
|
45
|
+
host=os.environ.get("LANGFUSE_HOST"),
|
46
|
+
release=os.environ.get("LANGFUSE_RELEASE", None)
|
47
47
|
)
|
48
48
|
|
49
49
|
def open_trace_in_browser(trace_id):
|
@@ -241,4 +241,100 @@ def search_traces(
|
|
241
241
|
return filtered_traces
|
242
242
|
except Exception as e:
|
243
243
|
print(f"Error searching traces: {e}")
|
244
|
-
return []
|
244
|
+
return []
|
245
|
+
|
246
|
+
def fetch_all_traces(start_date=None, end_date=None):
|
247
|
+
all_traces = []
|
248
|
+
page = 1
|
249
|
+
chunk_size = 100
|
250
|
+
params = {}
|
251
|
+
if start_date:
|
252
|
+
params['from_timestamp'] = datetime.datetime.fromisoformat(start_date).replace(tzinfo=pytz.UTC)
|
253
|
+
if end_date:
|
254
|
+
params['to_timestamp'] = datetime.datetime.fromisoformat(end_date).replace(tzinfo=pytz.UTC)
|
255
|
+
|
256
|
+
while True:
|
257
|
+
partial = langfuse.get_traces(limit=chunk_size, page=page, **params)
|
258
|
+
if not partial or not partial.data:
|
259
|
+
break
|
260
|
+
all_traces.extend(partial.data)
|
261
|
+
if len(partial.data) < chunk_size:
|
262
|
+
break
|
263
|
+
page += 1
|
264
|
+
return all_traces
|
265
|
+
|
266
|
+
def export_traces(format='json', output_path=None, start_date=None, end_date=None):
|
267
|
+
"""
|
268
|
+
Export traces to a given format (json or csv).
|
269
|
+
"""
|
270
|
+
try:
|
271
|
+
all_traces = fetch_all_traces(start_date=start_date, end_date=end_date)
|
272
|
+
if not output_path:
|
273
|
+
output_path = f"./traces_export.{format}"
|
274
|
+
|
275
|
+
# Ensure the output directory exists
|
276
|
+
output_dir = os.path.dirname(output_path)
|
277
|
+
if output_dir and not os.path.exists(output_dir):
|
278
|
+
os.makedirs(output_dir)
|
279
|
+
|
280
|
+
if format == 'json':
|
281
|
+
with open(output_path, 'w') as f:
|
282
|
+
json.dump([t.__dict__ for t in all_traces], f, indent=2, default=str)
|
283
|
+
elif format == 'csv':
|
284
|
+
import csv
|
285
|
+
fieldnames = ['id', 'name', 'input', 'output', 'createdAt']
|
286
|
+
with open(output_path, 'w', newline='') as f:
|
287
|
+
writer = csv.DictWriter(f, fieldnames=fieldnames)
|
288
|
+
writer.writeheader()
|
289
|
+
for t in all_traces:
|
290
|
+
writer.writerow({
|
291
|
+
'id': t.id,
|
292
|
+
'name': t.name,
|
293
|
+
'input': t.input,
|
294
|
+
'output': t.output,
|
295
|
+
'createdAt': str(t.createdAt)
|
296
|
+
})
|
297
|
+
|
298
|
+
if all_traces:
|
299
|
+
# Sort traces by createdAt to ensure the oldest date is first
|
300
|
+
all_traces.sort(key=lambda x: x.createdAt)
|
301
|
+
first_trace_date = datetime.datetime.fromisoformat(all_traces[0].createdAt.replace('Z', '+00:00')).strftime('%Y-%m-%d %H:%M:%S')
|
302
|
+
last_trace_date = datetime.datetime.fromisoformat(all_traces[-1].createdAt.replace('Z', '+00:00')).strftime('%Y-%m-%d %H:%M:%S')
|
303
|
+
print(f"Traces exported to {output_path}. Total traces exported: {len(all_traces)}")
|
304
|
+
print(f"Date range: {first_trace_date} to {last_trace_date}")
|
305
|
+
else:
|
306
|
+
print(f"Traces exported to {output_path}. Total traces exported: {len(all_traces)}")
|
307
|
+
except Exception as e:
|
308
|
+
print(f"Error exporting traces: {e}")
|
309
|
+
|
310
|
+
def import_traces(format='json', input_path=None):
|
311
|
+
"""
|
312
|
+
Import traces from a given file (json or csv) into Langfuse.
|
313
|
+
"""
|
314
|
+
if not input_path:
|
315
|
+
print("No input file provided for importing traces.")
|
316
|
+
return
|
317
|
+
|
318
|
+
try:
|
319
|
+
if format == 'json':
|
320
|
+
with open(input_path, 'r') as f:
|
321
|
+
data = json.load(f)
|
322
|
+
elif format == 'csv':
|
323
|
+
import csv
|
324
|
+
data = []
|
325
|
+
with open(input_path, 'r', newline='') as f:
|
326
|
+
reader = csv.DictReader(f)
|
327
|
+
for row in reader:
|
328
|
+
data.append(row)
|
329
|
+
|
330
|
+
# Create new traces in Langfuse from data
|
331
|
+
for item in data:
|
332
|
+
langfuse.create_trace(
|
333
|
+
name=item.get('name', 'Imported Trace'),
|
334
|
+
input=item.get('input', ''),
|
335
|
+
output=item.get('output', '')
|
336
|
+
# pass other fields as needed
|
337
|
+
)
|
338
|
+
print(f"Imported {len(data)} traces from {input_path}")
|
339
|
+
except Exception as e:
|
340
|
+
print(f"Error importing traces: {e}")
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# Create a new file "prompts.py" to store the prompt-related constants.
|
2
2
|
|
3
|
+
|
4
|
+
#@STCGoal https://smith.langchain.com/hub/jgwill/olca_system_append
|
5
|
+
SYSTEM_PROMPT_APPEND_hub_tag_name="jgwill/olca_system_append"
|
3
6
|
SYSTEM_PROMPT_APPEND = """
|
4
7
|
You do what is above and consider the following when doing the task:
|
5
8
|
---
|
@@ -22,6 +25,8 @@ You do what is above and consider the following when doing the task:
|
|
22
25
|
REMEMBER: Dont introduce nor conclude, just output results. No comments. you present in a coherent format without preambles or fluff. Never use the word "determination" and we never brainstorm (we conceptualize the result we want in the germination phase then transform it into vision by choice and work as assimilating the vision to until the last phase which is completing our work).
|
23
26
|
"""
|
24
27
|
|
28
|
+
#@STCGoal https://smith.langchain.com/hub/jgwill/olca_human_append
|
29
|
+
HUMAN_APPEND_PROMPT_hub_tag_name="jgwill/olca_human_append"
|
25
30
|
HUMAN_APPEND_PROMPT = """
|
26
31
|
* Utilize the 'human' tool for interactions as directed.
|
27
32
|
* Communicate clearly and simply, avoiding exaggeration.
|
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|
2
2
|
|
3
3
|
setup(
|
4
4
|
name='olca',
|
5
|
-
version = "0.2.
|
5
|
+
version = "0.2.60",
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|