Skip to content

Commit

Permalink
add user field for litellm
Browse files Browse the repository at this point in the history
  • Loading branch information
lowjiansheng committed Jan 9, 2025
1 parent 71ded3c commit df0a3d7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llms/openai/internal/openaiclient/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ type ChatRequest struct {

// Metadata allows you to specify additional information that will be passed to the model.
Metadata map[string]any `json:"metadata,omitempty"`

// User is the user to use for the request. This is used for LiteLLM's end_user tracking.
User string `json:"user,omitempty"`
}

// ToolType is the type of a tool.
Expand Down
1 change: 1 addition & 0 deletions llms/openai/openaillm.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (o *LLM) GenerateContent(ctx context.Context, messages []llms.MessageConten
FunctionCallBehavior: openaiclient.FunctionCallBehavior(opts.FunctionCallBehavior),
Seed: opts.Seed,
Metadata: opts.Metadata,
User: opts.User,
}
if opts.JSONMode {
req.ResponseFormat = ResponseFormatJSON
Expand Down
3 changes: 3 additions & 0 deletions llms/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ type CallOptions struct {
// Supported MIME types are: text/plain: (default) Text output.
// application/json: JSON response in the response candidates.
ResponseMIMEType string `json:"response_mime_type,omitempty"`

// User is the user to use for the request. This is used for LiteLLM's end_user tracking.
User string `json:"user,omitempty"`
}

// Tool is a tool that can be used by the model.
Expand Down

0 comments on commit df0a3d7

Please sign in to comment.