Skip to content

Instantly share code, notes, and snippets.

@cartermp
Created January 11, 2025 16:30
Show Gist options
  • Save cartermp/f37b6702109bbd7401be8a1cab8bdf8d to your computer and use it in GitHub Desktop.
Save cartermp/f37b6702109bbd7401be8a1cab8bdf8d to your computer and use it in GitHub Desktop.
import (
//... other imports
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
)
var tracer = otel.Tracer("MyTracerName")
//...
func fakeMostRelevantColumns(ctx context.Context, prompt string) {
ctx, span := tracer.Start(ctx, "queryml.MostRelevantColumns")
defer span.End()
// get columns
fakeCallEmbeddings(ctx)
fakeSaveInRedisCache(ctx)
// nlq embedding
fakeCallEmbeddings(ctx)
// columns come after 'COLUMNS:' in prompt and end with a newline
// take a slice from there and end it at the newline
columns := strings.Split(prompt, "COLUMNS:")[1]
columns = strings.Split(columns, "\n")[0]
str := "[" + columns + "]"
span.SetAttributes(
attribute.String("app.nlq.most_relevant_columns", str),
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment