Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ type Message struct {

// Request is a single completion request.
type Request struct {
Model string
Messages []Message
MaxTokens int
Temperature float64
Model string
Messages []Message
MaxTokens int

// Temperature is the sampling temperature. nil means "leave it to the
// provider", which is NOT the same as zero — provider defaults sit
// around 1.0. Pass Float64(0) for deterministic sampling; a bare 0
// would be indistinguishable from unset.
Temperature *float64

// TopP is nucleus-sampling cutoff. nil leaves it unset. Same
// zero-is-meaningful reasoning as Temperature.
TopP *float64

// Seed requests deterministic sampling where the provider supports
// it. nil leaves it unset. Best-effort — no provider guarantees it.
Seed *int

// JSONMode asks the provider to return a JSON object that conforms to
// JSONSchema. Providers that don't support structured outputs natively
Expand Down Expand Up @@ -89,6 +102,12 @@ type Response struct {
Model string
FinishReason string

// ReasoningContent is the model's thinking / reasoning trace when the
// provider exposes it separately from the answer (Claude extended
// thinking, OpenAI o-series). Empty when the model didn't reason or
// the provider folds it into Content.
ReasoningContent string

// Usage is the normalized accounting for this call.
Usage Usage

Expand All @@ -102,6 +121,18 @@ type Response struct {
ToolCalls []ToolCall
}

// Ptr returns a pointer to v. It exists so optional Request fields can be
// set inline: Temperature: llmgate.Ptr(0.7).
func Ptr[T any](v T) *T { return &v }

// Float64 returns a pointer to v. Prefer it over Ptr for the sampling
// fields, where the untyped-constant form reads better:
// Temperature: llmgate.Float64(0).
func Float64(v float64) *float64 { return &v }

// Int returns a pointer to v, for Request.Seed.
func Int(v int) *int { return &v }

// Client is the provider-agnostic contract.
type Client interface {
// Complete runs a single completion.
Expand Down
2 changes: 1 addition & 1 deletion examples/smoke/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func main() {
{Role: llmgate.RoleUser, Content: "In one sentence: what is vectorless retrieval?"},
},
MaxTokens: 1024,
Temperature: 0.2,
Temperature: llmgate.Float64(0.2),
})
if err != nil {
fmt.Fprintln(os.Stderr, "complete:", err)
Expand Down
63 changes: 33 additions & 30 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,48 @@ module github.com/hallelx2/llmgate

go 1.25.0

require github.com/tmc/langchaingo v0.1.14
require (
github.com/pkoukk/tiktoken-go v0.1.6
github.com/tmc/langchaingo v0.1.14
)

require (
cloud.google.com/go v0.116.0 // indirect
cloud.google.com/go v0.123.0 // indirect
cloud.google.com/go/ai v0.7.0 // indirect
cloud.google.com/go/aiplatform v1.69.0 // indirect
cloud.google.com/go/auth v0.14.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.2.2 // indirect
cloud.google.com/go/longrunning v0.6.2 // indirect
cloud.google.com/go/aiplatform v1.114.0 // indirect
cloud.google.com/go/auth v0.18.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
cloud.google.com/go/compute/metadata v0.9.0 // indirect
cloud.google.com/go/iam v1.5.3 // indirect
cloud.google.com/go/longrunning v0.8.0 // indirect
cloud.google.com/go/vertexai v0.12.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/generative-ai-go v0.15.1 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/pkoukk/tiktoken-go v0.1.6 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.11 // indirect
github.com/googleapis/gax-go/v2 v2.17.0 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/metric v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/time v0.9.0 // indirect
google.golang.org/api v0.218.0 // indirect
google.golang.org/genproto v0.0.0-20241118233622-e639e219e697 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250122153221-138b5a5a4fd4 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.3 // indirect
go.opentelemetry.io/otel v1.44.0 // indirect
go.opentelemetry.io/otel/metric v1.44.0 // indirect
go.opentelemetry.io/otel/trace v1.44.0 // indirect
golang.org/x/crypto v0.54.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sync v0.22.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/api v0.264.0 // indirect
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260526163538-3dc84a4a5aaa // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260729162451-8efbd57d26e0 // indirect
google.golang.org/grpc v1.83.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
)
Loading
Loading