a06f331eb8
CI / benchmark (push) Has been skipped
install-script / posix-syntax (push) Successful in 6m1s
CI / build-onnx (push) Failing after 6m43s
init-smoke / dry-run (push) Failing after 15m57s
security / govulncheck (push) Has been cancelled
security / trivy-fs (push) Has been cancelled
CI / test (1.26, ubuntu-latest) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
CI / test (1.26, macos-latest) (push) Has been cancelled
CI / build-windows (push) Has been cancelled
CI / lint (push) Has been cancelled
install-script / powershell-syntax (push) Has been cancelled
install-script / install (macos-14) (push) Has been cancelled
install-script / install (ubuntu-latest) (push) Has been cancelled
35 lines
946 B
Go
35 lines
946 B
Go
package conversationlog
|
|
|
|
import "context"
|
|
|
|
// Meta carries the session / file / phase labels a recorder stamps onto
|
|
// each Record. Callers attach it to the context they pass into the LLM
|
|
// service so the service can label the turn without a direct dependency
|
|
// on the caller's session machinery.
|
|
type Meta struct {
|
|
Session string
|
|
Repo string
|
|
File string
|
|
Phase string
|
|
}
|
|
|
|
type metaContextKey struct{}
|
|
|
|
// WithMeta returns a context carrying the conversation-log labels. The
|
|
// LLM service reads them via MetaFromContext when it records a turn.
|
|
func WithMeta(ctx context.Context, m Meta) context.Context {
|
|
return context.WithValue(ctx, metaContextKey{}, m)
|
|
}
|
|
|
|
// MetaFromContext returns the labels attached by WithMeta, or the zero
|
|
// Meta when none are present.
|
|
func MetaFromContext(ctx context.Context) Meta {
|
|
if ctx == nil {
|
|
return Meta{}
|
|
}
|
|
if m, ok := ctx.Value(metaContextKey{}).(Meta); ok {
|
|
return m
|
|
}
|
|
return Meta{}
|
|
}
|