Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
henomis authored May 14, 2024
1 parent 2db205c commit 4bdb995
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/content/reference/observer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ menu: { main: { parent: 'reference', weight: -92 } }

## Observer

The `Observer` interface helps to observe, debug, and analyze LLM applications. This component tracks metrics (e.g. LLM cost, latency, quality) and gains insights from external dashboards and data exports. To enable tracing an LLM application, create an observer and pass it to the LLM instance.
The `Observer` interface helps to observe, debug, and analyze LLM applications. This component tracks metrics (e.g. LLM cost, latency, quality) and gains insights from external dashboards and data exports. To enable tracing an LLM application, create an observer and attach it to the context. The observer will then track the application's execution and provide insights.

### Supported platform

Expand All @@ -16,25 +16,29 @@ The `Observer` interface helps to observe, debug, and analyze LLM applications.
### Usage

```go
ctx := context.Background()

o := langfuse.New(context.Background())
o := langfuse.New(ctx)
trace, err := o.Trace(&observer.Trace{Name: "Who are you"})
if err != nil {
panic(err)
}

openaillm := openai.New().WithObserver(o, trace.ID)
ctx = observer.ContextWithObserverInstance(ctx, o)
ctx = observer.ContextWithTraceID(ctx, trace.ID)

openaillm := openai.New()

t := thread.New().AddMessage(
thread.NewUserMessage().AddContent(
thread.NewTextContent("Hello, who are you?"),
),
)

err = openaillm.Generate(context.Background(), t)
err = openaillm.Generate(ctx, t)
if err != nil {
panic(err)
}

o.Flush(context.Background())
```
o.Flush(ctx)
```

0 comments on commit 4bdb995

Please sign in to comment.