gopenai/chat
Types
pub type ChatError {
DynamicError(dynamic.Dynamic)
JsonDecodeError(json.DecodeError)
BadRequestError(error: CompletionError)
}
Constructors
-
DynamicError(dynamic.Dynamic)
-
JsonDecodeError(json.DecodeError)
-
BadRequestError(error: CompletionError)
pub type Choice {
Choice(
finish_reason: FinishReason,
index: Int,
message: Message,
)
}
Constructors
-
Choice(finish_reason: FinishReason, index: Int, message: Message)
pub type CompletionError {
CompletionError(
message: String,
error_type: String,
param: String,
code: String,
)
}
Constructors
-
CompletionError( message: String, error_type: String, param: String, code: String, )
pub type CompletionResponse {
CompletionResponse(
id: String,
choices: List(Choice),
created: Int,
model: String,
object: String,
usage: Usage,
)
}
Constructors
-
CompletionResponse( id: String, choices: List(Choice), created: Int, model: String, object: String, usage: Usage, )
pub type FinishReason {
Stop
Length
ContentFilter
ToolCalls
FunctionCall
}
Constructors
-
Stop
-
Length
-
ContentFilter
-
ToolCalls
-
FunctionCall
pub type Message {
SystemMessage(content: String, name: Option(String))
UserMessage(content: String, name: Option(String))
AssistantMessage(
content: Option(String),
name: Option(String),
tool_calls: Option(List(tool.ToolCall)),
)
ToolMessage(content: String, tool_call_id: String)
}
Constructors
-
SystemMessage(content: String, name: Option(String))
-
UserMessage(content: String, name: Option(String))
-
AssistantMessage( content: Option(String), name: Option(String), tool_calls: Option(List(tool.ToolCall)), )
-
ToolMessage(content: String, tool_call_id: String)
pub type Request {
Request(
model: Model,
messages: List(Message),
temperature: Float,
tools: Option(List(tool.Tool)),
)
}
Constructors
-
Request( model: Model, messages: List(Message), temperature: Float, tools: Option(List(tool.Tool)), )
pub type Role {
System
Assistant
User
Tool
Function
}
Constructors
-
System
-
Assistant
-
User
-
Tool
-
Function
pub type Usage {
Usage(
completion_tokens: Int,
prompt_tokens: Int,
total_tokens: Int,
)
}
Constructors
-
Usage( completion_tokens: Int, prompt_tokens: Int, total_tokens: Int, )
Functions
pub fn completion(
client: Client,
req: Request,
) -> Result(CompletionResponse, ChatError)
pub fn completion_from_json(
data: String,
) -> Result(CompletionResponse, DecodeError)
pub fn request_to_json(req: Request) -> String
pub fn role_decoder(
from data: Dynamic,
) -> Result(Role, List(DecodeError))