Skip to content

Commit eba85ce

Browse files
committed
add end
1 parent 6cfec4e commit eba85ce

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

sample-app/generate_joke_workflow_example.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func createJoke(ctx context.Context, workflow *sdk.Workflow, client *openai.Clie
6565
return resp.Choices[0].Message.Content, nil
6666
}
6767

68-
func translateJokeToPirate(ctx context.Context, traceloop *sdk.Traceloop, workflow *sdk.Workflow, client *openai.Client, joke string) (string, error) {
68+
func translateJokeToPirate(ctx context.Context, workflow *sdk.Workflow, client *openai.Client, joke string) (string, error) {
6969
// Log prompt
7070
piratePrompt := fmt.Sprintf("Translate the below joke to pirate-like english:\n\n%s", joke)
7171
prompt := sdk.Prompt{
@@ -82,6 +82,7 @@ func translateJokeToPirate(ctx context.Context, traceloop *sdk.Traceloop, workfl
8282
}
8383

8484
agent := workflow.NewAgent("joke_translation")
85+
defer agent.End()
8586

8687
llmSpan := agent.LogPrompt(prompt)
8788

@@ -147,6 +148,7 @@ func historyJokesTool(ctx context.Context, agent *sdk.Agent, client *openai.Clie
147148
Description: "Get some history jokes",
148149
Parameters: map[string]interface{}{},
149150
})
151+
defer tool.End()
150152

151153
llmSpan := tool.LogPrompt(prompt)
152154

@@ -271,7 +273,7 @@ func runJokeWorkflow() {
271273
fmt.Printf("\nEnglish joke:\n%s\n\n", engJoke)
272274

273275
fmt.Println("Translating to pirate...")
274-
pirateJoke, err := translateJokeToPirate(ctx, traceloop, wf, client, engJoke)
276+
pirateJoke, err := translateJokeToPirate(ctx, wf, client, engJoke)
275277
if err != nil {
276278
fmt.Printf("Error translating joke: %v\n", err)
277279
return

traceloop-sdk/workflow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func (workflow *Workflow) NewAgent(name string) *Agent {
6565
)
6666

6767
return &Agent{
68+
sdk: workflow.sdk,
6869
workflow: workflow,
6970
ctx: aCtx,
7071
Name: name,

0 commit comments

Comments
 (0)