glopenai/chat
Types
Content part for assistant messages.
pub type AssistantContentPart {
AssistantTextPart(text: String)
AssistantRefusalPart(refusal: String)
}
Constructors
-
AssistantTextPart(text: String) -
AssistantRefusalPart(refusal: String)
pub type AssistantMessageContent {
AssistantTextContent(String)
AssistantPartsContent(List(AssistantContentPart))
}
Constructors
-
AssistantTextContent(String) -
AssistantPartsContent(List(AssistantContentPart))
pub type ChatChoice {
ChatChoice(
index: Int,
message: ChatCompletionResponseMessage,
finish_reason: option.Option(FinishReason),
)
}
Constructors
-
ChatChoice( index: Int, message: ChatCompletionResponseMessage, finish_reason: option.Option(FinishReason), )
pub type ChatChoiceStream {
ChatChoiceStream(
index: Int,
delta: ChatCompletionStreamDelta,
finish_reason: option.Option(FinishReason),
)
}
Constructors
-
ChatChoiceStream( index: Int, delta: ChatCompletionStreamDelta, finish_reason: option.Option(FinishReason), )
pub type ChatCompletionDeleted {
ChatCompletionDeleted(
object: String,
id: String,
deleted: Bool,
)
}
Constructors
-
ChatCompletionDeleted(object: String, id: String, deleted: Bool)
pub type ChatCompletionList {
ChatCompletionList(
object: String,
data: List(CreateChatCompletionResponse),
first_id: option.Option(String),
last_id: option.Option(String),
has_more: Bool,
)
}
Constructors
-
ChatCompletionList( object: String, data: List(CreateChatCompletionResponse), first_id: option.Option(String), last_id: option.Option(String), has_more: Bool, )
pub type ChatCompletionResponseMessage {
ChatCompletionResponseMessage(
role: Role,
content: option.Option(String),
refusal: option.Option(String),
tool_calls: option.Option(List(ToolCall)),
annotations: option.Option(List(ResponseMessageAnnotation)),
)
}
Constructors
-
ChatCompletionResponseMessage( role: Role, content: option.Option(String), refusal: option.Option(String), tool_calls: option.Option(List(ToolCall)), annotations: option.Option(List(ResponseMessageAnnotation)), )
pub type ChatCompletionStreamDelta {
ChatCompletionStreamDelta(
role: option.Option(Role),
content: option.Option(String),
refusal: option.Option(String),
tool_calls: option.Option(List(ToolCallChunk)),
)
}
Constructors
-
ChatCompletionStreamDelta( role: option.Option(Role), content: option.Option(String), refusal: option.Option(String), tool_calls: option.Option(List(ToolCallChunk)), )
pub type ChatCompletionStreamOptions {
ChatCompletionStreamOptions(
include_usage: option.Option(Bool),
include_obfuscation: option.Option(Bool),
)
}
Constructors
-
ChatCompletionStreamOptions( include_usage: option.Option(Bool), include_obfuscation: option.Option(Bool), )
pub type ChatCompletionTool {
FunctionTool(function: shared.FunctionObject)
}
Constructors
-
FunctionTool(function: shared.FunctionObject)
pub type ChatMessage {
DeveloperMessage(
content: DeveloperMessageContent,
name: option.Option(String),
)
SystemMessage(
content: SystemMessageContent,
name: option.Option(String),
)
UserMessage(
content: UserMessageContent,
name: option.Option(String),
)
AssistantMessage(
content: option.Option(AssistantMessageContent),
refusal: option.Option(String),
name: option.Option(String),
tool_calls: option.Option(List(ToolCall)),
)
ToolMessage(content: ToolMessageContent, tool_call_id: String)
}
Constructors
-
DeveloperMessage( content: DeveloperMessageContent, name: option.Option(String), ) -
SystemMessage( content: SystemMessageContent, name: option.Option(String), ) -
UserMessage( content: UserMessageContent, name: option.Option(String), ) -
AssistantMessage( content: option.Option(AssistantMessageContent), refusal: option.Option(String), name: option.Option(String), tool_calls: option.Option(List(ToolCall)), ) -
ToolMessage(content: ToolMessageContent, tool_call_id: String)
pub type CreateChatCompletionRequest {
CreateChatCompletionRequest(
model: String,
messages: List(ChatMessage),
temperature: option.Option(Float),
top_p: option.Option(Float),
n: option.Option(Int),
stream: option.Option(Bool),
stream_options: option.Option(ChatCompletionStreamOptions),
stop: option.Option(StopConfiguration),
max_completion_tokens: option.Option(Int),
frequency_penalty: option.Option(Float),
presence_penalty: option.Option(Float),
logprobs: option.Option(Bool),
top_logprobs: option.Option(Int),
response_format: option.Option(shared.ResponseFormat),
tools: option.Option(List(ChatCompletionTool)),
tool_choice: option.Option(ToolChoice),
parallel_tool_calls: option.Option(Bool),
reasoning_effort: option.Option(shared.ReasoningEffort),
modalities: option.Option(List(ResponseModality)),
verbosity: option.Option(Verbosity),
web_search_options: option.Option(WebSearchOptions),
store: option.Option(Bool),
metadata: option.Option(dict.Dict(String, String)),
service_tier: option.Option(ServiceTier),
safety_identifier: option.Option(String),
prompt_cache_key: option.Option(String),
)
}
Constructors
-
CreateChatCompletionRequest( model: String, messages: List(ChatMessage), temperature: option.Option(Float), top_p: option.Option(Float), n: option.Option(Int), stream: option.Option(Bool), stream_options: option.Option(ChatCompletionStreamOptions), stop: option.Option(StopConfiguration), max_completion_tokens: option.Option(Int), frequency_penalty: option.Option(Float), presence_penalty: option.Option(Float), logprobs: option.Option(Bool), top_logprobs: option.Option(Int), response_format: option.Option(shared.ResponseFormat), tools: option.Option(List(ChatCompletionTool)), tool_choice: option.Option(ToolChoice), parallel_tool_calls: option.Option(Bool), reasoning_effort: option.Option(shared.ReasoningEffort), modalities: option.Option(List(ResponseModality)), verbosity: option.Option(Verbosity), web_search_options: option.Option(WebSearchOptions), store: option.Option(Bool), metadata: option.Option(dict.Dict(String, String)), service_tier: option.Option(ServiceTier), safety_identifier: option.Option(String), prompt_cache_key: option.Option(String), )
pub type CreateChatCompletionResponse {
CreateChatCompletionResponse(
id: String,
object: String,
created: Int,
model: String,
choices: List(ChatChoice),
usage: option.Option(shared.CompletionUsage),
service_tier: option.Option(ServiceTier),
system_fingerprint: option.Option(String),
)
}
Constructors
-
CreateChatCompletionResponse( id: String, object: String, created: Int, model: String, choices: List(ChatChoice), usage: option.Option(shared.CompletionUsage), service_tier: option.Option(ServiceTier), system_fingerprint: option.Option(String), )
pub type CreateChatCompletionStreamResponse {
CreateChatCompletionStreamResponse(
id: String,
object: String,
created: Int,
model: String,
choices: List(ChatChoiceStream),
usage: option.Option(shared.CompletionUsage),
service_tier: option.Option(ServiceTier),
system_fingerprint: option.Option(String),
)
}
Constructors
-
CreateChatCompletionStreamResponse( id: String, object: String, created: Int, model: String, choices: List(ChatChoiceStream), usage: option.Option(shared.CompletionUsage), service_tier: option.Option(ServiceTier), system_fingerprint: option.Option(String), )
pub type DeveloperMessageContent {
DeveloperTextContent(String)
DeveloperPartsContent(List(String))
}
Constructors
-
DeveloperTextContent(String) -
DeveloperPartsContent(List(String))
pub type FileObject {
FileObject(
file_data: option.Option(String),
file_id: option.Option(String),
filename: option.Option(String),
)
}
Constructors
-
FileObject( file_data: option.Option(String), file_id: option.Option(String), filename: option.Option(String), )
pub type FinishReason {
Stop
Length
ToolCalls
ContentFilter
FunctionCallFinish
}
Constructors
-
Stop -
Length -
ToolCalls -
ContentFilter -
FunctionCallFinish
pub type FunctionCallStream {
FunctionCallStream(
name: option.Option(String),
arguments: option.Option(String),
)
}
Constructors
-
FunctionCallStream( name: option.Option(String), arguments: option.Option(String), )
pub type InputAudio {
InputAudio(data: String, format: InputAudioFormat)
}
Constructors
-
InputAudio(data: String, format: InputAudioFormat)
pub type InputAudioFormat {
Wav
Mp3
}
Constructors
-
Wav -
Mp3
pub type ResponseMessageAnnotation {
UrlCitationAnnotation(url_citation: UrlCitation)
}
Constructors
-
UrlCitationAnnotation(url_citation: UrlCitation)
pub type ResponseModality {
ModalityText
ModalityAudio
}
Constructors
-
ModalityText -
ModalityAudio
pub type Role {
RoleSystem
RoleUser
RoleAssistant
RoleTool
RoleDeveloper
}
Constructors
-
RoleSystem -
RoleUser -
RoleAssistant -
RoleTool -
RoleDeveloper
pub type ServiceTier {
ServiceTierAuto
ServiceTierDefault
ServiceTierFlex
ServiceTierScale
ServiceTierPriority
}
Constructors
-
ServiceTierAuto -
ServiceTierDefault -
ServiceTierFlex -
ServiceTierScale -
ServiceTierPriority
pub type StopConfiguration {
StopString(String)
StopStringArray(List(String))
}
Constructors
-
StopString(String) -
StopStringArray(List(String))
pub type SystemMessageContent {
SystemTextContent(String)
SystemPartsContent(List(String))
}
Constructors
-
SystemTextContent(String) -
SystemPartsContent(List(String))
The name and arguments of a tool call made by the model.
pub type ToolCall {
FunctionToolCall(id: String, function: shared.FunctionCall)
}
Constructors
-
FunctionToolCall(id: String, function: shared.FunctionCall)
pub type ToolCallChunk {
ToolCallChunk(
index: Int,
id: option.Option(String),
function: option.Option(FunctionCallStream),
)
}
Constructors
-
ToolCallChunk( index: Int, id: option.Option(String), function: option.Option(FunctionCallStream), )
Controls which tool the model calls.
pub type ToolChoice {
ToolChoiceModeChoice(ToolChoiceMode)
ToolChoiceFunctionChoice(function: shared.FunctionName)
}
Constructors
-
ToolChoiceModeChoice(ToolChoiceMode) -
ToolChoiceFunctionChoice(function: shared.FunctionName)
pub type ToolChoiceMode {
ToolChoiceNone
ToolChoiceAuto
ToolChoiceRequired
}
Constructors
-
ToolChoiceNone -
ToolChoiceAuto -
ToolChoiceRequired
pub type ToolMessageContent {
ToolTextContent(String)
ToolPartsContent(List(String))
}
Constructors
-
ToolTextContent(String) -
ToolPartsContent(List(String))
pub type UrlCitation {
UrlCitation(
start_index: Int,
end_index: Int,
title: String,
url: String,
)
}
Constructors
-
UrlCitation( start_index: Int, end_index: Int, title: String, url: String, )
Content part for user messages (tagged by “type”).
pub type UserContentPart {
UserTextPart(text: String)
UserImageUrlPart(image_url: shared.ImageUrl)
UserInputAudioPart(input_audio: InputAudio)
UserFilePart(file: FileObject)
}
Constructors
-
UserTextPart(text: String) -
UserImageUrlPart(image_url: shared.ImageUrl) -
UserInputAudioPart(input_audio: InputAudio) -
UserFilePart(file: FileObject)
pub type UserMessageContent {
UserTextContent(String)
UserPartsContent(List(UserContentPart))
}
Constructors
-
UserTextContent(String) -
UserPartsContent(List(UserContentPart))
pub type Verbosity {
VerbosityLow
VerbosityMedium
VerbosityHigh
}
Constructors
-
VerbosityLow -
VerbosityMedium -
VerbosityHigh
pub type WebSearchContextSize {
WebSearchLow
WebSearchMedium
WebSearchHigh
}
Constructors
-
WebSearchLow -
WebSearchMedium -
WebSearchHigh
pub type WebSearchLocation {
WebSearchLocation(
country: option.Option(String),
region: option.Option(String),
city: option.Option(String),
timezone: option.Option(String),
)
}
Constructors
-
WebSearchLocation( country: option.Option(String), region: option.Option(String), city: option.Option(String), timezone: option.Option(String), )
pub type WebSearchOptions {
WebSearchOptions(
search_context_size: option.Option(WebSearchContextSize),
user_location: option.Option(WebSearchUserLocation),
)
}
Constructors
-
WebSearchOptions( search_context_size: option.Option(WebSearchContextSize), user_location: option.Option(WebSearchUserLocation), )
pub type WebSearchUserLocation {
WebSearchUserLocation(approximate: WebSearchLocation)
}
Constructors
-
WebSearchUserLocation(approximate: WebSearchLocation)
Values
pub fn assistant_content_part_to_json(
part: AssistantContentPart,
) -> json.Json
pub fn assistant_message(text: String) -> ChatMessage
Create a simple assistant text message.
pub fn assistant_message_content_to_json(
content: AssistantMessageContent,
) -> json.Json
pub fn chat_choice_decoder() -> decode.Decoder(ChatChoice)
pub fn chat_choice_stream_decoder() -> decode.Decoder(
ChatChoiceStream,
)
pub fn chat_completion_response_message_decoder() -> decode.Decoder(
ChatCompletionResponseMessage,
)
pub fn chat_completion_stream_delta_decoder() -> decode.Decoder(
ChatCompletionStreamDelta,
)
pub fn chat_completion_tool_to_json(
tool: ChatCompletionTool,
) -> json.Json
pub fn chat_message_to_json(message: ChatMessage) -> json.Json
pub fn create_chat_completion_request_to_json(
request: CreateChatCompletionRequest,
) -> json.Json
pub fn create_chat_completion_response_decoder() -> decode.Decoder(
CreateChatCompletionResponse,
)
pub fn create_chat_completion_stream_response_decoder() -> decode.Decoder(
CreateChatCompletionStreamResponse,
)
pub fn create_request(
config: config.Config,
params: CreateChatCompletionRequest,
) -> request.Request(String)
Build a request to create a chat completion.
pub fn create_response(
response: response.Response(String),
) -> Result(CreateChatCompletionResponse, error.GlopenaiError)
Parse the response from creating a chat completion.
pub fn delete_request(
config: config.Config,
completion_id: String,
) -> request.Request(String)
Build a request to delete a stored chat completion.
pub fn delete_response(
response: response.Response(String),
) -> Result(ChatCompletionDeleted, error.GlopenaiError)
Parse the response from deleting a chat completion.
pub fn developer_message(text: String) -> ChatMessage
Create a simple developer text message.
pub fn developer_message_content_to_json(
content: DeveloperMessageContent,
) -> json.Json
pub fn file_object_to_json(file: FileObject) -> json.Json
pub fn finish_reason_decoder() -> decode.Decoder(FinishReason)
pub fn finish_reason_to_json(reason: FinishReason) -> json.Json
pub fn function_call_stream_decoder() -> decode.Decoder(
FunctionCallStream,
)
pub fn input_audio_format_to_json(
format: InputAudioFormat,
) -> json.Json
pub fn input_audio_to_json(audio: InputAudio) -> json.Json
pub fn list_request(
config: config.Config,
) -> request.Request(String)
Build a request to list stored chat completions.
pub fn list_response(
response: response.Response(String),
) -> Result(ChatCompletionList, error.GlopenaiError)
Parse the response from listing chat completions.
pub fn new_create_request(
model model: String,
messages messages: List(ChatMessage),
) -> CreateChatCompletionRequest
Create a new chat completion request with required fields.
pub fn parse_stream_chunk(
data: String,
) -> Result(
option.Option(CreateChatCompletionStreamResponse),
error.GlopenaiError,
)
Parse a single SSE data line into a stream chunk.
Returns Ok(Some(chunk)) for data, Ok(None) for the [DONE] sentinel.
pub fn response_message_annotation_decoder() -> decode.Decoder(
ResponseMessageAnnotation,
)
pub fn response_modality_to_json(
m: ResponseModality,
) -> json.Json
pub fn retrieve_request(
config: config.Config,
completion_id: String,
) -> request.Request(String)
Build a request to retrieve a stored chat completion.
pub fn retrieve_response(
response: response.Response(String),
) -> Result(CreateChatCompletionResponse, error.GlopenaiError)
Parse the response from retrieving a chat completion.
pub fn role_decoder() -> decode.Decoder(Role)
pub fn service_tier_decoder() -> decode.Decoder(ServiceTier)
pub fn service_tier_to_json(tier: ServiceTier) -> json.Json
pub fn stop_configuration_to_json(
stop: StopConfiguration,
) -> json.Json
pub fn stream_options_to_json(
opts: ChatCompletionStreamOptions,
) -> json.Json
pub fn system_message(text: String) -> ChatMessage
Create a simple system text message.
pub fn system_message_content_to_json(
content: SystemMessageContent,
) -> json.Json
pub fn tool_call_chunk_decoder() -> decode.Decoder(ToolCallChunk)
pub fn tool_call_decoder() -> decode.Decoder(ToolCall)
pub fn tool_choice_mode_to_json(
mode: ToolChoiceMode,
) -> json.Json
pub fn tool_choice_to_json(choice: ToolChoice) -> json.Json
pub fn tool_message(
content: String,
tool_call_id: String,
) -> ChatMessage
Create a tool result message.
pub fn tool_message_content_to_json(
content: ToolMessageContent,
) -> json.Json
pub fn url_citation_decoder() -> decode.Decoder(UrlCitation)
pub fn user_content_part_to_json(
part: UserContentPart,
) -> json.Json
pub fn user_message(text: String) -> ChatMessage
Create a simple user text message.
pub fn user_message_content_to_json(
content: UserMessageContent,
) -> json.Json
pub fn web_search_context_size_to_json(
size: WebSearchContextSize,
) -> json.Json
pub fn web_search_options_to_json(
opts: WebSearchOptions,
) -> json.Json
pub fn with_max_completion_tokens(
request: CreateChatCompletionRequest,
max_tokens: Int,
) -> CreateChatCompletionRequest
pub fn with_metadata(
request: CreateChatCompletionRequest,
metadata: dict.Dict(String, String),
) -> CreateChatCompletionRequest
pub fn with_n(
request: CreateChatCompletionRequest,
n: Int,
) -> CreateChatCompletionRequest
pub fn with_reasoning_effort(
request: CreateChatCompletionRequest,
effort: shared.ReasoningEffort,
) -> CreateChatCompletionRequest
pub fn with_response_format(
request: CreateChatCompletionRequest,
format: shared.ResponseFormat,
) -> CreateChatCompletionRequest
pub fn with_service_tier(
request: CreateChatCompletionRequest,
tier: ServiceTier,
) -> CreateChatCompletionRequest
pub fn with_stop(
request: CreateChatCompletionRequest,
stop: StopConfiguration,
) -> CreateChatCompletionRequest
pub fn with_store(
request: CreateChatCompletionRequest,
store: Bool,
) -> CreateChatCompletionRequest
pub fn with_stream(
request: CreateChatCompletionRequest,
stream: Bool,
) -> CreateChatCompletionRequest
pub fn with_temperature(
request: CreateChatCompletionRequest,
temperature: Float,
) -> CreateChatCompletionRequest
pub fn with_tool_choice(
request: CreateChatCompletionRequest,
choice: ToolChoice,
) -> CreateChatCompletionRequest
pub fn with_tools(
request: CreateChatCompletionRequest,
tools: List(ChatCompletionTool),
) -> CreateChatCompletionRequest
pub fn with_top_p(
request: CreateChatCompletionRequest,
top_p: Float,
) -> CreateChatCompletionRequest
pub fn with_web_search_options(
request: CreateChatCompletionRequest,
options: WebSearchOptions,
) -> CreateChatCompletionRequest