Documentation
¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func F[T any](value T) param.Field[T]
- func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type AudioService
- type AudioTranscriptionNewParams
- type AudioTranscriptionNewParamsLanguage
- type AudioTranscriptionNewParamsModel
- type AudioTranscriptionNewParamsResponseFormat
- type AudioTranscriptionNewParamsTimestampGranularity
- type AudioTranscriptionNewResponse
- type AudioTranscriptionService
- type AudioTranslationNewParams
- type AudioTranslationNewParamsModel
- type AudioTranslationNewParamsResponseFormat
- type AudioTranslationNewResponse
- type AudioTranslationService
- type ChatCompletionNewParams
- type ChatCompletionNewParamsFunction
- type ChatCompletionNewParamsFunctionCallChatCompletionFunctionCallOption
- type ChatCompletionNewParamsFunctionCallString
- type ChatCompletionNewParamsFunctionCallUnion
- type ChatCompletionNewParamsMessage
- type ChatCompletionNewParamsMessageUnion
- type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessage
- type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageFunctionCall
- type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole
- type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCall
- type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsFunction
- type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsType
- type ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessage
- type ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole
- type ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessage
- type ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole
- type ChatCompletionNewParamsMessagesChatCompletionRequestToolMessage
- type ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessage
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPart
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartUnion
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentParts
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImage
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURL
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageType
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartText
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartTextType
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsType
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion
- type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole
- type ChatCompletionNewParamsMessagesRole
- type ChatCompletionNewParamsModel
- type ChatCompletionNewParamsResponseFormat
- type ChatCompletionNewParamsResponseFormatType
- type ChatCompletionNewParamsStopArray
- type ChatCompletionNewParamsStopUnion
- type ChatCompletionNewParamsTool
- type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoice
- type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceFunction
- type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType
- type ChatCompletionNewParamsToolChoiceString
- type ChatCompletionNewParamsToolChoiceUnion
- type ChatCompletionNewParamsToolsFunction
- type ChatCompletionNewParamsToolsType
- type ChatCompletionNewResponse
- type ChatCompletionNewResponseChoice
- type ChatCompletionNewResponseChoicesFinishReason
- type ChatCompletionNewResponseChoicesLogprobs
- type ChatCompletionNewResponseChoicesLogprobsContent
- type ChatCompletionNewResponseChoicesLogprobsContentTopLogprob
- type ChatCompletionNewResponseChoicesMessage
- type ChatCompletionNewResponseChoicesMessageFunctionCall
- type ChatCompletionNewResponseChoicesMessageRole
- type ChatCompletionNewResponseChoicesMessageToolCall
- type ChatCompletionNewResponseChoicesMessageToolCallsFunction
- type ChatCompletionNewResponseChoicesMessageToolCallsType
- type ChatCompletionNewResponseObject
- type ChatCompletionNewResponseUsage
- type ChatCompletionService
- type ChatService
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, ...) error
- func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- type EmbeddingNewParams
- type EmbeddingNewParamsEncodingFormat
- type EmbeddingNewParamsInputArray
- type EmbeddingNewParamsInputUnion
- type EmbeddingNewParamsModel
- type EmbeddingNewResponse
- type EmbeddingNewResponseData
- type EmbeddingNewResponseDataEmbeddingArray
- type EmbeddingNewResponseDataEmbeddingUnion
- type EmbeddingNewResponseDataObject
- type EmbeddingNewResponseObject
- type EmbeddingNewResponseUsage
- type EmbeddingService
- type Error
- type Model
- type ModelDeleteResponse
- type ModelListResponse
- type ModelListResponseObject
- type ModelObject
- type ModelService
- func (r *ModelService) Delete(ctx context.Context, model string, opts ...option.RequestOption) (res *ModelDeleteResponse, err error)
- func (r *ModelService) Get(ctx context.Context, model string, opts ...option.RequestOption) (res *Model, err error)
- func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *ModelListResponse, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func F ¶
F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.
func Int ¶
Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.
func Raw ¶
Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).
Types ¶
type AudioService ¶
type AudioService struct {
Options []option.RequestOption
Transcriptions *AudioTranscriptionService
Translations *AudioTranslationService
}
AudioService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioService method instead.
func NewAudioService ¶
func NewAudioService(opts ...option.RequestOption) (r *AudioService)
NewAudioService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
type AudioTranscriptionNewParams ¶
type AudioTranscriptionNewParams struct {
// The audio file object (not file name) to transcribe, in one of these formats:
// flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
File param.Field[io.Reader] `json:"file,required" format:"binary"`
// ID of the model to use. Only `whisper-large-v3` is currently available.
Model param.Field[AudioTranscriptionNewParamsModel] `json:"model,required"`
// The language of the input audio. Supplying the input language in
// [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format will
// improve accuracy and latency.
Language param.Field[AudioTranscriptionNewParamsLanguage] `json:"language"`
// An optional text to guide the model's style or continue a previous audio
// segment. The [prompt](/docs/guides/speech-to-text/prompting) should match the
// audio language.
Prompt param.Field[string] `json:"prompt"`
// The format of the transcript output, in one of these options: `json`, `text`, or
// `verbose_json`.
ResponseFormat param.Field[AudioTranscriptionNewParamsResponseFormat] `json:"response_format"`
// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
// output more random, while lower values like 0.2 will make it more focused and
// deterministic. If set to 0, the model will use
// [log probability](https://en.wikipedia.org/wiki/Log_probability) to
// automatically increase the temperature until certain thresholds are hit.
Temperature param.Field[float64] `json:"temperature"`
// The timestamp granularities to populate for this transcription.
// `response_format` must be set `verbose_json` to use timestamp granularities.
// Either or both of these options are supported: `word`, or `segment`. Note: There
// is no additional latency for segment timestamps, but generating word timestamps
// incurs additional latency.
TimestampGranularities param.Field[[]AudioTranscriptionNewParamsTimestampGranularity] `json:"timestamp_granularities"`
}
func (AudioTranscriptionNewParams) MarshalMultipart ¶
func (r AudioTranscriptionNewParams) MarshalMultipart() (data []byte, contentType string, err error)
type AudioTranscriptionNewParamsLanguage ¶
type AudioTranscriptionNewParamsLanguage string
const ( AudioTranscriptionNewParamsLanguageEn AudioTranscriptionNewParamsLanguage = "en" AudioTranscriptionNewParamsLanguageZh AudioTranscriptionNewParamsLanguage = "zh" AudioTranscriptionNewParamsLanguageDe AudioTranscriptionNewParamsLanguage = "de" AudioTranscriptionNewParamsLanguageEs AudioTranscriptionNewParamsLanguage = "es" AudioTranscriptionNewParamsLanguageRu AudioTranscriptionNewParamsLanguage = "ru" AudioTranscriptionNewParamsLanguageKo AudioTranscriptionNewParamsLanguage = "ko" AudioTranscriptionNewParamsLanguageFr AudioTranscriptionNewParamsLanguage = "fr" AudioTranscriptionNewParamsLanguageJa AudioTranscriptionNewParamsLanguage = "ja" AudioTranscriptionNewParamsLanguagePt AudioTranscriptionNewParamsLanguage = "pt" AudioTranscriptionNewParamsLanguageTr AudioTranscriptionNewParamsLanguage = "tr" AudioTranscriptionNewParamsLanguagePl AudioTranscriptionNewParamsLanguage = "pl" AudioTranscriptionNewParamsLanguageCa AudioTranscriptionNewParamsLanguage = "ca" AudioTranscriptionNewParamsLanguageNl AudioTranscriptionNewParamsLanguage = "nl" AudioTranscriptionNewParamsLanguageAr AudioTranscriptionNewParamsLanguage = "ar" AudioTranscriptionNewParamsLanguageSv AudioTranscriptionNewParamsLanguage = "sv" AudioTranscriptionNewParamsLanguageIt AudioTranscriptionNewParamsLanguage = "it" AudioTranscriptionNewParamsLanguageID AudioTranscriptionNewParamsLanguage = "id" AudioTranscriptionNewParamsLanguageHi AudioTranscriptionNewParamsLanguage = "hi" AudioTranscriptionNewParamsLanguageFi AudioTranscriptionNewParamsLanguage = "fi" AudioTranscriptionNewParamsLanguageVi AudioTranscriptionNewParamsLanguage = "vi" AudioTranscriptionNewParamsLanguageHe AudioTranscriptionNewParamsLanguage = "he" AudioTranscriptionNewParamsLanguageUk AudioTranscriptionNewParamsLanguage = "uk" AudioTranscriptionNewParamsLanguageEl AudioTranscriptionNewParamsLanguage = "el" AudioTranscriptionNewParamsLanguageMs AudioTranscriptionNewParamsLanguage = "ms" AudioTranscriptionNewParamsLanguageCs AudioTranscriptionNewParamsLanguage = "cs" AudioTranscriptionNewParamsLanguageRo AudioTranscriptionNewParamsLanguage = "ro" AudioTranscriptionNewParamsLanguageDa AudioTranscriptionNewParamsLanguage = "da" AudioTranscriptionNewParamsLanguageHu AudioTranscriptionNewParamsLanguage = "hu" AudioTranscriptionNewParamsLanguageTa AudioTranscriptionNewParamsLanguage = "ta" AudioTranscriptionNewParamsLanguageTh AudioTranscriptionNewParamsLanguage = "th" AudioTranscriptionNewParamsLanguageUr AudioTranscriptionNewParamsLanguage = "ur" AudioTranscriptionNewParamsLanguageHr AudioTranscriptionNewParamsLanguage = "hr" AudioTranscriptionNewParamsLanguageBg AudioTranscriptionNewParamsLanguage = "bg" AudioTranscriptionNewParamsLanguageLt AudioTranscriptionNewParamsLanguage = "lt" AudioTranscriptionNewParamsLanguageLa AudioTranscriptionNewParamsLanguage = "la" AudioTranscriptionNewParamsLanguageMi AudioTranscriptionNewParamsLanguage = "mi" AudioTranscriptionNewParamsLanguageMl AudioTranscriptionNewParamsLanguage = "ml" AudioTranscriptionNewParamsLanguageCy AudioTranscriptionNewParamsLanguage = "cy" AudioTranscriptionNewParamsLanguageSk AudioTranscriptionNewParamsLanguage = "sk" AudioTranscriptionNewParamsLanguageTe AudioTranscriptionNewParamsLanguage = "te" AudioTranscriptionNewParamsLanguageFa AudioTranscriptionNewParamsLanguage = "fa" AudioTranscriptionNewParamsLanguageLv AudioTranscriptionNewParamsLanguage = "lv" AudioTranscriptionNewParamsLanguageBn AudioTranscriptionNewParamsLanguage = "bn" AudioTranscriptionNewParamsLanguageSr AudioTranscriptionNewParamsLanguage = "sr" AudioTranscriptionNewParamsLanguageAz AudioTranscriptionNewParamsLanguage = "az" AudioTranscriptionNewParamsLanguageSl AudioTranscriptionNewParamsLanguage = "sl" AudioTranscriptionNewParamsLanguageKn AudioTranscriptionNewParamsLanguage = "kn" AudioTranscriptionNewParamsLanguageEt AudioTranscriptionNewParamsLanguage = "et" AudioTranscriptionNewParamsLanguageMk AudioTranscriptionNewParamsLanguage = "mk" AudioTranscriptionNewParamsLanguageBr AudioTranscriptionNewParamsLanguage = "br" AudioTranscriptionNewParamsLanguageEu AudioTranscriptionNewParamsLanguage = "eu" AudioTranscriptionNewParamsLanguageIs AudioTranscriptionNewParamsLanguage = "is" AudioTranscriptionNewParamsLanguageHy AudioTranscriptionNewParamsLanguage = "hy" AudioTranscriptionNewParamsLanguageNe AudioTranscriptionNewParamsLanguage = "ne" AudioTranscriptionNewParamsLanguageMn AudioTranscriptionNewParamsLanguage = "mn" AudioTranscriptionNewParamsLanguageBs AudioTranscriptionNewParamsLanguage = "bs" AudioTranscriptionNewParamsLanguageKk AudioTranscriptionNewParamsLanguage = "kk" AudioTranscriptionNewParamsLanguageSq AudioTranscriptionNewParamsLanguage = "sq" AudioTranscriptionNewParamsLanguageSw AudioTranscriptionNewParamsLanguage = "sw" AudioTranscriptionNewParamsLanguageGl AudioTranscriptionNewParamsLanguage = "gl" AudioTranscriptionNewParamsLanguageMr AudioTranscriptionNewParamsLanguage = "mr" AudioTranscriptionNewParamsLanguagePa AudioTranscriptionNewParamsLanguage = "pa" AudioTranscriptionNewParamsLanguageSi AudioTranscriptionNewParamsLanguage = "si" AudioTranscriptionNewParamsLanguageKm AudioTranscriptionNewParamsLanguage = "km" AudioTranscriptionNewParamsLanguageSn AudioTranscriptionNewParamsLanguage = "sn" AudioTranscriptionNewParamsLanguageYo AudioTranscriptionNewParamsLanguage = "yo" AudioTranscriptionNewParamsLanguageSo AudioTranscriptionNewParamsLanguage = "so" AudioTranscriptionNewParamsLanguageAf AudioTranscriptionNewParamsLanguage = "af" AudioTranscriptionNewParamsLanguageOc AudioTranscriptionNewParamsLanguage = "oc" AudioTranscriptionNewParamsLanguageKa AudioTranscriptionNewParamsLanguage = "ka" AudioTranscriptionNewParamsLanguageBe AudioTranscriptionNewParamsLanguage = "be" AudioTranscriptionNewParamsLanguageTg AudioTranscriptionNewParamsLanguage = "tg" AudioTranscriptionNewParamsLanguageSd AudioTranscriptionNewParamsLanguage = "sd" AudioTranscriptionNewParamsLanguageGu AudioTranscriptionNewParamsLanguage = "gu" AudioTranscriptionNewParamsLanguageAm AudioTranscriptionNewParamsLanguage = "am" AudioTranscriptionNewParamsLanguageYi AudioTranscriptionNewParamsLanguage = "yi" AudioTranscriptionNewParamsLanguageLo AudioTranscriptionNewParamsLanguage = "lo" AudioTranscriptionNewParamsLanguageUz AudioTranscriptionNewParamsLanguage = "uz" AudioTranscriptionNewParamsLanguageFo AudioTranscriptionNewParamsLanguage = "fo" AudioTranscriptionNewParamsLanguageHt AudioTranscriptionNewParamsLanguage = "ht" AudioTranscriptionNewParamsLanguagePs AudioTranscriptionNewParamsLanguage = "ps" AudioTranscriptionNewParamsLanguageTk AudioTranscriptionNewParamsLanguage = "tk" AudioTranscriptionNewParamsLanguageNn AudioTranscriptionNewParamsLanguage = "nn" AudioTranscriptionNewParamsLanguageMt AudioTranscriptionNewParamsLanguage = "mt" AudioTranscriptionNewParamsLanguageSa AudioTranscriptionNewParamsLanguage = "sa" AudioTranscriptionNewParamsLanguageLb AudioTranscriptionNewParamsLanguage = "lb" AudioTranscriptionNewParamsLanguageMy AudioTranscriptionNewParamsLanguage = "my" AudioTranscriptionNewParamsLanguageBo AudioTranscriptionNewParamsLanguage = "bo" AudioTranscriptionNewParamsLanguageTl AudioTranscriptionNewParamsLanguage = "tl" AudioTranscriptionNewParamsLanguageMg AudioTranscriptionNewParamsLanguage = "mg" AudioTranscriptionNewParamsLanguageAs AudioTranscriptionNewParamsLanguage = "as" AudioTranscriptionNewParamsLanguageTt AudioTranscriptionNewParamsLanguage = "tt" AudioTranscriptionNewParamsLanguageHaw AudioTranscriptionNewParamsLanguage = "haw" AudioTranscriptionNewParamsLanguageLn AudioTranscriptionNewParamsLanguage = "ln" AudioTranscriptionNewParamsLanguageHa AudioTranscriptionNewParamsLanguage = "ha" AudioTranscriptionNewParamsLanguageBa AudioTranscriptionNewParamsLanguage = "ba" AudioTranscriptionNewParamsLanguageJv AudioTranscriptionNewParamsLanguage = "jv" AudioTranscriptionNewParamsLanguageSu AudioTranscriptionNewParamsLanguage = "su" AudioTranscriptionNewParamsLanguageYue AudioTranscriptionNewParamsLanguage = "yue" )
func (AudioTranscriptionNewParamsLanguage) IsKnown ¶
func (r AudioTranscriptionNewParamsLanguage) IsKnown() bool
type AudioTranscriptionNewParamsModel ¶
type AudioTranscriptionNewParamsModel string
const (
AudioTranscriptionNewParamsModelWhisperLargeV3 AudioTranscriptionNewParamsModel = "whisper-large-v3"
)
func (AudioTranscriptionNewParamsModel) IsKnown ¶
func (r AudioTranscriptionNewParamsModel) IsKnown() bool
type AudioTranscriptionNewParamsResponseFormat ¶
type AudioTranscriptionNewParamsResponseFormat string
The format of the transcript output, in one of these options: `json`, `text`, or `verbose_json`.
const ( AudioTranscriptionNewParamsResponseFormatJson AudioTranscriptionNewParamsResponseFormat = "json" AudioTranscriptionNewParamsResponseFormatText AudioTranscriptionNewParamsResponseFormat = "text" AudioTranscriptionNewParamsResponseFormatVerboseJson AudioTranscriptionNewParamsResponseFormat = "verbose_json" )
func (AudioTranscriptionNewParamsResponseFormat) IsKnown ¶
func (r AudioTranscriptionNewParamsResponseFormat) IsKnown() bool
type AudioTranscriptionNewParamsTimestampGranularity ¶
type AudioTranscriptionNewParamsTimestampGranularity string
const ( AudioTranscriptionNewParamsTimestampGranularityWord AudioTranscriptionNewParamsTimestampGranularity = "word" AudioTranscriptionNewParamsTimestampGranularitySegment AudioTranscriptionNewParamsTimestampGranularity = "segment" )
func (AudioTranscriptionNewParamsTimestampGranularity) IsKnown ¶
func (r AudioTranscriptionNewParamsTimestampGranularity) IsKnown() bool
type AudioTranscriptionNewResponse ¶
type AudioTranscriptionNewResponse struct {
// The transcribed text.
Text string `json:"text,required"`
JSON audioTranscriptionNewResponseJSON `json:"-"`
}
Represents a transcription response returned by model, based on the provided input.
func (*AudioTranscriptionNewResponse) UnmarshalJSON ¶
func (r *AudioTranscriptionNewResponse) UnmarshalJSON(data []byte) (err error)
type AudioTranscriptionService ¶
type AudioTranscriptionService struct {
Options []option.RequestOption
}
AudioTranscriptionService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioTranscriptionService method instead.
func NewAudioTranscriptionService ¶
func NewAudioTranscriptionService(opts ...option.RequestOption) (r *AudioTranscriptionService)
NewAudioTranscriptionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*AudioTranscriptionService) New ¶
func (r *AudioTranscriptionService) New(ctx context.Context, body AudioTranscriptionNewParams, opts ...option.RequestOption) (res *AudioTranscriptionNewResponse, err error)
Transcribes audio into the input language.
type AudioTranslationNewParams ¶
type AudioTranslationNewParams struct {
// The audio file object (not file name) translate, in one of these formats: flac,
// mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
File param.Field[io.Reader] `json:"file,required" format:"binary"`
// ID of the model to use. Only `whisper-large-v3` is currently available.
Model param.Field[AudioTranslationNewParamsModel] `json:"model,required"`
// An optional text to guide the model's style or continue a previous audio
// segment. The [prompt](/docs/guides/speech-to-text/prompting) should be in
// English.
Prompt param.Field[string] `json:"prompt"`
// The format of the transcript output, in one of these options: `json`, `text`, or
// `verbose_json`.
ResponseFormat param.Field[AudioTranslationNewParamsResponseFormat] `json:"response_format"`
// The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
// output more random, while lower values like 0.2 will make it more focused and
// deterministic. If set to 0, the model will use
// [log probability](https://en.wikipedia.org/wiki/Log_probability) to
// automatically increase the temperature until certain thresholds are hit.
Temperature param.Field[float64] `json:"temperature"`
}
func (AudioTranslationNewParams) MarshalMultipart ¶
func (r AudioTranslationNewParams) MarshalMultipart() (data []byte, contentType string, err error)
type AudioTranslationNewParamsModel ¶
type AudioTranslationNewParamsModel string
const (
AudioTranslationNewParamsModelWhisperLargeV3 AudioTranslationNewParamsModel = "whisper-large-v3"
)
func (AudioTranslationNewParamsModel) IsKnown ¶
func (r AudioTranslationNewParamsModel) IsKnown() bool
type AudioTranslationNewParamsResponseFormat ¶
type AudioTranslationNewParamsResponseFormat string
The format of the transcript output, in one of these options: `json`, `text`, or `verbose_json`.
const ( AudioTranslationNewParamsResponseFormatJson AudioTranslationNewParamsResponseFormat = "json" AudioTranslationNewParamsResponseFormatText AudioTranslationNewParamsResponseFormat = "text" AudioTranslationNewParamsResponseFormatVerboseJson AudioTranslationNewParamsResponseFormat = "verbose_json" )
func (AudioTranslationNewParamsResponseFormat) IsKnown ¶
func (r AudioTranslationNewParamsResponseFormat) IsKnown() bool
type AudioTranslationNewResponse ¶
type AudioTranslationNewResponse struct {
Text string `json:"text,required"`
JSON audioTranslationNewResponseJSON `json:"-"`
}
func (*AudioTranslationNewResponse) UnmarshalJSON ¶
func (r *AudioTranslationNewResponse) UnmarshalJSON(data []byte) (err error)
type AudioTranslationService ¶
type AudioTranslationService struct {
Options []option.RequestOption
}
AudioTranslationService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAudioTranslationService method instead.
func NewAudioTranslationService ¶
func NewAudioTranslationService(opts ...option.RequestOption) (r *AudioTranslationService)
NewAudioTranslationService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*AudioTranslationService) New ¶
func (r *AudioTranslationService) New(ctx context.Context, body AudioTranslationNewParams, opts ...option.RequestOption) (res *AudioTranslationNewResponse, err error)
Translates audio into English.
type ChatCompletionNewParams ¶
type ChatCompletionNewParams struct {
// A list of messages comprising the conversation so far.
Messages param.Field[[]ChatCompletionNewParamsMessageUnion] `json:"messages,required"`
// ID of the model to use. For details on which models are compatible with the Chat
// API, see available [models](/docs/models)
Model param.Field[ChatCompletionNewParamsModel] `json:"model,required"`
// Number between -2.0 and 2.0. Positive values penalize new tokens based on their
// existing frequency in the text so far, decreasing the model's likelihood to
// repeat the same line verbatim.
FrequencyPenalty param.Field[float64] `json:"frequency_penalty"`
// Deprecated in favor of `tool_choice`.
//
// Controls which (if any) function is called by the model. `none` means the model
// will not call a function and instead generates a message. `auto` means the model
// can pick between generating a message or calling a function. Specifying a
// particular function via `{"name": "my_function"}` forces the model to call that
// function.
//
// `none` is the default when no functions are present. `auto` is the default if
// functions are present.
FunctionCall param.Field[ChatCompletionNewParamsFunctionCallUnion] `json:"function_call"`
// Deprecated in favor of `tools`.
//
// A list of functions the model may generate JSON inputs for.
Functions param.Field[[]ChatCompletionNewParamsFunction] `json:"functions"`
// This is not yet supported by any of our models. Modify the likelihood of
// specified tokens appearing in the completion.
LogitBias param.Field[map[string]int64] `json:"logit_bias"`
// This is not yet supported by any of our models. Whether to return log
// probabilities of the output tokens or not. If true, returns the log
// probabilities of each output token returned in the `content` of `message`.
Logprobs param.Field[bool] `json:"logprobs"`
// The maximum number of tokens that can be generated in the chat completion. The
// total length of input tokens and generated tokens is limited by the model's
// context length.
MaxTokens param.Field[int64] `json:"max_tokens"`
// How many chat completion choices to generate for each input message. Note that
// the current moment, only n=1 is supported. Other values will result in a 400
// response.
N param.Field[int64] `json:"n"`
// Whether to enable parallel function calling during tool use.
ParallelToolCalls param.Field[bool] `json:"parallel_tool_calls"`
// Number between -2.0 and 2.0. Positive values penalize new tokens based on
// whether they appear in the text so far, increasing the model's likelihood to
// talk about new topics.
PresencePenalty param.Field[float64] `json:"presence_penalty"`
// An object specifying the format that the model must output.
//
// Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
// message the model generates is valid JSON.
//
// **Important:** when using JSON mode, you **must** also instruct the model to
// produce JSON yourself via a system or user message.
ResponseFormat param.Field[ChatCompletionNewParamsResponseFormat] `json:"response_format"`
// If specified, our system will make a best effort to sample deterministically,
// such that repeated requests with the same `seed` and parameters should return
// the same result. Determinism is not guaranteed, and you should refer to the
// `system_fingerprint` response parameter to monitor changes in the backend.
Seed param.Field[int64] `json:"seed"`
// Up to 4 sequences where the API will stop generating further tokens. The
// returned text will not contain the stop sequence.
Stop param.Field[ChatCompletionNewParamsStopUnion] `json:"stop"`
// If set, partial message deltas will be sent. Tokens will be sent as data-only
// [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format)
// as they become available, with the stream terminated by a `data: [DONE]`
// message. [Example code](/docs/text-chat#streaming-a-chat-completion).
Stream param.Field[bool] `json:"stream"`
// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
// make the output more random, while lower values like 0.2 will make it more
// focused and deterministic. We generally recommend altering this or top_p but not
// both
Temperature param.Field[float64] `json:"temperature"`
// Controls which (if any) tool is called by the model. `none` means the model will
// not call any tool and instead generates a message. `auto` means the model can
// pick between generating a message or calling one or more tools. `required` means
// the model must call one or more tools. Specifying a particular tool via
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
// call that tool.
//
// `none` is the default when no tools are present. `auto` is the default if tools
// are present.
ToolChoice param.Field[ChatCompletionNewParamsToolChoiceUnion] `json:"tool_choice"`
// A list of tools the model may call. Currently, only functions are supported as a
// tool. Use this to provide a list of functions the model may generate JSON inputs
// for. A max of 128 functions are supported.
Tools param.Field[[]ChatCompletionNewParamsTool] `json:"tools"`
// This is not yet supported by any of our models. An integer between 0 and 20
// specifying the number of most likely tokens to return at each token position,
// each with an associated log probability. `logprobs` must be set to `true` if
// this parameter is used.
TopLogprobs param.Field[int64] `json:"top_logprobs"`
// An alternative to sampling with temperature, called nucleus sampling, where the
// model considers the results of the tokens with top_p probability mass. So 0.1
// means only the tokens comprising the top 10% probability mass are considered. We
// generally recommend altering this or temperature but not both.
TopP param.Field[float64] `json:"top_p"`
// A unique identifier representing your end-user, which can help us monitor and
// detect abuse.
User param.Field[string] `json:"user"`
}
func (ChatCompletionNewParams) MarshalJSON ¶
func (r ChatCompletionNewParams) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsFunction ¶
type ChatCompletionNewParamsFunction struct {
// The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
// underscores and dashes, with a maximum length of 64.
Name param.Field[string] `json:"name,required"`
// A description of what the function does, used by the model to choose when and
// how to call the function.
Description param.Field[string] `json:"description"`
// The parameters the functions accepts, described as a JSON Schema object. See the
// docs on [tool use](/docs/tool-use) for examples, and the
// [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
// documentation about the format.
//
// Omitting `parameters` defines a function with an empty parameter list.
Parameters param.Field[map[string]interface{}] `json:"parameters"`
}
func (ChatCompletionNewParamsFunction) MarshalJSON ¶
func (r ChatCompletionNewParamsFunction) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsFunctionCallChatCompletionFunctionCallOption ¶
type ChatCompletionNewParamsFunctionCallChatCompletionFunctionCallOption struct {
// The name of the function to call.
Name param.Field[string] `json:"name,required"`
}
Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
func (ChatCompletionNewParamsFunctionCallChatCompletionFunctionCallOption) MarshalJSON ¶
func (r ChatCompletionNewParamsFunctionCallChatCompletionFunctionCallOption) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsFunctionCallString ¶
type ChatCompletionNewParamsFunctionCallString string
`none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.
const ( ChatCompletionNewParamsFunctionCallStringNone ChatCompletionNewParamsFunctionCallString = "none" ChatCompletionNewParamsFunctionCallStringAuto ChatCompletionNewParamsFunctionCallString = "auto" ChatCompletionNewParamsFunctionCallStringRequired ChatCompletionNewParamsFunctionCallString = "required" )
func (ChatCompletionNewParamsFunctionCallString) IsKnown ¶
func (r ChatCompletionNewParamsFunctionCallString) IsKnown() bool
type ChatCompletionNewParamsFunctionCallUnion ¶
type ChatCompletionNewParamsFunctionCallUnion interface {
// contains filtered or unexported methods
}
Deprecated in favor of `tool_choice`.
Controls which (if any) function is called by the model. `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function. Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
`none` is the default when no functions are present. `auto` is the default if functions are present.
Satisfied by ChatCompletionNewParamsFunctionCallString, ChatCompletionNewParamsFunctionCallChatCompletionFunctionCallOption.
type ChatCompletionNewParamsMessage ¶
type ChatCompletionNewParamsMessage struct {
Content param.Field[interface{}] `json:"content,required"`
// An optional name for the participant. Provides the model information to
// differentiate between participants of the same role.
Name param.Field[string] `json:"name"`
// The role of the messages author, in this case `system`.
Role param.Field[ChatCompletionNewParamsMessagesRole] `json:"role,required"`
FunctionCall param.Field[interface{}] `json:"function_call,required"`
ToolCalls param.Field[interface{}] `json:"tool_calls,required"`
// Tool call that this message is responding to.
ToolCallID param.Field[string] `json:"tool_call_id"`
}
func (ChatCompletionNewParamsMessage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessageUnion ¶
type ChatCompletionNewParamsMessageUnion interface {
// contains filtered or unexported methods
}
Satisfied by ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessage, ChatCompletionNewParamsMessagesChatCompletionRequestUserMessage, ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessage, ChatCompletionNewParamsMessagesChatCompletionRequestToolMessage, ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessage, ChatCompletionNewParamsMessage.
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessage ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessage struct {
// The role of the messages author, in this case `assistant`.
Role param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole] `json:"role,required"`
// The contents of the assistant message. Required unless `tool_calls` or
// `function_call` is specified.
Content param.Field[string] `json:"content"`
// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
FunctionCall param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageFunctionCall] `json:"function_call"`
// An optional name for the participant. Provides the model information to
// differentiate between participants of the same role.
Name param.Field[string] `json:"name"`
// The tool calls generated by the model, such as function calls.
ToolCalls param.Field[[]ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCall] `json:"tool_calls"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageFunctionCall ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageFunctionCall struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments param.Field[string] `json:"arguments"`
// The name of the function to call.
Name param.Field[string] `json:"name"`
}
Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
func (ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageFunctionCall) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageFunctionCall) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole string
The role of the messages author, in this case `assistant`.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRoleAssistant ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole = "assistant"
)
func (ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole) IsKnown ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageRole) IsKnown() bool
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCall ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCall struct {
// The ID of the tool call.
ID param.Field[string] `json:"id,required"`
// The function that the model called.
Function param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsFunction] `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsType] `json:"type,required"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCall) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCall) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsFunction ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsFunction struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments param.Field[string] `json:"arguments,required"`
// The name of the function to call.
Name param.Field[string] `json:"name,required"`
}
The function that the model called.
func (ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsFunction) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsFunction) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsType ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsType string
The type of the tool. Currently, only `function` is supported.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsTypeFunction ChatCompletionNewParamsMessagesChatCompletionRequestAssistantMessageToolCallsType = "function"
)
type ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessage ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessage struct {
// The contents of the function message.
Content param.Field[string] `json:"content,required"`
// The name of the function to call.
Name param.Field[string] `json:"name,required"`
// The role of the messages author, in this case `function`.
Role param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole] `json:"role,required"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole string
The role of the messages author, in this case `function`.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRoleFunction ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole = "function"
)
func (ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole) IsKnown ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestFunctionMessageRole) IsKnown() bool
type ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessage ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessage struct {
// The contents of the system message.
Content param.Field[string] `json:"content,required"`
// The role of the messages author, in this case `system`.
Role param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole] `json:"role,required"`
// An optional name for the participant. Provides the model information to
// differentiate between participants of the same role.
Name param.Field[string] `json:"name"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole string
The role of the messages author, in this case `system`.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRoleSystem ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole = "system"
)
func (ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole) IsKnown ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestSystemMessageRole) IsKnown() bool
type ChatCompletionNewParamsMessagesChatCompletionRequestToolMessage ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestToolMessage struct {
// The contents of the tool message.
Content param.Field[string] `json:"content,required"`
// The role of the messages author, in this case `tool`.
Role param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole] `json:"role,required"`
// Tool call that this message is responding to.
ToolCallID param.Field[string] `json:"tool_call_id,required"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestToolMessage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestToolMessage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole string
The role of the messages author, in this case `tool`.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRoleTool ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole = "tool"
)
func (ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole) IsKnown ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestToolMessageRole) IsKnown() bool
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessage ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessage struct {
// The contents of the user message.
Content param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion] `json:"content,required"`
// The role of the messages author, in this case `user`.
Role param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole] `json:"role,required"`
// An optional name for the participant. Provides the model information to
// differentiate between participants of the same role.
Name param.Field[string] `json:"name"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPart ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPart struct {
// The text content.
Text param.Field[string] `json:"text"`
// The type of the content part.
Type param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsType] `json:"type,required"`
ImageURL param.Field[interface{}] `json:"image_url,required"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPart) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPart) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartUnion ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartUnion interface {
// contains filtered or unexported methods
}
Satisfied by ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartText, ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImage, ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPart.
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentParts ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentParts []ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartUnion
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentParts) ImplementsChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentParts) ImplementsChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion()
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImage ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImage struct {
ImageURL param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURL] `json:"image_url,required"`
// The type of the content part.
Type param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageType] `json:"type,required"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImage) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImage) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURL ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURL struct {
// Either a URL of the image or the base64 encoded image data.
URL param.Field[string] `json:"url,required" format:"uri"`
// Specifies the detail level of the image.
Detail param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail] `json:"detail"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURL) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURL) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail string
Specifies the detail level of the image.
const ( ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetailAuto ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail = "auto" ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetailLow ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail = "low" ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetailHigh ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageImageURLDetail = "high" )
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageType ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageType string
The type of the content part.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageTypeImageURL ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartImageType = "image_url"
)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartText ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartText struct {
// The text content.
Text param.Field[string] `json:"text,required"`
// The type of the content part.
Type param.Field[ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartTextType] `json:"type,required"`
}
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartText) MarshalJSON ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartText) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartTextType ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartTextType string
The type of the content part.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartTextTypeText ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsChatCompletionRequestMessageContentPartTextType = "text"
)
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsType ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsType string
The type of the content part.
const ( ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsTypeText ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsType = "text" ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsTypeImageURL ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentPartsType = "image_url" )
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion interface {
ImplementsChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentUnion()
}
The contents of the user message.
Satisfied by shared.UnionString, ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageContentArrayOfContentParts.
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole ¶
type ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole string
The role of the messages author, in this case `user`.
const (
ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRoleUser ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole = "user"
)
func (ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole) IsKnown ¶
func (r ChatCompletionNewParamsMessagesChatCompletionRequestUserMessageRole) IsKnown() bool
type ChatCompletionNewParamsMessagesRole ¶
type ChatCompletionNewParamsMessagesRole string
The role of the messages author, in this case `system`.
const ( ChatCompletionNewParamsMessagesRoleSystem ChatCompletionNewParamsMessagesRole = "system" ChatCompletionNewParamsMessagesRoleUser ChatCompletionNewParamsMessagesRole = "user" ChatCompletionNewParamsMessagesRoleAssistant ChatCompletionNewParamsMessagesRole = "assistant" ChatCompletionNewParamsMessagesRoleTool ChatCompletionNewParamsMessagesRole = "tool" ChatCompletionNewParamsMessagesRoleFunction ChatCompletionNewParamsMessagesRole = "function" )
func (ChatCompletionNewParamsMessagesRole) IsKnown ¶
func (r ChatCompletionNewParamsMessagesRole) IsKnown() bool
type ChatCompletionNewParamsModel ¶
type ChatCompletionNewParamsModel string
const ( ChatCompletionNewParamsModelGemma7bIt ChatCompletionNewParamsModel = "gemma-7b-it" ChatCompletionNewParamsModelLlama3_70b8192 ChatCompletionNewParamsModel = "llama3-70b-8192" ChatCompletionNewParamsModelLlama3_8b8192 ChatCompletionNewParamsModel = "llama3-8b-8192" ChatCompletionNewParamsModelMixtral8x7b32768 ChatCompletionNewParamsModel = "mixtral-8x7b-32768" )
func (ChatCompletionNewParamsModel) IsKnown ¶
func (r ChatCompletionNewParamsModel) IsKnown() bool
type ChatCompletionNewParamsResponseFormat ¶
type ChatCompletionNewParamsResponseFormat struct {
// Must be one of `text` or `json_object`.
Type param.Field[ChatCompletionNewParamsResponseFormatType] `json:"type"`
}
An object specifying the format that the model must output.
Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the message the model generates is valid JSON.
**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message.
func (ChatCompletionNewParamsResponseFormat) MarshalJSON ¶
func (r ChatCompletionNewParamsResponseFormat) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsResponseFormatType ¶
type ChatCompletionNewParamsResponseFormatType string
Must be one of `text` or `json_object`.
const ( ChatCompletionNewParamsResponseFormatTypeText ChatCompletionNewParamsResponseFormatType = "text" ChatCompletionNewParamsResponseFormatTypeJsonObject ChatCompletionNewParamsResponseFormatType = "json_object" )
func (ChatCompletionNewParamsResponseFormatType) IsKnown ¶
func (r ChatCompletionNewParamsResponseFormatType) IsKnown() bool
type ChatCompletionNewParamsStopArray ¶
type ChatCompletionNewParamsStopArray []string
func (ChatCompletionNewParamsStopArray) ImplementsChatCompletionNewParamsStopUnion ¶
func (r ChatCompletionNewParamsStopArray) ImplementsChatCompletionNewParamsStopUnion()
type ChatCompletionNewParamsStopUnion ¶
type ChatCompletionNewParamsStopUnion interface {
ImplementsChatCompletionNewParamsStopUnion()
}
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
Satisfied by shared.UnionString, ChatCompletionNewParamsStopArray.
type ChatCompletionNewParamsTool ¶
type ChatCompletionNewParamsTool struct {
Function param.Field[ChatCompletionNewParamsToolsFunction] `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type param.Field[ChatCompletionNewParamsToolsType] `json:"type,required"`
}
func (ChatCompletionNewParamsTool) MarshalJSON ¶
func (r ChatCompletionNewParamsTool) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoice ¶
type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoice struct {
Function param.Field[ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceFunction] `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type param.Field[ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType] `json:"type,required"`
}
Specifies a tool the model should use. Use to force the model to call a specific function.
func (ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoice) MarshalJSON ¶
func (r ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoice) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceFunction ¶
type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceFunction struct {
// The name of the function to call.
Name param.Field[string] `json:"name,required"`
}
func (ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceFunction) MarshalJSON ¶
func (r ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceFunction) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType ¶
type ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType string
The type of the tool. Currently, only `function` is supported.
const (
ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceTypeFunction ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType = "function"
)
func (ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType) IsKnown ¶
func (r ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoiceType) IsKnown() bool
type ChatCompletionNewParamsToolChoiceString ¶
type ChatCompletionNewParamsToolChoiceString string
`none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools.
const ( ChatCompletionNewParamsToolChoiceStringNone ChatCompletionNewParamsToolChoiceString = "none" ChatCompletionNewParamsToolChoiceStringAuto ChatCompletionNewParamsToolChoiceString = "auto" ChatCompletionNewParamsToolChoiceStringRequired ChatCompletionNewParamsToolChoiceString = "required" )
func (ChatCompletionNewParamsToolChoiceString) IsKnown ¶
func (r ChatCompletionNewParamsToolChoiceString) IsKnown() bool
type ChatCompletionNewParamsToolChoiceUnion ¶
type ChatCompletionNewParamsToolChoiceUnion interface {
// contains filtered or unexported methods
}
Controls which (if any) tool is called by the model. `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools. Specifying a particular tool via `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
`none` is the default when no tools are present. `auto` is the default if tools are present.
Satisfied by ChatCompletionNewParamsToolChoiceString, ChatCompletionNewParamsToolChoiceChatCompletionNamedToolChoice.
type ChatCompletionNewParamsToolsFunction ¶
type ChatCompletionNewParamsToolsFunction struct {
// The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
// underscores and dashes, with a maximum length of 64.
Name param.Field[string] `json:"name,required"`
// A description of what the function does, used by the model to choose when and
// how to call the function.
Description param.Field[string] `json:"description"`
// The parameters the functions accepts, described as a JSON Schema object. See the
// docs on [tool use](/docs/tool-use) for examples, and the
// [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
// documentation about the format.
//
// Omitting `parameters` defines a function with an empty parameter list.
Parameters param.Field[map[string]interface{}] `json:"parameters"`
}
func (ChatCompletionNewParamsToolsFunction) MarshalJSON ¶
func (r ChatCompletionNewParamsToolsFunction) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsToolsType ¶
type ChatCompletionNewParamsToolsType string
The type of the tool. Currently, only `function` is supported.
const (
ChatCompletionNewParamsToolsTypeFunction ChatCompletionNewParamsToolsType = "function"
)
func (ChatCompletionNewParamsToolsType) IsKnown ¶
func (r ChatCompletionNewParamsToolsType) IsKnown() bool
type ChatCompletionNewResponse ¶
type ChatCompletionNewResponse struct {
// A unique identifier for the chat completion.
ID string `json:"id,required"`
// A list of chat completion choices. Can be more than one if `n` is greater
// than 1.
Choices []ChatCompletionNewResponseChoice `json:"choices,required"`
// The Unix timestamp (in seconds) of when the chat completion was created.
Created int64 `json:"created,required"`
// The model used for the chat completion.
Model string `json:"model,required"`
// The object type, which is always `chat.completion`.
Object ChatCompletionNewResponseObject `json:"object,required"`
// This fingerprint represents the backend configuration that the model runs with.
//
// Can be used in conjunction with the `seed` request parameter to understand when
// backend changes have been made that might impact determinism.
SystemFingerprint string `json:"system_fingerprint"`
// Usage statistics for the completion request.
Usage ChatCompletionNewResponseUsage `json:"usage"`
JSON chatCompletionNewResponseJSON `json:"-"`
}
Represents a chat completion response returned by model, based on the provided input.
func (*ChatCompletionNewResponse) UnmarshalJSON ¶
func (r *ChatCompletionNewResponse) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoice ¶
type ChatCompletionNewResponseChoice struct {
// The reason the model stopped generating tokens. This will be `stop` if the model
// hit a natural stop point or a provided stop sequence, `length` if the maximum
// number of tokens specified in the request was reached, `tool_calls` if the model
// called a tool, or `function_call` (deprecated) if the model called a function.
FinishReason ChatCompletionNewResponseChoicesFinishReason `json:"finish_reason,required"`
// The index of the choice in the list of choices.
Index int64 `json:"index,required"`
// Log probability information for the choice.
Logprobs ChatCompletionNewResponseChoicesLogprobs `json:"logprobs,required,nullable"`
// A chat completion message generated by the model.
Message ChatCompletionNewResponseChoicesMessage `json:"message,required"`
JSON chatCompletionNewResponseChoiceJSON `json:"-"`
}
func (*ChatCompletionNewResponseChoice) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoice) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesFinishReason ¶
type ChatCompletionNewResponseChoicesFinishReason string
The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence, `length` if the maximum number of tokens specified in the request was reached, `tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.
const ( ChatCompletionNewResponseChoicesFinishReasonStop ChatCompletionNewResponseChoicesFinishReason = "stop" ChatCompletionNewResponseChoicesFinishReasonLength ChatCompletionNewResponseChoicesFinishReason = "length" ChatCompletionNewResponseChoicesFinishReasonToolCalls ChatCompletionNewResponseChoicesFinishReason = "tool_calls" ChatCompletionNewResponseChoicesFinishReasonFunctionCall ChatCompletionNewResponseChoicesFinishReason = "function_call" )
func (ChatCompletionNewResponseChoicesFinishReason) IsKnown ¶
func (r ChatCompletionNewResponseChoicesFinishReason) IsKnown() bool
type ChatCompletionNewResponseChoicesLogprobs ¶
type ChatCompletionNewResponseChoicesLogprobs struct {
// A list of message content tokens with log probability information.
Content []ChatCompletionNewResponseChoicesLogprobsContent `json:"content,required,nullable"`
JSON chatCompletionNewResponseChoicesLogprobsJSON `json:"-"`
}
Log probability information for the choice.
func (*ChatCompletionNewResponseChoicesLogprobs) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesLogprobs) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesLogprobsContent ¶
type ChatCompletionNewResponseChoicesLogprobsContent struct {
// The token.
Token string `json:"token,required"`
// A list of integers representing the UTF-8 bytes representation of the token.
// Useful in instances where characters are represented by multiple tokens and
// their byte representations must be combined to generate the correct text
// representation. Can be `null` if there is no bytes representation for the token.
Bytes []int64 `json:"bytes,required,nullable"`
// The log probability of this token, if it is within the top 20 most likely
// tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
// unlikely.
Logprob float64 `json:"logprob,required"`
// List of the most likely tokens and their log probability, at this token
// position. In rare cases, there may be fewer than the number of requested
// `top_logprobs` returned.
TopLogprobs []ChatCompletionNewResponseChoicesLogprobsContentTopLogprob `json:"top_logprobs,required"`
JSON chatCompletionNewResponseChoicesLogprobsContentJSON `json:"-"`
}
func (*ChatCompletionNewResponseChoicesLogprobsContent) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesLogprobsContent) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesLogprobsContentTopLogprob ¶
type ChatCompletionNewResponseChoicesLogprobsContentTopLogprob struct {
// The token.
Token string `json:"token,required"`
// A list of integers representing the UTF-8 bytes representation of the token.
// Useful in instances where characters are represented by multiple tokens and
// their byte representations must be combined to generate the correct text
// representation. Can be `null` if there is no bytes representation for the token.
Bytes []int64 `json:"bytes,required,nullable"`
// The log probability of this token, if it is within the top 20 most likely
// tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
// unlikely.
Logprob float64 `json:"logprob,required"`
JSON chatCompletionNewResponseChoicesLogprobsContentTopLogprobJSON `json:"-"`
}
func (*ChatCompletionNewResponseChoicesLogprobsContentTopLogprob) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesLogprobsContentTopLogprob) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesMessage ¶
type ChatCompletionNewResponseChoicesMessage struct {
// The contents of the message.
Content string `json:"content,required,nullable"`
// The role of the author of this message.
Role ChatCompletionNewResponseChoicesMessageRole `json:"role,required"`
// Deprecated and replaced by `tool_calls`. The name and arguments of a function
// that should be called, as generated by the model.
FunctionCall ChatCompletionNewResponseChoicesMessageFunctionCall `json:"function_call"`
// The tool calls generated by the model, such as function calls.
ToolCalls []ChatCompletionNewResponseChoicesMessageToolCall `json:"tool_calls"`
JSON chatCompletionNewResponseChoicesMessageJSON `json:"-"`
}
A chat completion message generated by the model.
func (*ChatCompletionNewResponseChoicesMessage) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesMessage) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesMessageFunctionCall ¶
type ChatCompletionNewResponseChoicesMessageFunctionCall struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments string `json:"arguments,required"`
// The name of the function to call.
Name string `json:"name,required"`
JSON chatCompletionNewResponseChoicesMessageFunctionCallJSON `json:"-"`
}
Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.
func (*ChatCompletionNewResponseChoicesMessageFunctionCall) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesMessageFunctionCall) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesMessageRole ¶
type ChatCompletionNewResponseChoicesMessageRole string
The role of the author of this message.
const (
ChatCompletionNewResponseChoicesMessageRoleAssistant ChatCompletionNewResponseChoicesMessageRole = "assistant"
)
func (ChatCompletionNewResponseChoicesMessageRole) IsKnown ¶
func (r ChatCompletionNewResponseChoicesMessageRole) IsKnown() bool
type ChatCompletionNewResponseChoicesMessageToolCall ¶
type ChatCompletionNewResponseChoicesMessageToolCall struct {
// The ID of the tool call.
ID string `json:"id,required"`
// The function that the model called.
Function ChatCompletionNewResponseChoicesMessageToolCallsFunction `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type ChatCompletionNewResponseChoicesMessageToolCallsType `json:"type,required"`
JSON chatCompletionNewResponseChoicesMessageToolCallJSON `json:"-"`
}
func (*ChatCompletionNewResponseChoicesMessageToolCall) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesMessageToolCall) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesMessageToolCallsFunction ¶
type ChatCompletionNewResponseChoicesMessageToolCallsFunction struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments string `json:"arguments,required"`
// The name of the function to call.
Name string `json:"name,required"`
JSON chatCompletionNewResponseChoicesMessageToolCallsFunctionJSON `json:"-"`
}
The function that the model called.
func (*ChatCompletionNewResponseChoicesMessageToolCallsFunction) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseChoicesMessageToolCallsFunction) UnmarshalJSON(data []byte) (err error)
type ChatCompletionNewResponseChoicesMessageToolCallsType ¶
type ChatCompletionNewResponseChoicesMessageToolCallsType string
The type of the tool. Currently, only `function` is supported.
const (
ChatCompletionNewResponseChoicesMessageToolCallsTypeFunction ChatCompletionNewResponseChoicesMessageToolCallsType = "function"
)
func (ChatCompletionNewResponseChoicesMessageToolCallsType) IsKnown ¶
func (r ChatCompletionNewResponseChoicesMessageToolCallsType) IsKnown() bool
type ChatCompletionNewResponseObject ¶
type ChatCompletionNewResponseObject string
The object type, which is always `chat.completion`.
const (
ChatCompletionNewResponseObjectChatCompletion ChatCompletionNewResponseObject = "chat.completion"
)
func (ChatCompletionNewResponseObject) IsKnown ¶
func (r ChatCompletionNewResponseObject) IsKnown() bool
type ChatCompletionNewResponseUsage ¶
type ChatCompletionNewResponseUsage struct {
// Number of tokens in the generated completion.
CompletionTokens int64 `json:"completion_tokens,required"`
// Number of tokens in the prompt.
PromptTokens int64 `json:"prompt_tokens,required"`
// Total number of tokens used in the request (prompt + completion).
TotalTokens int64 `json:"total_tokens,required"`
// Time spent generating tokens
CompletionTime float64 `json:"completion_time"`
// Time spent processing input tokens
PromptTime float64 `json:"prompt_time"`
// Time the requests was spent queued
QueueTime float64 `json:"queue_time"`
// completion time and prompt time combined
TotalTime float64 `json:"total_time"`
JSON chatCompletionNewResponseUsageJSON `json:"-"`
}
Usage statistics for the completion request.
func (*ChatCompletionNewResponseUsage) UnmarshalJSON ¶
func (r *ChatCompletionNewResponseUsage) UnmarshalJSON(data []byte) (err error)
type ChatCompletionService ¶
type ChatCompletionService struct {
Options []option.RequestOption
}
ChatCompletionService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatCompletionService method instead.
func NewChatCompletionService ¶
func NewChatCompletionService(opts ...option.RequestOption) (r *ChatCompletionService)
NewChatCompletionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ChatCompletionService) New ¶
func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletionNewResponse, err error)
Creates a model response for the given chat conversation.
type ChatService ¶
type ChatService struct {
Options []option.RequestOption
Completions *ChatCompletionService
}
ChatService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewChatService method instead.
func NewChatService ¶
func NewChatService(opts ...option.RequestOption) (r *ChatService)
NewChatService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
type Client ¶
type Client struct {
Options []option.RequestOption
Audio *AudioService
Chat *ChatService
Embeddings *EmbeddingService
Models *ModelService
}
Client creates a struct with services and top level methods that help with interacting with the groq API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
NewClient generates a new client with the default option read from the environment (GROQ_BEARER_TOKEN). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Post ¶
func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type EmbeddingNewParams ¶
type EmbeddingNewParams struct {
// Input text to embed, encoded as a string or array of tokens. To embed multiple
// inputs in a single request, pass an array of strings or array of token arrays.
// The input must not exceed the max input tokens for the model, cannot be an empty
// string, and any array must be 2048 dimensions or less.
Input param.Field[EmbeddingNewParamsInputUnion] `json:"input,required"`
// ID of the model to use.
Model param.Field[EmbeddingNewParamsModel] `json:"model,required"`
// The format to return the embeddings in. Can only be `float` or `base64`.
EncodingFormat param.Field[EmbeddingNewParamsEncodingFormat] `json:"encoding_format"`
// A unique identifier representing your end-user, which can help us monitor and
// detect abuse.
User param.Field[string] `json:"user"`
}
func (EmbeddingNewParams) MarshalJSON ¶
func (r EmbeddingNewParams) MarshalJSON() (data []byte, err error)
type EmbeddingNewParamsEncodingFormat ¶
type EmbeddingNewParamsEncodingFormat string
The format to return the embeddings in. Can only be `float` or `base64`.
const ( EmbeddingNewParamsEncodingFormatFloat EmbeddingNewParamsEncodingFormat = "float" EmbeddingNewParamsEncodingFormatBase64 EmbeddingNewParamsEncodingFormat = "base64" )
func (EmbeddingNewParamsEncodingFormat) IsKnown ¶
func (r EmbeddingNewParamsEncodingFormat) IsKnown() bool
type EmbeddingNewParamsInputArray ¶
type EmbeddingNewParamsInputArray []string
func (EmbeddingNewParamsInputArray) ImplementsEmbeddingNewParamsInputUnion ¶
func (r EmbeddingNewParamsInputArray) ImplementsEmbeddingNewParamsInputUnion()
type EmbeddingNewParamsInputUnion ¶
type EmbeddingNewParamsInputUnion interface {
ImplementsEmbeddingNewParamsInputUnion()
}
Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model, cannot be an empty string, and any array must be 2048 dimensions or less.
Satisfied by shared.UnionString, EmbeddingNewParamsInputArray.
type EmbeddingNewParamsModel ¶
type EmbeddingNewParamsModel string
const (
EmbeddingNewParamsModelNomicEmbedTextV1_5 EmbeddingNewParamsModel = "nomic-embed-text-v1_5"
)
func (EmbeddingNewParamsModel) IsKnown ¶
func (r EmbeddingNewParamsModel) IsKnown() bool
type EmbeddingNewResponse ¶
type EmbeddingNewResponse struct {
// The list of embeddings generated by the model.
Data []EmbeddingNewResponseData `json:"data,required"`
// The name of the model used to generate the embedding.
Model string `json:"model,required"`
// The object type, which is always "list".
Object EmbeddingNewResponseObject `json:"object,required"`
// The usage information for the request.
Usage EmbeddingNewResponseUsage `json:"usage,required"`
JSON embeddingNewResponseJSON `json:"-"`
}
func (*EmbeddingNewResponse) UnmarshalJSON ¶
func (r *EmbeddingNewResponse) UnmarshalJSON(data []byte) (err error)
type EmbeddingNewResponseData ¶
type EmbeddingNewResponseData struct {
// The embedding vector, which is a list of floats. The length of vector depends on
// the model as listed in the [embedding guide](/docs/guides/embeddings).
Embedding EmbeddingNewResponseDataEmbeddingUnion `json:"embedding,required"`
// The index of the embedding in the list of embeddings.
Index int64 `json:"index,required"`
// The object type, which is always "embedding".
Object EmbeddingNewResponseDataObject `json:"object,required"`
JSON embeddingNewResponseDataJSON `json:"-"`
}
Represents an embedding vector returned by embedding endpoint.
func (*EmbeddingNewResponseData) UnmarshalJSON ¶
func (r *EmbeddingNewResponseData) UnmarshalJSON(data []byte) (err error)
type EmbeddingNewResponseDataEmbeddingArray ¶
type EmbeddingNewResponseDataEmbeddingArray []float64
func (EmbeddingNewResponseDataEmbeddingArray) ImplementsEmbeddingNewResponseDataEmbeddingUnion ¶
func (r EmbeddingNewResponseDataEmbeddingArray) ImplementsEmbeddingNewResponseDataEmbeddingUnion()
type EmbeddingNewResponseDataEmbeddingUnion ¶
type EmbeddingNewResponseDataEmbeddingUnion interface {
ImplementsEmbeddingNewResponseDataEmbeddingUnion()
}
The embedding vector, which is a list of floats. The length of vector depends on the model as listed in the [embedding guide](/docs/guides/embeddings).
Union satisfied by EmbeddingNewResponseDataEmbeddingArray or shared.UnionString.
type EmbeddingNewResponseDataObject ¶
type EmbeddingNewResponseDataObject string
The object type, which is always "embedding".
const (
EmbeddingNewResponseDataObjectEmbedding EmbeddingNewResponseDataObject = "embedding"
)
func (EmbeddingNewResponseDataObject) IsKnown ¶
func (r EmbeddingNewResponseDataObject) IsKnown() bool
type EmbeddingNewResponseObject ¶
type EmbeddingNewResponseObject string
The object type, which is always "list".
const (
EmbeddingNewResponseObjectList EmbeddingNewResponseObject = "list"
)
func (EmbeddingNewResponseObject) IsKnown ¶
func (r EmbeddingNewResponseObject) IsKnown() bool
type EmbeddingNewResponseUsage ¶
type EmbeddingNewResponseUsage struct {
// The number of tokens used by the prompt.
PromptTokens int64 `json:"prompt_tokens,required"`
// The total number of tokens used by the request.
TotalTokens int64 `json:"total_tokens,required"`
JSON embeddingNewResponseUsageJSON `json:"-"`
}
The usage information for the request.
func (*EmbeddingNewResponseUsage) UnmarshalJSON ¶
func (r *EmbeddingNewResponseUsage) UnmarshalJSON(data []byte) (err error)
type EmbeddingService ¶
type EmbeddingService struct {
Options []option.RequestOption
}
EmbeddingService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewEmbeddingService method instead.
func NewEmbeddingService ¶
func NewEmbeddingService(opts ...option.RequestOption) (r *EmbeddingService)
NewEmbeddingService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*EmbeddingService) New ¶
func (r *EmbeddingService) New(ctx context.Context, body EmbeddingNewParams, opts ...option.RequestOption) (res *EmbeddingNewResponse, err error)
Creates an embedding vector representing the input text.
type Model ¶ added in v0.9.0
type Model struct {
// The model identifier, which can be referenced in the API endpoints.
ID string `json:"id,required"`
// The Unix timestamp (in seconds) when the model was created.
Created int64 `json:"created,required"`
// The object type, which is always "model".
Object ModelObject `json:"object,required"`
// The organization that owns the model.
OwnedBy string `json:"owned_by,required"`
JSON modelJSON `json:"-"`
}
Describes an OpenAI model offering that can be used with the API.
func (*Model) UnmarshalJSON ¶
type ModelDeleteResponse ¶
type ModelDeleteResponse struct {
ID string `json:"id,required"`
Deleted bool `json:"deleted,required"`
Object string `json:"object,required"`
JSON modelDeleteResponseJSON `json:"-"`
}
func (*ModelDeleteResponse) UnmarshalJSON ¶
func (r *ModelDeleteResponse) UnmarshalJSON(data []byte) (err error)
type ModelListResponse ¶
type ModelListResponse struct {
Data []Model `json:"data,required"`
Object ModelListResponseObject `json:"object,required"`
JSON modelListResponseJSON `json:"-"`
}
func (*ModelListResponse) UnmarshalJSON ¶
func (r *ModelListResponse) UnmarshalJSON(data []byte) (err error)
type ModelListResponseObject ¶
type ModelListResponseObject string
const (
ModelListResponseObjectList ModelListResponseObject = "list"
)
func (ModelListResponseObject) IsKnown ¶
func (r ModelListResponseObject) IsKnown() bool
type ModelObject ¶
type ModelObject string
The object type, which is always "model".
const (
ModelObjectModel ModelObject = "model"
)
func (ModelObject) IsKnown ¶
func (r ModelObject) IsKnown() bool
type ModelService ¶
type ModelService struct {
Options []option.RequestOption
}
ModelService contains methods and other services that help with interacting with the groq API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewModelService method instead.
func NewModelService ¶
func NewModelService(opts ...option.RequestOption) (r *ModelService)
NewModelService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ModelService) Delete ¶
func (r *ModelService) Delete(ctx context.Context, model string, opts ...option.RequestOption) (res *ModelDeleteResponse, err error)
Delete a model
func (*ModelService) Get ¶
func (r *ModelService) Get(ctx context.Context, model string, opts ...option.RequestOption) (res *Model, err error)
Get a specific model
func (*ModelService) List ¶
func (r *ModelService) List(ctx context.Context, opts ...option.RequestOption) (res *ModelListResponse, err error)
get all available models