tracia 0.0.1__py3-none-any.whl → 0.1.0__py3-none-any.whl
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.
- tracia/__init__.py +150 -3
- tracia/_client.py +1100 -0
- tracia/_constants.py +39 -0
- tracia/_errors.py +87 -0
- tracia/_http.py +362 -0
- tracia/_llm.py +898 -0
- tracia/_session.py +244 -0
- tracia/_streaming.py +135 -0
- tracia/_types.py +540 -0
- tracia/_utils.py +116 -0
- tracia/py.typed +0 -0
- tracia/resources/__init__.py +6 -0
- tracia/resources/prompts.py +273 -0
- tracia/resources/spans.py +227 -0
- tracia-0.1.0.dist-info/METADATA +277 -0
- tracia-0.1.0.dist-info/RECORD +18 -0
- tracia-0.0.1.dist-info/METADATA +0 -52
- tracia-0.0.1.dist-info/RECORD +0 -5
- {tracia-0.0.1.dist-info → tracia-0.1.0.dist-info}/WHEEL +0 -0
- {tracia-0.0.1.dist-info → tracia-0.1.0.dist-info}/licenses/LICENSE +0 -0
tracia/__init__.py
CHANGED
|
@@ -1,8 +1,155 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Tracia - LLM prompt management and tracing SDK
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
A Python SDK for managing LLM prompts and tracing LLM interactions.
|
|
5
|
+
Uses LiteLLM as the unified provider abstraction layer.
|
|
6
|
+
|
|
7
|
+
Example usage:
|
|
8
|
+
```python
|
|
9
|
+
from tracia import Tracia
|
|
10
|
+
|
|
11
|
+
client = Tracia(api_key="your_api_key")
|
|
12
|
+
|
|
13
|
+
# Run a local prompt
|
|
14
|
+
result = client.run_local(
|
|
15
|
+
model="gpt-4o",
|
|
16
|
+
messages=[{"role": "user", "content": "Hello!"}]
|
|
17
|
+
)
|
|
18
|
+
print(result.text)
|
|
19
|
+
|
|
20
|
+
# Run with streaming
|
|
21
|
+
stream = client.run_local(
|
|
22
|
+
model="gpt-4o",
|
|
23
|
+
messages=[{"role": "user", "content": "Tell me a story"}],
|
|
24
|
+
stream=True
|
|
25
|
+
)
|
|
26
|
+
for chunk in stream:
|
|
27
|
+
print(chunk, end="")
|
|
28
|
+
|
|
29
|
+
# Use prompts API
|
|
30
|
+
prompts = client.prompts.list()
|
|
31
|
+
prompt = client.prompts.get("my-prompt")
|
|
32
|
+
|
|
33
|
+
# Use spans API
|
|
34
|
+
spans = client.spans.list()
|
|
35
|
+
client.spans.evaluate("sp_xxx", EvaluateOptions(evaluator="quality", value=1))
|
|
36
|
+
|
|
37
|
+
# Create a session for multi-turn conversations
|
|
38
|
+
session = client.create_session()
|
|
39
|
+
r1 = session.run_local(model="gpt-4o", messages=[...])
|
|
40
|
+
r2 = session.run_local(model="gpt-4o", messages=[...]) # Linked
|
|
41
|
+
|
|
42
|
+
# Clean up
|
|
43
|
+
client.close()
|
|
44
|
+
```
|
|
5
45
|
"""
|
|
6
46
|
|
|
7
|
-
|
|
8
|
-
|
|
47
|
+
from ._client import Tracia
|
|
48
|
+
from ._constants import SDK_VERSION, Eval
|
|
49
|
+
from ._errors import TraciaError, TraciaErrorCode
|
|
50
|
+
from ._session import TraciaSession
|
|
51
|
+
from ._streaming import AsyncLocalStream, LocalStream
|
|
52
|
+
from ._types import (
|
|
53
|
+
ContentPart,
|
|
54
|
+
CreatePromptOptions,
|
|
55
|
+
CreateSpanPayload,
|
|
56
|
+
CreateSpanResult,
|
|
57
|
+
EvaluateOptions,
|
|
58
|
+
EvaluateResult,
|
|
59
|
+
FinishReason,
|
|
60
|
+
JsonSchemaProperty,
|
|
61
|
+
ListSpansOptions,
|
|
62
|
+
ListSpansResult,
|
|
63
|
+
LLMProvider,
|
|
64
|
+
LocalPromptMessage,
|
|
65
|
+
Prompt,
|
|
66
|
+
PromptListItem,
|
|
67
|
+
PromptMessage,
|
|
68
|
+
PromptVersion,
|
|
69
|
+
ResponsesEvent,
|
|
70
|
+
ResponsesFunctionCall,
|
|
71
|
+
ResponsesFunctionCallOutput,
|
|
72
|
+
ResponsesInputItem,
|
|
73
|
+
ResponsesInputMessage,
|
|
74
|
+
ResponsesMessage,
|
|
75
|
+
ResponsesOutputItem,
|
|
76
|
+
ResponsesToolCall,
|
|
77
|
+
RunLocalInput,
|
|
78
|
+
RunLocalResult,
|
|
79
|
+
RunOptions,
|
|
80
|
+
RunResponsesInput,
|
|
81
|
+
RunResponsesResult,
|
|
82
|
+
RunResult,
|
|
83
|
+
Span,
|
|
84
|
+
StreamResult,
|
|
85
|
+
TextPart,
|
|
86
|
+
TokenUsage,
|
|
87
|
+
ToolCall,
|
|
88
|
+
ToolCallPart,
|
|
89
|
+
ToolChoice,
|
|
90
|
+
ToolDefinition,
|
|
91
|
+
ToolParameters,
|
|
92
|
+
UpdatePromptOptions,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
__version__ = SDK_VERSION
|
|
96
|
+
__all__ = [
|
|
97
|
+
# Main client
|
|
98
|
+
"Tracia",
|
|
99
|
+
"TraciaSession",
|
|
100
|
+
# Errors
|
|
101
|
+
"TraciaError",
|
|
102
|
+
"TraciaErrorCode",
|
|
103
|
+
# Constants
|
|
104
|
+
"Eval",
|
|
105
|
+
# Streaming
|
|
106
|
+
"LocalStream",
|
|
107
|
+
"AsyncLocalStream",
|
|
108
|
+
# Types - Core
|
|
109
|
+
"LLMProvider",
|
|
110
|
+
"TokenUsage",
|
|
111
|
+
"FinishReason",
|
|
112
|
+
# Types - Messages
|
|
113
|
+
"LocalPromptMessage",
|
|
114
|
+
"ContentPart",
|
|
115
|
+
"TextPart",
|
|
116
|
+
"ToolCallPart",
|
|
117
|
+
# Types - Tools
|
|
118
|
+
"ToolDefinition",
|
|
119
|
+
"ToolParameters",
|
|
120
|
+
"JsonSchemaProperty",
|
|
121
|
+
"ToolCall",
|
|
122
|
+
"ToolChoice",
|
|
123
|
+
# Types - Run Local
|
|
124
|
+
"RunLocalInput",
|
|
125
|
+
"RunLocalResult",
|
|
126
|
+
"StreamResult",
|
|
127
|
+
# Types - Run Responses (OpenAI Responses API)
|
|
128
|
+
"RunResponsesInput",
|
|
129
|
+
"RunResponsesResult",
|
|
130
|
+
"ResponsesInputItem",
|
|
131
|
+
"ResponsesInputMessage",
|
|
132
|
+
"ResponsesFunctionCallOutput",
|
|
133
|
+
"ResponsesFunctionCall",
|
|
134
|
+
"ResponsesMessage",
|
|
135
|
+
"ResponsesOutputItem",
|
|
136
|
+
"ResponsesToolCall",
|
|
137
|
+
"ResponsesEvent",
|
|
138
|
+
# Types - Spans
|
|
139
|
+
"CreateSpanPayload",
|
|
140
|
+
"CreateSpanResult",
|
|
141
|
+
"Span",
|
|
142
|
+
"ListSpansOptions",
|
|
143
|
+
"ListSpansResult",
|
|
144
|
+
"EvaluateOptions",
|
|
145
|
+
"EvaluateResult",
|
|
146
|
+
# Types - Prompts
|
|
147
|
+
"Prompt",
|
|
148
|
+
"PromptListItem",
|
|
149
|
+
"PromptMessage",
|
|
150
|
+
"PromptVersion",
|
|
151
|
+
"CreatePromptOptions",
|
|
152
|
+
"UpdatePromptOptions",
|
|
153
|
+
"RunOptions",
|
|
154
|
+
"RunResult",
|
|
155
|
+
]
|