Skip to content

Commit 5d3cf19

Browse files
committed
comments
1 parent 95f583d commit 5d3cf19

File tree

5 files changed

+17
-22
lines changed

5 files changed

+17
-22
lines changed

sample-app/recipe_agent_example.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var associationProperties = map[string]string{
1515
}
1616

1717
var abTest = &model.ABTest{
18-
VarientsKeys: map[string]bool{
18+
VarientKeys: map[string]bool{
1919
"variant_a": false,
2020
"variant_b": true,
2121
},
@@ -167,9 +167,7 @@ func cookingTimeEstimatorTool(ctx context.Context, agent *sdk.Agent, client *ope
167167
},
168168
},
169169
},
170-
}, map[string]string{
171-
"user_id": "user_67890",
172-
})
170+
}, associationProperties)
173171
defer tool.End()
174172

175173
prompt := sdk.Prompt{
@@ -238,9 +236,9 @@ func runRecipeAgent() {
238236

239237
// Create standalone agent with association properties
240238
agent := traceloop.NewAgent(ctx, "recipe_generator", sdk.AgentAttributes{
241-
Name: "recipe_generator",
239+
Name: "recipe_generator",
242240
AssociationProperties: associationProperties,
243-
ABTest: abTest,
241+
ABTest: abTest,
244242
})
245243
defer agent.End()
246244

traceloop-sdk/agent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func (agent *Agent) End() {
2424
func (agent *Agent) LogPrompt(prompt Prompt) LLMSpan {
2525
// Merge workflow and agent association properties
2626
contextAttrs := ContextAttributes{
27+
AgentName: &agent.Attributes.Name,
2728
AssociationProperties: make(map[string]string),
2829
}
2930

traceloop-sdk/model/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package model
33
type SpanKind string
44

55
const (
6-
SpanKindTool SpanKind = "tool"
7-
SpanKindAgent SpanKind = "agent"
8-
SpanKindTask SpanKind = "task"
6+
SpanKindTool SpanKind = "tool"
7+
SpanKindAgent SpanKind = "agent"
8+
SpanKindTask SpanKind = "task"
99
SpanKindWorkflow SpanKind = "workflow"
1010
)
1111

1212
// The varient that is active will be added to the trace.
1313
type ABTest struct {
14-
VarientsKeys map[string]bool `json:"varients_keys"`
14+
VarientKeys map[string]bool `json:"varient_keys"`
1515
}

traceloop-sdk/sdk.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121

2222
const PromptsPath = "/v1/traceloop/prompts"
2323

24-
2524
type Traceloop struct {
2625
config Config
2726
promptRegistry model.PromptRegistry
@@ -30,7 +29,6 @@ type Traceloop struct {
3029
http.Client
3130
}
3231

33-
3432
func NewClient(ctx context.Context, config Config) (*Traceloop, error) {
3533
instance := Traceloop{
3634
config: config,
@@ -153,7 +151,7 @@ func (instance *Traceloop) NewAgent(ctx context.Context, name string, agentAttrs
153151
}
154152

155153
if agentAttrs.ABTest != nil {
156-
for key, activeVarient := range agentAttrs.ABTest.VarientsKeys {
154+
for key, activeVarient := range agentAttrs.ABTest.VarientKeys {
157155
if activeVarient {
158156
agentAttrs.AssociationProperties["ab_testing_variant"] = key
159157
break
@@ -169,9 +167,9 @@ func (instance *Traceloop) NewAgent(ctx context.Context, name string, agentAttrs
169167
span.SetAttributes(attrs...)
170168

171169
return &Agent{
172-
sdk: instance,
173-
workflow: nil,
174-
ctx: aCtx,
170+
sdk: instance,
171+
workflow: nil,
172+
ctx: aCtx,
175173
Attributes: agentAttrs,
176174
}
177175
}
@@ -199,7 +197,6 @@ func (instance *Traceloop) LogPrompt(ctx context.Context, prompt Prompt, context
199197
for key, value := range contextAttrs.AssociationProperties {
200198
attrs = append(attrs, attribute.String("traceloop.association.properties."+key, value))
201199
}
202-
203200

204201
span.SetAttributes(attrs...)
205202
setMessagesAttribute(span, "llm.prompts", prompt.Messages)

traceloop-sdk/workflow.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/traceloop/go-openllmetry/traceloop-sdk/model"
87
semconvai "github.com/traceloop/go-openllmetry/semconv-ai"
8+
"github.com/traceloop/go-openllmetry/traceloop-sdk/model"
99
"go.opentelemetry.io/otel/attribute"
1010
"go.opentelemetry.io/otel/trace"
1111
)
@@ -26,12 +26,12 @@ func (instance *Traceloop) NewWorkflow(ctx context.Context, attrs WorkflowAttrib
2626
)
2727

2828
if attrs.ABTest != nil {
29-
for key, activeVarient := range attrs.ABTest.VarientsKeys {
29+
for key, activeVarient := range attrs.ABTest.VarientKeys {
3030
if activeVarient {
3131
span.SetAttributes(attribute.String("traceloop.association.properties.ab_testing_variant", key))
3232
break
3333
}
34-
}
34+
}
3535
}
3636

3737
return &Workflow{
@@ -79,7 +79,7 @@ func (workflow *Workflow) NewAgent(name string, associationProperties map[string
7979
}
8080

8181
if workflow.Attributes.ABTest != nil {
82-
for key, activeVarient := range workflow.Attributes.ABTest.VarientsKeys {
82+
for key, activeVarient := range workflow.Attributes.ABTest.VarientKeys {
8383
if activeVarient {
8484
associationProperties["ab_testing_variant"] = key
8585
}
@@ -102,4 +102,3 @@ func (workflow *Workflow) NewAgent(name string, associationProperties map[string
102102
},
103103
}
104104
}
105-

0 commit comments

Comments
 (0)