tracellm 0.1.0__tar.gz

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.
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: tracellm
3
+ Version: 0.1.0
4
+ Summary: Local-first observability for LLM applications
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+
8
+ # tracellm
9
+
10
+ Lightweight tracing for LLM applications. One import, three calls —
11
+ every API interaction logged locally, queryable from your terminal.
12
+
13
+ No backend. No signup. Nothing leaves your machine.
14
+
15
+ ## Install
16
+
17
+ pip install tracellm
18
+
19
+ ## Usage
20
+
21
+ from tracellm import Tracer
22
+
23
+ tracer = Tracer()
24
+ tracer.start_trace(model="llama-3.1-8b-instant", prompt="your prompt")
25
+
26
+ try:
27
+ response = client.chat.completions.create(...)
28
+ tracer.end_trace(response)
29
+ except Exception as e:
30
+ tracer.record_error(type(e).__name__, str(e))
31
+
32
+ ## Query traces from terminal
33
+
34
+ python -m tracellm.cli --Status failed
35
+ python -m tracellm.cli --Latency 2.0
36
+ python -m tracellm.cli --Model llama-3.1-8b-instant
37
+ python -m tracellm.cli --Status failed --Latency 1.5
38
+
39
+ ## What gets captured
40
+
41
+ - Model, prompt, response
42
+ - Tokens used, latency, finish reason
43
+ - Error type and message on failures
44
+ - Timestamp for every call
45
+
46
+ ## Limitations
47
+
48
+ Storage is append-only JSON lines. Query supports >=
49
+ for latency, exact match for everything else. Early days.
50
+
51
+ ## Roadmap
52
+
53
+ - Binary storage for faster querying at scale
54
+ - Cost calculation per model
55
+ - Terminal dashboard
@@ -0,0 +1,48 @@
1
+ # tracellm
2
+
3
+ Lightweight tracing for LLM applications. One import, three calls —
4
+ every API interaction logged locally, queryable from your terminal.
5
+
6
+ No backend. No signup. Nothing leaves your machine.
7
+
8
+ ## Install
9
+
10
+ pip install tracellm
11
+
12
+ ## Usage
13
+
14
+ from tracellm import Tracer
15
+
16
+ tracer = Tracer()
17
+ tracer.start_trace(model="llama-3.1-8b-instant", prompt="your prompt")
18
+
19
+ try:
20
+ response = client.chat.completions.create(...)
21
+ tracer.end_trace(response)
22
+ except Exception as e:
23
+ tracer.record_error(type(e).__name__, str(e))
24
+
25
+ ## Query traces from terminal
26
+
27
+ python -m tracellm.cli --Status failed
28
+ python -m tracellm.cli --Latency 2.0
29
+ python -m tracellm.cli --Model llama-3.1-8b-instant
30
+ python -m tracellm.cli --Status failed --Latency 1.5
31
+
32
+ ## What gets captured
33
+
34
+ - Model, prompt, response
35
+ - Tokens used, latency, finish reason
36
+ - Error type and message on failures
37
+ - Timestamp for every call
38
+
39
+ ## Limitations
40
+
41
+ Storage is append-only JSON lines. Query supports >=
42
+ for latency, exact match for everything else. Early days.
43
+
44
+ ## Roadmap
45
+
46
+ - Binary storage for faster querying at scale
47
+ - Cost calculation per model
48
+ - Terminal dashboard
@@ -0,0 +1,10 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "tracellm"
7
+ version = "0.1.0"
8
+ description = "Local-first observability for LLM applications"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .tracer import Tracer
@@ -0,0 +1,33 @@
1
+ import argparse
2
+ import json
3
+ import os
4
+ TRACE_FILE = os.path.join(os.path.dirname(__file__), '..', 'trace.txt')
5
+
6
+ parser = argparse.ArgumentParser()
7
+ parser.add_argument("-S" , "--Status" , help = "Based on what status do filter" , choices = ["success" , "failed"])
8
+ parser.add_argument("-L" , "--Latency" , help = "Based on what latency do filter")
9
+ parser.add_argument("-M" , "--Model" , help = "Based on what model do filter")
10
+ parser.add_argument("-E" , "--Error" , help = "Based on what type of Error do filter")
11
+ parser.add_argument("-T" , "--Time" , help = "Based on what time do filter")
12
+ args = parser.parse_args()
13
+
14
+
15
+ conditions = []
16
+ if args.Status:
17
+ conditions.append(lambda t : t.get('Status') == args.Status)
18
+ if args.Latency:
19
+ conditions.append(lambda t : t.get('Latency') >= float(args.Latency))
20
+ if args.Model:
21
+ conditions.append(lambda t : t.get('Model') == args.Model)
22
+ if args.Error:
23
+ conditions.append(lambda t : t.get('Error Type' , None) == args.Error)
24
+ if args.Time:
25
+ conditions.append(lambda t : t.get('Start Time') >= float(args.Time))
26
+ with open(TRACE_FILE , 'r') as trace_file:
27
+ for line in trace_file:
28
+ trace = json.loads(line)
29
+ if all(condition(trace) for condition in conditions):
30
+ print("\n--- Trace ---")
31
+ for key, value in trace.items():
32
+ print(f" {key}: {value}")
33
+ print("-------------")
@@ -0,0 +1,39 @@
1
+ import json
2
+ import time
3
+ from datetime import datetime
4
+ import os
5
+ TRACE_FILE = os.path.join(os.path.dirname(__file__), '..', 'trace.txt')
6
+
7
+ class Tracer:
8
+ def __init__(self):
9
+ pass
10
+
11
+
12
+ def start_trace(self , model , prompt ):
13
+ self.start_time = time.time()
14
+ self.prompt = prompt
15
+ self.model = model
16
+ self.timestamp = datetime.fromtimestamp(self.start_time).strftime('%Y-%m-%d %H:%M:%S')
17
+
18
+ def end_trace(self, response):
19
+ self.end_time = time.time()
20
+ self.tokens_used = response.usage.total_tokens
21
+ self.finish_reason = response.choices[0].finish_reason
22
+ self.status = "success"
23
+ self.latency = self.end_time - self.start_time
24
+ self.data = {"Model" : self.model , "Prompt" : self.prompt , "Response" : response.choices[0].message.content , "Tokens used" : self.tokens_used , "Finish reason" : self.finish_reason , "Latency" : round(self.latency , 3) , "Status" : self.status , "Timestamp" : self.timestamp }
25
+ with open(TRACE_FILE , 'a') as trace_file:
26
+ json.dump(self.data , trace_file)
27
+ trace_file.write('\n')
28
+
29
+
30
+ def record_error(self, error_type , error_message):
31
+ self.end_time = time.time()
32
+ self.error_type = error_type
33
+ self.error_message = error_message
34
+ self.status = "failed"
35
+ self.latency = self.end_time - self.start_time
36
+ self.data = {"Model" : self.model , "Prompt" : self.prompt , "Latency" : round(self.latency , 3) , "Status" : self.status , "Error Type" : self.error_type , "Error Message" : self.error_message , "Timestamp" : self.timestamp }
37
+ with open(TRACE_FILE , 'a') as trace_file:
38
+ json.dump(self.data , trace_file)
39
+ trace_file.write('\n')
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: tracellm
3
+ Version: 0.1.0
4
+ Summary: Local-first observability for LLM applications
5
+ Requires-Python: >=3.9
6
+ Description-Content-Type: text/markdown
7
+
8
+ # tracellm
9
+
10
+ Lightweight tracing for LLM applications. One import, three calls —
11
+ every API interaction logged locally, queryable from your terminal.
12
+
13
+ No backend. No signup. Nothing leaves your machine.
14
+
15
+ ## Install
16
+
17
+ pip install tracellm
18
+
19
+ ## Usage
20
+
21
+ from tracellm import Tracer
22
+
23
+ tracer = Tracer()
24
+ tracer.start_trace(model="llama-3.1-8b-instant", prompt="your prompt")
25
+
26
+ try:
27
+ response = client.chat.completions.create(...)
28
+ tracer.end_trace(response)
29
+ except Exception as e:
30
+ tracer.record_error(type(e).__name__, str(e))
31
+
32
+ ## Query traces from terminal
33
+
34
+ python -m tracellm.cli --Status failed
35
+ python -m tracellm.cli --Latency 2.0
36
+ python -m tracellm.cli --Model llama-3.1-8b-instant
37
+ python -m tracellm.cli --Status failed --Latency 1.5
38
+
39
+ ## What gets captured
40
+
41
+ - Model, prompt, response
42
+ - Tokens used, latency, finish reason
43
+ - Error type and message on failures
44
+ - Timestamp for every call
45
+
46
+ ## Limitations
47
+
48
+ Storage is append-only JSON lines. Query supports >=
49
+ for latency, exact match for everything else. Early days.
50
+
51
+ ## Roadmap
52
+
53
+ - Binary storage for faster querying at scale
54
+ - Cost calculation per model
55
+ - Terminal dashboard
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ tracellm/__init__.py
4
+ tracellm/cli.py
5
+ tracellm/tracer.py
6
+ tracellm.egg-info/PKG-INFO
7
+ tracellm.egg-info/SOURCES.txt
8
+ tracellm.egg-info/dependency_links.txt
9
+ tracellm.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ tracellm