Current section
Files
Jump to
Current section
Files
src/glopenai@chatkit.erl
-module(glopenai@chatkit).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glopenai/chatkit.gleam").
-export([chat_session_status_to_json/1, chat_session_status_decoder/0, chatkit_workflow_tracing_to_json/1, chatkit_workflow_tracing_decoder/0, chatkit_workflow_to_json/1, chatkit_workflow_decoder/0, chat_session_rate_limits_decoder/0, chat_session_resource_decoder/0, new_workflow_tracing_param/0, workflow_tracing_param_to_json/1, new_workflow_param/1, workflow_param_with_version/2, workflow_param_with_state_variables/2, workflow_param_with_tracing/2, workflow_param_to_json/1, new_expires_after_param/1, expires_after_param_to_json/1, rate_limits_param_to_json/1, automatic_thread_titling_param_to_json/1, file_upload_param_to_json/1, history_param_to_json/1, chatkit_configuration_param_to_json/1, new_create_chat_session_body/2, with_expires_after/2, with_rate_limits/2, with_chatkit_configuration/2, create_chat_session_body_to_json/1, thread_status_decoder/0, annotation_decoder/0, thread_item_decoder/0, thread_resource_decoder/0, empty_list_threads_query/0, empty_list_thread_items_query/0, session_create_request/2, session_create_response/1, session_cancel_request/2, session_cancel_response/1, thread_list_request/1, thread_list_request_with_query/2, thread_list_response/1, thread_retrieve_request/2, thread_retrieve_response/1, thread_delete_request/2, thread_delete_response/1, thread_items_list_request/2, thread_items_list_request_with_query/3, thread_items_list_response/1]).
-export_type([chat_session_status/0, chatkit_workflow_tracing/0, chatkit_workflow/0, chat_session_rate_limits/0, chat_session_automatic_thread_titling/0, chat_session_file_upload/0, chat_session_history/0, chat_session_chatkit_configuration/0, chat_session_resource/0, workflow_tracing_param/0, workflow_param/0, expires_after_param/0, rate_limits_param/0, automatic_thread_titling_param/0, file_upload_param/0, history_param/0, chatkit_configuration_param/0, create_chat_session_body/0, thread_status/0, file_annotation_source/0, url_annotation_source/0, annotation/0, response_output_text/0, attachment_type/0, attachment/0, tool_choice/0, inference_options/0, user_message_content/0, task_type/0, task_group_task/0, client_tool_call_status/0, thread_item/0, thread_resource/0, thread_list_resource/0, deleted_thread_resource/0, thread_item_list_resource/0, list_chat_kit_threads_order/0, list_chat_kit_threads_query/0, list_chat_kit_thread_items_order/0, list_chat_kit_thread_items_query/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type chat_session_status() :: session_active |
session_expired |
session_cancelled.
-type chatkit_workflow_tracing() :: {chatkit_workflow_tracing, boolean()}.
-type chatkit_workflow() :: {chatkit_workflow,
binary(),
gleam@option:option(binary()),
gleam@option:option(gleam@dict:dict(binary(), gleam@dynamic:dynamic_())),
chatkit_workflow_tracing()}.
-type chat_session_rate_limits() :: {chat_session_rate_limits, integer()}.
-type chat_session_automatic_thread_titling() :: {chat_session_automatic_thread_titling,
boolean()}.
-type chat_session_file_upload() :: {chat_session_file_upload,
boolean(),
gleam@option:option(integer()),
gleam@option:option(integer())}.
-type chat_session_history() :: {chat_session_history,
boolean(),
gleam@option:option(integer())}.
-type chat_session_chatkit_configuration() :: {chat_session_chatkit_configuration,
chat_session_automatic_thread_titling(),
chat_session_file_upload(),
chat_session_history()}.
-type chat_session_resource() :: {chat_session_resource,
binary(),
binary(),
integer(),
binary(),
chatkit_workflow(),
binary(),
chat_session_rate_limits(),
integer(),
chat_session_status(),
chat_session_chatkit_configuration()}.
-type workflow_tracing_param() :: {workflow_tracing_param,
gleam@option:option(boolean())}.
-type workflow_param() :: {workflow_param,
binary(),
gleam@option:option(binary()),
gleam@option:option(gleam@dict:dict(binary(), gleam@dynamic:dynamic_())),
gleam@option:option(workflow_tracing_param())}.
-type expires_after_param() :: {expires_after_param, binary(), integer()}.
-type rate_limits_param() :: {rate_limits_param, gleam@option:option(integer())}.
-type automatic_thread_titling_param() :: {automatic_thread_titling_param,
gleam@option:option(boolean())}.
-type file_upload_param() :: {file_upload_param,
gleam@option:option(boolean()),
gleam@option:option(integer()),
gleam@option:option(integer())}.
-type history_param() :: {history_param,
gleam@option:option(boolean()),
gleam@option:option(integer())}.
-type chatkit_configuration_param() :: {chatkit_configuration_param,
gleam@option:option(automatic_thread_titling_param()),
gleam@option:option(file_upload_param()),
gleam@option:option(history_param())}.
-type create_chat_session_body() :: {create_chat_session_body,
workflow_param(),
binary(),
gleam@option:option(expires_after_param()),
gleam@option:option(rate_limits_param()),
gleam@option:option(chatkit_configuration_param())}.
-type thread_status() :: thread_active |
{thread_locked, gleam@option:option(binary())} |
{thread_closed, gleam@option:option(binary())}.
-type file_annotation_source() :: {file_annotation_source, binary()}.
-type url_annotation_source() :: {url_annotation_source, binary()}.
-type annotation() :: {file_annotation, file_annotation_source()} |
{url_annotation, url_annotation_source()}.
-type response_output_text() :: {response_output_text,
binary(),
binary(),
list(annotation())}.
-type attachment_type() :: attachment_image | attachment_file.
-type attachment() :: {attachment,
attachment_type(),
binary(),
binary(),
binary(),
gleam@option:option(binary())}.
-type tool_choice() :: {tool_choice, binary()}.
-type inference_options() :: {inference_options,
gleam@option:option(tool_choice()),
gleam@option:option(binary())}.
-type user_message_content() :: {input_text_content, binary()} |
{quoted_text_content, binary()}.
-type task_type() :: task_custom | task_thought.
-type task_group_task() :: {task_group_task,
task_type(),
gleam@option:option(binary()),
gleam@option:option(binary())}.
-type client_tool_call_status() :: client_tool_in_progress |
client_tool_completed.
-type thread_item() :: {user_message_item,
binary(),
binary(),
integer(),
binary(),
list(user_message_content()),
list(attachment()),
gleam@option:option(inference_options())} |
{assistant_message_item,
binary(),
binary(),
integer(),
binary(),
list(response_output_text())} |
{widget_message_item, binary(), binary(), integer(), binary(), binary()} |
{client_tool_call_item,
binary(),
binary(),
integer(),
binary(),
client_tool_call_status(),
binary(),
binary(),
binary(),
gleam@option:option(binary())} |
{task_item,
binary(),
binary(),
integer(),
binary(),
task_type(),
gleam@option:option(binary()),
gleam@option:option(binary())} |
{task_group_item,
binary(),
binary(),
integer(),
binary(),
list(task_group_task())}.
-type thread_resource() :: {thread_resource,
binary(),
binary(),
integer(),
gleam@option:option(binary()),
thread_status(),
binary(),
gleam@option:option(thread_item_list_resource())}.
-type thread_list_resource() :: {thread_list_resource,
binary(),
list(thread_resource()),
gleam@option:option(binary()),
gleam@option:option(binary()),
boolean()}.
-type deleted_thread_resource() :: {deleted_thread_resource,
binary(),
binary(),
boolean()}.
-type thread_item_list_resource() :: {thread_item_list_resource,
binary(),
list(thread_item()),
gleam@option:option(binary()),
gleam@option:option(binary()),
boolean()}.
-type list_chat_kit_threads_order() :: threads_asc | threads_desc.
-type list_chat_kit_threads_query() :: {list_chat_kit_threads_query,
gleam@option:option(integer()),
gleam@option:option(list_chat_kit_threads_order()),
gleam@option:option(binary()),
gleam@option:option(binary()),
gleam@option:option(binary())}.
-type list_chat_kit_thread_items_order() :: items_asc | items_desc.
-type list_chat_kit_thread_items_query() :: {list_chat_kit_thread_items_query,
gleam@option:option(integer()),
gleam@option:option(list_chat_kit_thread_items_order()),
gleam@option:option(binary()),
gleam@option:option(binary())}.
-file("src/glopenai/chatkit.gleam", 35).
-spec chat_session_status_to_json(chat_session_status()) -> gleam@json:json().
chat_session_status_to_json(Status) ->
gleam@json:string(case Status of
session_active ->
<<"active"/utf8>>;
session_expired ->
<<"expired"/utf8>>;
session_cancelled ->
<<"cancelled"/utf8>>
end).
-file("src/glopenai/chatkit.gleam", 43).
-spec chat_session_status_decoder() -> gleam@dynamic@decode:decoder(chat_session_status()).
chat_session_status_decoder() ->
gleam@dynamic@decode:then(
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Value) -> case Value of
<<"active"/utf8>> ->
gleam@dynamic@decode:success(session_active);
<<"expired"/utf8>> ->
gleam@dynamic@decode:success(session_expired);
<<"cancelled"/utf8>> ->
gleam@dynamic@decode:success(session_cancelled);
_ ->
gleam@dynamic@decode:failure(
session_active,
<<"ChatSessionStatus"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 57).
-spec chatkit_workflow_tracing_to_json(chatkit_workflow_tracing()) -> gleam@json:json().
chatkit_workflow_tracing_to_json(Tracing) ->
gleam@json:object(
[{<<"enabled"/utf8>>, gleam@json:bool(erlang:element(2, Tracing))}]
).
-file("src/glopenai/chatkit.gleam", 63).
-spec chatkit_workflow_tracing_decoder() -> gleam@dynamic@decode:decoder(chatkit_workflow_tracing()).
chatkit_workflow_tracing_decoder() ->
gleam@dynamic@decode:field(
<<"enabled"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Enabled) ->
gleam@dynamic@decode:success({chatkit_workflow_tracing, Enabled})
end
).
-file("src/glopenai/chatkit.gleam", 97).
-spec state_variables_to_json(
gleam@dict:dict(binary(), gleam@dynamic:dynamic_())
) -> gleam@json:json().
state_variables_to_json(Vars) ->
gleam@json:object(
begin
_pipe = maps:to_list(Vars),
gleam@list:map(
_pipe,
fun(Pair) ->
{erlang:element(1, Pair),
glopenai_codec_ffi:dynamic_to_json(
erlang:element(2, Pair)
)}
end
)
end
).
-file("src/glopenai/chatkit.gleam", 80).
-spec chatkit_workflow_to_json(chatkit_workflow()) -> gleam@json:json().
chatkit_workflow_to_json(Workflow) ->
glopenai@internal@codec:object_with_optional(
[{<<"id"/utf8>>, gleam@json:string(erlang:element(2, Workflow))},
{<<"tracing"/utf8>>,
chatkit_workflow_tracing_to_json(erlang:element(5, Workflow))}],
[glopenai@internal@codec:optional_field(
<<"version"/utf8>>,
erlang:element(3, Workflow),
fun gleam@json:string/1
),
glopenai@internal@codec:optional_field(
<<"state_variables"/utf8>>,
erlang:element(4, Workflow),
fun state_variables_to_json/1
)]
).
-file("src/glopenai/chatkit.gleam", 104).
-spec chatkit_workflow_decoder() -> gleam@dynamic@decode:decoder(chatkit_workflow()).
chatkit_workflow_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:optional_field(
<<"version"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Version) ->
gleam@dynamic@decode:optional_field(
<<"state_variables"/utf8>>,
none,
gleam@dynamic@decode:optional(
gleam@dynamic@decode:dict(
{decoder,
fun gleam@dynamic@decode:decode_string/1},
{decoder,
fun gleam@dynamic@decode:decode_dynamic/1}
)
),
fun(State_variables) ->
gleam@dynamic@decode:field(
<<"tracing"/utf8>>,
chatkit_workflow_tracing_decoder(),
fun(Tracing) ->
gleam@dynamic@decode:success(
{chatkit_workflow,
Id,
Version,
State_variables,
Tracing}
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 129).
-spec chat_session_rate_limits_decoder() -> gleam@dynamic@decode:decoder(chat_session_rate_limits()).
chat_session_rate_limits_decoder() ->
gleam@dynamic@decode:field(
<<"max_requests_per_1_minute"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Max_requests) ->
gleam@dynamic@decode:success(
{chat_session_rate_limits, Max_requests}
)
end
).
-file("src/glopenai/chatkit.gleam", 140).
-spec chat_session_automatic_thread_titling_decoder() -> gleam@dynamic@decode:decoder(chat_session_automatic_thread_titling()).
chat_session_automatic_thread_titling_decoder() ->
gleam@dynamic@decode:field(
<<"enabled"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Enabled) ->
gleam@dynamic@decode:success(
{chat_session_automatic_thread_titling, Enabled}
)
end
).
-file("src/glopenai/chatkit.gleam", 155).
-spec chat_session_file_upload_decoder() -> gleam@dynamic@decode:decoder(chat_session_file_upload()).
chat_session_file_upload_decoder() ->
gleam@dynamic@decode:field(
<<"enabled"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Enabled) ->
gleam@dynamic@decode:optional_field(
<<"max_file_size"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_int/1}
),
fun(Max_file_size) ->
gleam@dynamic@decode:optional_field(
<<"max_files"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_int/1}
),
fun(Max_files) ->
gleam@dynamic@decode:success(
{chat_session_file_upload,
Enabled,
Max_file_size,
Max_files}
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 178).
-spec chat_session_history_decoder() -> gleam@dynamic@decode:decoder(chat_session_history()).
chat_session_history_decoder() ->
gleam@dynamic@decode:field(
<<"enabled"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Enabled) ->
gleam@dynamic@decode:optional_field(
<<"recent_threads"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_int/1}
),
fun(Recent_threads) ->
gleam@dynamic@decode:success(
{chat_session_history, Enabled, Recent_threads}
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 199).
-spec chat_session_chatkit_configuration_decoder() -> gleam@dynamic@decode:decoder(chat_session_chatkit_configuration()).
chat_session_chatkit_configuration_decoder() ->
gleam@dynamic@decode:field(
<<"automatic_thread_titling"/utf8>>,
chat_session_automatic_thread_titling_decoder(),
fun(Automatic) ->
gleam@dynamic@decode:field(
<<"file_upload"/utf8>>,
chat_session_file_upload_decoder(),
fun(File_upload) ->
gleam@dynamic@decode:field(
<<"history"/utf8>>,
chat_session_history_decoder(),
fun(History) ->
gleam@dynamic@decode:success(
{chat_session_chatkit_configuration,
Automatic,
File_upload,
History}
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 233).
-spec chat_session_resource_decoder() -> gleam@dynamic@decode:decoder(chat_session_resource()).
chat_session_resource_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:optional_field(
<<"object"/utf8>>,
<<"chatkit.session"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Object) ->
gleam@dynamic@decode:field(
<<"expires_at"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Expires_at) ->
gleam@dynamic@decode:field(
<<"client_secret"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Client_secret) ->
gleam@dynamic@decode:field(
<<"workflow"/utf8>>,
chatkit_workflow_decoder(),
fun(Workflow) ->
gleam@dynamic@decode:field(
<<"user"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(User) ->
gleam@dynamic@decode:field(
<<"rate_limits"/utf8>>,
chat_session_rate_limits_decoder(
),
fun(Rate_limits) ->
gleam@dynamic@decode:field(
<<"max_requests_per_1_minute"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_int/1},
fun(
Max_requests
) ->
gleam@dynamic@decode:field(
<<"status"/utf8>>,
chat_session_status_decoder(
),
fun(
Status
) ->
gleam@dynamic@decode:field(
<<"chatkit_configuration"/utf8>>,
chat_session_chatkit_configuration_decoder(
),
fun(
Configuration
) ->
gleam@dynamic@decode:success(
{chat_session_resource,
Id,
Object,
Expires_at,
Client_secret,
Workflow,
User,
Rate_limits,
Max_requests,
Status,
Configuration}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 274).
-spec new_workflow_tracing_param() -> workflow_tracing_param().
new_workflow_tracing_param() ->
{workflow_tracing_param, none}.
-file("src/glopenai/chatkit.gleam", 278).
-spec workflow_tracing_param_to_json(workflow_tracing_param()) -> gleam@json:json().
workflow_tracing_param_to_json(Tracing) ->
glopenai@internal@codec:object_with_optional(
[],
[glopenai@internal@codec:optional_field(
<<"enabled"/utf8>>,
erlang:element(2, Tracing),
fun gleam@json:bool/1
)]
).
-file("src/glopenai/chatkit.gleam", 295).
-spec new_workflow_param(binary()) -> workflow_param().
new_workflow_param(Id) ->
{workflow_param, Id, none, none, none}.
-file("src/glopenai/chatkit.gleam", 299).
-spec workflow_param_with_version(workflow_param(), binary()) -> workflow_param().
workflow_param_with_version(Workflow, Version) ->
{workflow_param,
erlang:element(2, Workflow),
{some, Version},
erlang:element(4, Workflow),
erlang:element(5, Workflow)}.
-file("src/glopenai/chatkit.gleam", 306).
-spec workflow_param_with_state_variables(
workflow_param(),
gleam@dict:dict(binary(), gleam@dynamic:dynamic_())
) -> workflow_param().
workflow_param_with_state_variables(Workflow, State_variables) ->
{workflow_param,
erlang:element(2, Workflow),
erlang:element(3, Workflow),
{some, State_variables},
erlang:element(5, Workflow)}.
-file("src/glopenai/chatkit.gleam", 313).
-spec workflow_param_with_tracing(workflow_param(), workflow_tracing_param()) -> workflow_param().
workflow_param_with_tracing(Workflow, Tracing) ->
{workflow_param,
erlang:element(2, Workflow),
erlang:element(3, Workflow),
erlang:element(4, Workflow),
{some, Tracing}}.
-file("src/glopenai/chatkit.gleam", 320).
-spec workflow_param_to_json(workflow_param()) -> gleam@json:json().
workflow_param_to_json(Workflow) ->
glopenai@internal@codec:object_with_optional(
[{<<"id"/utf8>>, gleam@json:string(erlang:element(2, Workflow))}],
[glopenai@internal@codec:optional_field(
<<"version"/utf8>>,
erlang:element(3, Workflow),
fun gleam@json:string/1
),
glopenai@internal@codec:optional_field(
<<"state_variables"/utf8>>,
erlang:element(4, Workflow),
fun state_variables_to_json/1
),
glopenai@internal@codec:optional_field(
<<"tracing"/utf8>>,
erlang:element(5, Workflow),
fun workflow_tracing_param_to_json/1
)]
).
-file("src/glopenai/chatkit.gleam", 341).
?DOC(" Default anchor `\"created_at\"`.\n").
-spec new_expires_after_param(integer()) -> expires_after_param().
new_expires_after_param(Seconds) ->
{expires_after_param, <<"created_at"/utf8>>, Seconds}.
-file("src/glopenai/chatkit.gleam", 345).
-spec expires_after_param_to_json(expires_after_param()) -> gleam@json:json().
expires_after_param_to_json(Expires) ->
gleam@json:object(
[{<<"anchor"/utf8>>, gleam@json:string(erlang:element(2, Expires))},
{<<"seconds"/utf8>>, gleam@json:int(erlang:element(3, Expires))}]
).
-file("src/glopenai/chatkit.gleam", 356).
-spec rate_limits_param_to_json(rate_limits_param()) -> gleam@json:json().
rate_limits_param_to_json(Rate_limits) ->
glopenai@internal@codec:object_with_optional(
[],
[glopenai@internal@codec:optional_field(
<<"max_requests_per_1_minute"/utf8>>,
erlang:element(2, Rate_limits),
fun gleam@json:int/1
)]
).
-file("src/glopenai/chatkit.gleam", 370).
-spec automatic_thread_titling_param_to_json(automatic_thread_titling_param()) -> gleam@json:json().
automatic_thread_titling_param_to_json(Param) ->
glopenai@internal@codec:object_with_optional(
[],
[glopenai@internal@codec:optional_field(
<<"enabled"/utf8>>,
erlang:element(2, Param),
fun gleam@json:bool/1
)]
).
-file("src/glopenai/chatkit.gleam", 386).
-spec file_upload_param_to_json(file_upload_param()) -> gleam@json:json().
file_upload_param_to_json(Param) ->
glopenai@internal@codec:object_with_optional(
[],
[glopenai@internal@codec:optional_field(
<<"enabled"/utf8>>,
erlang:element(2, Param),
fun gleam@json:bool/1
),
glopenai@internal@codec:optional_field(
<<"max_file_size"/utf8>>,
erlang:element(3, Param),
fun gleam@json:int/1
),
glopenai@internal@codec:optional_field(
<<"max_files"/utf8>>,
erlang:element(4, Param),
fun gleam@json:int/1
)]
).
-file("src/glopenai/chatkit.gleam", 398).
-spec history_param_to_json(history_param()) -> gleam@json:json().
history_param_to_json(Param) ->
glopenai@internal@codec:object_with_optional(
[],
[glopenai@internal@codec:optional_field(
<<"enabled"/utf8>>,
erlang:element(2, Param),
fun gleam@json:bool/1
),
glopenai@internal@codec:optional_field(
<<"recent_threads"/utf8>>,
erlang:element(3, Param),
fun gleam@json:int/1
)]
).
-file("src/glopenai/chatkit.gleam", 413).
-spec chatkit_configuration_param_to_json(chatkit_configuration_param()) -> gleam@json:json().
chatkit_configuration_param_to_json(Config) ->
glopenai@internal@codec:object_with_optional(
[],
[glopenai@internal@codec:optional_field(
<<"automatic_thread_titling"/utf8>>,
erlang:element(2, Config),
fun automatic_thread_titling_param_to_json/1
),
glopenai@internal@codec:optional_field(
<<"file_upload"/utf8>>,
erlang:element(3, Config),
fun file_upload_param_to_json/1
),
glopenai@internal@codec:optional_field(
<<"history"/utf8>>,
erlang:element(4, Config),
fun history_param_to_json/1
)]
).
-file("src/glopenai/chatkit.gleam", 441).
-spec new_create_chat_session_body(workflow_param(), binary()) -> create_chat_session_body().
new_create_chat_session_body(Workflow, User) ->
{create_chat_session_body, Workflow, User, none, none, none}.
-file("src/glopenai/chatkit.gleam", 454).
-spec with_expires_after(create_chat_session_body(), expires_after_param()) -> create_chat_session_body().
with_expires_after(Body, Expires_after) ->
{create_chat_session_body,
erlang:element(2, Body),
erlang:element(3, Body),
{some, Expires_after},
erlang:element(5, Body),
erlang:element(6, Body)}.
-file("src/glopenai/chatkit.gleam", 461).
-spec with_rate_limits(create_chat_session_body(), rate_limits_param()) -> create_chat_session_body().
with_rate_limits(Body, Rate_limits) ->
{create_chat_session_body,
erlang:element(2, Body),
erlang:element(3, Body),
erlang:element(4, Body),
{some, Rate_limits},
erlang:element(6, Body)}.
-file("src/glopenai/chatkit.gleam", 468).
-spec with_chatkit_configuration(
create_chat_session_body(),
chatkit_configuration_param()
) -> create_chat_session_body().
with_chatkit_configuration(Body, Configuration) ->
{create_chat_session_body,
erlang:element(2, Body),
erlang:element(3, Body),
erlang:element(4, Body),
erlang:element(5, Body),
{some, Configuration}}.
-file("src/glopenai/chatkit.gleam", 475).
-spec create_chat_session_body_to_json(create_chat_session_body()) -> gleam@json:json().
create_chat_session_body_to_json(Body) ->
glopenai@internal@codec:object_with_optional(
[{<<"workflow"/utf8>>, workflow_param_to_json(erlang:element(2, Body))},
{<<"user"/utf8>>, gleam@json:string(erlang:element(3, Body))}],
[glopenai@internal@codec:optional_field(
<<"expires_after"/utf8>>,
erlang:element(4, Body),
fun expires_after_param_to_json/1
),
glopenai@internal@codec:optional_field(
<<"rate_limits"/utf8>>,
erlang:element(5, Body),
fun rate_limits_param_to_json/1
),
glopenai@internal@codec:optional_field(
<<"chatkit_configuration"/utf8>>,
erlang:element(6, Body),
fun chatkit_configuration_param_to_json/1
)]
).
-file("src/glopenai/chatkit.gleam", 516).
-spec thread_status_decoder() -> gleam@dynamic@decode:decoder(thread_status()).
thread_status_decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Status_type) -> case Status_type of
<<"active"/utf8>> ->
gleam@dynamic@decode:success(thread_active);
<<"locked"/utf8>> ->
gleam@dynamic@decode:optional_field(
<<"reason"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Reason) ->
gleam@dynamic@decode:success(
{thread_locked, Reason}
)
end
);
<<"closed"/utf8>> ->
gleam@dynamic@decode:optional_field(
<<"reason"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Reason@1) ->
gleam@dynamic@decode:success(
{thread_closed, Reason@1}
)
end
);
_ ->
gleam@dynamic@decode:failure(
thread_active,
<<"ThreadStatus"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 546).
-spec file_annotation_source_decoder() -> gleam@dynamic@decode:decoder(file_annotation_source()).
file_annotation_source_decoder() ->
gleam@dynamic@decode:field(
<<"filename"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Filename) ->
gleam@dynamic@decode:success({file_annotation_source, Filename})
end
).
-file("src/glopenai/chatkit.gleam", 555).
-spec url_annotation_source_decoder() -> gleam@dynamic@decode:decoder(url_annotation_source()).
url_annotation_source_decoder() ->
gleam@dynamic@decode:field(
<<"url"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Url) ->
gleam@dynamic@decode:success({url_annotation_source, Url})
end
).
-file("src/glopenai/chatkit.gleam", 565).
-spec annotation_decoder() -> gleam@dynamic@decode:decoder(annotation()).
annotation_decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Annotation_type) -> case Annotation_type of
<<"file"/utf8>> ->
gleam@dynamic@decode:field(
<<"source"/utf8>>,
file_annotation_source_decoder(),
fun(Source) ->
gleam@dynamic@decode:success(
{file_annotation, Source}
)
end
);
<<"url"/utf8>> ->
gleam@dynamic@decode:field(
<<"source"/utf8>>,
url_annotation_source_decoder(),
fun(Source@1) ->
gleam@dynamic@decode:success(
{url_annotation, Source@1}
)
end
);
_ ->
gleam@dynamic@decode:failure(
{file_annotation, {file_annotation_source, <<""/utf8>>}},
<<"Annotation"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 588).
-spec response_output_text_decoder() -> gleam@dynamic@decode:decoder(response_output_text()).
response_output_text_decoder() ->
gleam@dynamic@decode:optional_field(
<<"type"/utf8>>,
<<"output_text"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Output_text_type) ->
gleam@dynamic@decode:field(
<<"text"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Text) ->
gleam@dynamic@decode:optional_field(
<<"annotations"/utf8>>,
[],
gleam@dynamic@decode:list(annotation_decoder()),
fun(Annotations) ->
gleam@dynamic@decode:success(
{response_output_text,
Output_text_type,
Text,
Annotations}
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 614).
-spec attachment_type_decoder() -> gleam@dynamic@decode:decoder(attachment_type()).
attachment_type_decoder() ->
gleam@dynamic@decode:then(
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Value) -> case Value of
<<"image"/utf8>> ->
gleam@dynamic@decode:success(attachment_image);
<<"file"/utf8>> ->
gleam@dynamic@decode:success(attachment_file);
_ ->
gleam@dynamic@decode:failure(
attachment_file,
<<"AttachmentType"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 633).
-spec attachment_decoder() -> gleam@dynamic@decode:decoder(attachment()).
attachment_decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
attachment_type_decoder(),
fun(Attachment_type) ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:field(
<<"name"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Name) ->
gleam@dynamic@decode:field(
<<"mime_type"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Mime_type) ->
gleam@dynamic@decode:field(
<<"preview_url"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(Preview_url) ->
gleam@dynamic@decode:success(
{attachment,
Attachment_type,
Id,
Name,
Mime_type,
Preview_url}
)
end
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 652).
-spec tool_choice_decoder() -> gleam@dynamic@decode:decoder(tool_choice()).
tool_choice_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) -> gleam@dynamic@decode:success({tool_choice, Id}) end
).
-file("src/glopenai/chatkit.gleam", 661).
-spec inference_options_decoder() -> gleam@dynamic@decode:decoder(inference_options()).
inference_options_decoder() ->
gleam@dynamic@decode:optional_field(
<<"tool_choice"/utf8>>,
none,
gleam@dynamic@decode:optional(tool_choice_decoder()),
fun(Tool_choice) ->
gleam@dynamic@decode:optional_field(
<<"model"/utf8>>,
none,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Model) ->
gleam@dynamic@decode:success(
{inference_options, Tool_choice, Model}
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 682).
-spec user_message_content_decoder() -> gleam@dynamic@decode:decoder(user_message_content()).
user_message_content_decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Content_type) -> case Content_type of
<<"input_text"/utf8>> ->
gleam@dynamic@decode:field(
<<"text"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Text) ->
gleam@dynamic@decode:success(
{input_text_content, Text}
)
end
);
<<"quoted_text"/utf8>> ->
gleam@dynamic@decode:field(
<<"text"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Text@1) ->
gleam@dynamic@decode:success(
{quoted_text_content, Text@1}
)
end
);
_ ->
gleam@dynamic@decode:failure(
{input_text_content, <<""/utf8>>},
<<"UserMessageContent"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 704).
-spec task_type_decoder() -> gleam@dynamic@decode:decoder(task_type()).
task_type_decoder() ->
gleam@dynamic@decode:then(
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Value) -> case Value of
<<"custom"/utf8>> ->
gleam@dynamic@decode:success(task_custom);
<<"thought"/utf8>> ->
gleam@dynamic@decode:success(task_thought);
_ ->
gleam@dynamic@decode:failure(
task_custom,
<<"TaskType"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 721).
-spec task_group_task_decoder() -> gleam@dynamic@decode:decoder(task_group_task()).
task_group_task_decoder() ->
gleam@dynamic@decode:field(
<<"task_type"/utf8>>,
task_type_decoder(),
fun(Task_type) ->
gleam@dynamic@decode:field(
<<"heading"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Heading) ->
gleam@dynamic@decode:field(
<<"summary"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Summary) ->
gleam@dynamic@decode:success(
{task_group_task, Task_type, Heading, Summary}
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 739).
-spec client_tool_call_status_decoder() -> gleam@dynamic@decode:decoder(client_tool_call_status()).
client_tool_call_status_decoder() ->
gleam@dynamic@decode:then(
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Value) -> case Value of
<<"in_progress"/utf8>> ->
gleam@dynamic@decode:success(client_tool_in_progress);
<<"completed"/utf8>> ->
gleam@dynamic@decode:success(client_tool_completed);
_ ->
gleam@dynamic@decode:failure(
client_tool_in_progress,
<<"ClientToolCallStatus"/utf8>>
)
end end
).
-file("src/glopenai/chatkit.gleam", 803).
-spec thread_item_decoder() -> gleam@dynamic@decode:decoder(thread_item()).
thread_item_decoder() ->
gleam@dynamic@decode:field(
<<"type"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Item_type) ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:optional_field(
<<"object"/utf8>>,
<<"chatkit.thread_item"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Object) ->
gleam@dynamic@decode:field(
<<"created_at"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Created_at) ->
gleam@dynamic@decode:field(
<<"thread_id"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Thread_id) -> case Item_type of
<<"chatkit.user_message"/utf8>> ->
gleam@dynamic@decode:field(
<<"content"/utf8>>,
gleam@dynamic@decode:list(
user_message_content_decoder(
)
),
fun(Content) ->
gleam@dynamic@decode:optional_field(
<<"attachments"/utf8>>,
[],
gleam@dynamic@decode:list(
attachment_decoder(
)
),
fun(Attachments) ->
gleam@dynamic@decode:optional_field(
<<"inference_options"/utf8>>,
none,
gleam@dynamic@decode:optional(
inference_options_decoder(
)
),
fun(
Inference_options
) ->
gleam@dynamic@decode:success(
{user_message_item,
Id,
Object,
Created_at,
Thread_id,
Content,
Attachments,
Inference_options}
)
end
)
end
)
end
);
<<"chatkit.assistant_message"/utf8>> ->
gleam@dynamic@decode:field(
<<"content"/utf8>>,
gleam@dynamic@decode:list(
response_output_text_decoder(
)
),
fun(Content@1) ->
gleam@dynamic@decode:success(
{assistant_message_item,
Id,
Object,
Created_at,
Thread_id,
Content@1}
)
end
);
<<"chatkit.widget"/utf8>> ->
gleam@dynamic@decode:field(
<<"widget"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Widget) ->
gleam@dynamic@decode:success(
{widget_message_item,
Id,
Object,
Created_at,
Thread_id,
Widget}
)
end
);
<<"chatkit.client_tool_call"/utf8>> ->
gleam@dynamic@decode:field(
<<"status"/utf8>>,
client_tool_call_status_decoder(
),
fun(Status) ->
gleam@dynamic@decode:field(
<<"call_id"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(Call_id) ->
gleam@dynamic@decode:field(
<<"name"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Name
) ->
gleam@dynamic@decode:field(
<<"arguments"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(
Arguments
) ->
gleam@dynamic@decode:field(
<<"output"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(
Output
) ->
gleam@dynamic@decode:success(
{client_tool_call_item,
Id,
Object,
Created_at,
Thread_id,
Status,
Call_id,
Name,
Arguments,
Output}
)
end
)
end
)
end
)
end
)
end
);
<<"chatkit.task"/utf8>> ->
gleam@dynamic@decode:field(
<<"task_type"/utf8>>,
task_type_decoder(),
fun(Task_type) ->
gleam@dynamic@decode:field(
<<"heading"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(Heading) ->
gleam@dynamic@decode:field(
<<"summary"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(
Summary
) ->
gleam@dynamic@decode:success(
{task_item,
Id,
Object,
Created_at,
Thread_id,
Task_type,
Heading,
Summary}
)
end
)
end
)
end
);
<<"chatkit.task_group"/utf8>> ->
gleam@dynamic@decode:field(
<<"tasks"/utf8>>,
gleam@dynamic@decode:list(
task_group_task_decoder(
)
),
fun(Tasks) ->
gleam@dynamic@decode:success(
{task_group_item,
Id,
Object,
Created_at,
Thread_id,
Tasks}
)
end
);
_ ->
gleam@dynamic@decode:failure(
{widget_message_item,
<<""/utf8>>,
<<""/utf8>>,
0,
<<""/utf8>>,
<<""/utf8>>},
<<"ThreadItem"/utf8>>
)
end end
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 989).
-spec deleted_thread_resource_decoder() -> gleam@dynamic@decode:decoder(deleted_thread_resource()).
deleted_thread_resource_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:optional_field(
<<"object"/utf8>>,
<<"chatkit.thread.deleted"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Object) ->
gleam@dynamic@decode:field(
<<"deleted"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Deleted) ->
gleam@dynamic@decode:success(
{deleted_thread_resource, Id, Object, Deleted}
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 1010).
-spec thread_item_list_resource_decoder() -> gleam@dynamic@decode:decoder(thread_item_list_resource()).
thread_item_list_resource_decoder() ->
gleam@dynamic@decode:optional_field(
<<"object"/utf8>>,
<<"list"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Object) ->
gleam@dynamic@decode:field(
<<"data"/utf8>>,
gleam@dynamic@decode:list(thread_item_decoder()),
fun(Data) ->
gleam@dynamic@decode:field(
<<"first_id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(First_id) ->
gleam@dynamic@decode:field(
<<"last_id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(Last_id) ->
gleam@dynamic@decode:field(
<<"has_more"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_bool/1},
fun(Has_more) ->
gleam@dynamic@decode:success(
{thread_item_list_resource,
Object,
Data,
First_id,
Last_id,
Has_more}
)
end
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 936).
-spec thread_resource_decoder() -> gleam@dynamic@decode:decoder(thread_resource()).
thread_resource_decoder() ->
gleam@dynamic@decode:field(
<<"id"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Id) ->
gleam@dynamic@decode:optional_field(
<<"object"/utf8>>,
<<"chatkit.thread"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Object) ->
gleam@dynamic@decode:field(
<<"created_at"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_int/1},
fun(Created_at) ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(Title) ->
gleam@dynamic@decode:then(
thread_status_decoder(),
fun(Status) ->
gleam@dynamic@decode:field(
<<"user"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_string/1},
fun(User) ->
gleam@dynamic@decode:optional_field(
<<"items"/utf8>>,
none,
gleam@dynamic@decode:optional(
thread_item_list_resource_decoder(
)
),
fun(Items) ->
gleam@dynamic@decode:success(
{thread_resource,
Id,
Object,
Created_at,
Title,
Status,
User,
Items}
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 970).
-spec thread_list_resource_decoder() -> gleam@dynamic@decode:decoder(thread_list_resource()).
thread_list_resource_decoder() ->
gleam@dynamic@decode:optional_field(
<<"object"/utf8>>,
<<"list"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Object) ->
gleam@dynamic@decode:field(
<<"data"/utf8>>,
gleam@dynamic@decode:list(thread_resource_decoder()),
fun(Data) ->
gleam@dynamic@decode:field(
<<"first_id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(First_id) ->
gleam@dynamic@decode:field(
<<"last_id"/utf8>>,
gleam@dynamic@decode:optional(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(Last_id) ->
gleam@dynamic@decode:field(
<<"has_more"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_bool/1},
fun(Has_more) ->
gleam@dynamic@decode:success(
{thread_list_resource,
Object,
Data,
First_id,
Last_id,
Has_more}
)
end
)
end
)
end
)
end
)
end
).
-file("src/glopenai/chatkit.gleam", 1034).
-spec threads_order_to_string(list_chat_kit_threads_order()) -> binary().
threads_order_to_string(Order) ->
case Order of
threads_asc ->
<<"asc"/utf8>>;
threads_desc ->
<<"desc"/utf8>>
end.
-file("src/glopenai/chatkit.gleam", 1051).
-spec empty_list_threads_query() -> list_chat_kit_threads_query().
empty_list_threads_query() ->
{list_chat_kit_threads_query, none, none, none, none, none}.
-file("src/glopenai/chatkit.gleam", 1078).
-spec items_order_to_string(list_chat_kit_thread_items_order()) -> binary().
items_order_to_string(Order) ->
case Order of
items_asc ->
<<"asc"/utf8>>;
items_desc ->
<<"desc"/utf8>>
end.
-file("src/glopenai/chatkit.gleam", 1094).
-spec empty_list_thread_items_query() -> list_chat_kit_thread_items_query().
empty_list_thread_items_query() ->
{list_chat_kit_thread_items_query, none, none, none, none}.
-file("src/glopenai/chatkit.gleam", 1114).
-spec optional_string_pair(
binary(),
gleam@option:option(GZA),
fun((GZA) -> binary())
) -> list({binary(), binary()}).
optional_string_pair(Key, Value, Encode) ->
case Value of
{some, V} ->
[{Key, Encode(V)}];
none ->
[]
end.
-file("src/glopenai/chatkit.gleam", 1061).
-spec list_threads_query_pairs(list_chat_kit_threads_query()) -> list({binary(),
binary()}).
list_threads_query_pairs(Query) ->
lists:append(
[optional_string_pair(
<<"limit"/utf8>>,
erlang:element(2, Query),
fun erlang:integer_to_binary/1
),
optional_string_pair(
<<"order"/utf8>>,
erlang:element(3, Query),
fun threads_order_to_string/1
),
optional_string_pair(
<<"after"/utf8>>,
erlang:element(4, Query),
fun(S) -> S end
),
optional_string_pair(
<<"before"/utf8>>,
erlang:element(5, Query),
fun(S@1) -> S@1 end
),
optional_string_pair(
<<"user"/utf8>>,
erlang:element(6, Query),
fun(S@2) -> S@2 end
)]
).
-file("src/glopenai/chatkit.gleam", 1103).
-spec list_thread_items_query_pairs(list_chat_kit_thread_items_query()) -> list({binary(),
binary()}).
list_thread_items_query_pairs(Query) ->
lists:append(
[optional_string_pair(
<<"limit"/utf8>>,
erlang:element(2, Query),
fun erlang:integer_to_binary/1
),
optional_string_pair(
<<"order"/utf8>>,
erlang:element(3, Query),
fun items_order_to_string/1
),
optional_string_pair(
<<"after"/utf8>>,
erlang:element(4, Query),
fun(S) -> S end
),
optional_string_pair(
<<"before"/utf8>>,
erlang:element(5, Query),
fun(S@1) -> S@1 end
)]
).
-file("src/glopenai/chatkit.gleam", 1129).
-spec session_create_request(
glopenai@config:config(),
create_chat_session_body()
) -> gleam@http@request:request(binary()).
session_create_request(Config, Body) ->
glopenai@internal:post_request(
Config,
<<"/chatkit/sessions"/utf8>>,
create_chat_session_body_to_json(Body)
).
-file("src/glopenai/chatkit.gleam", 1140).
-spec session_create_response(gleam@http@response:response(binary())) -> {ok,
chat_session_resource()} |
{error, glopenai@error:glopenai_error()}.
session_create_response(Response) ->
glopenai@internal:parse_response(Response, chat_session_resource_decoder()).
-file("src/glopenai/chatkit.gleam", 1146).
-spec session_cancel_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()).
session_cancel_request(Config, Session_id) ->
glopenai@internal:post_request(
Config,
<<<<"/chatkit/sessions/"/utf8, Session_id/binary>>/binary,
"/cancel"/utf8>>,
gleam@json:object([])
).
-file("src/glopenai/chatkit.gleam", 1157).
-spec session_cancel_response(gleam@http@response:response(binary())) -> {ok,
chat_session_resource()} |
{error, glopenai@error:glopenai_error()}.
session_cancel_response(Response) ->
glopenai@internal:parse_response(Response, chat_session_resource_decoder()).
-file("src/glopenai/chatkit.gleam", 1163).
-spec thread_list_request(glopenai@config:config()) -> gleam@http@request:request(binary()).
thread_list_request(Config) ->
glopenai@internal:get_request(Config, <<"/chatkit/threads"/utf8>>).
-file("src/glopenai/chatkit.gleam", 1167).
-spec thread_list_request_with_query(
glopenai@config:config(),
list_chat_kit_threads_query()
) -> gleam@http@request:request(binary()).
thread_list_request_with_query(Config, Query) ->
_pipe = glopenai@internal:get_request(Config, <<"/chatkit/threads"/utf8>>),
gleam@http@request:set_query(_pipe, list_threads_query_pairs(Query)).
-file("src/glopenai/chatkit.gleam", 1175).
-spec thread_list_response(gleam@http@response:response(binary())) -> {ok,
thread_list_resource()} |
{error, glopenai@error:glopenai_error()}.
thread_list_response(Response) ->
glopenai@internal:parse_response(Response, thread_list_resource_decoder()).
-file("src/glopenai/chatkit.gleam", 1181).
-spec thread_retrieve_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()).
thread_retrieve_request(Config, Thread_id) ->
glopenai@internal:get_request(
Config,
<<"/chatkit/threads/"/utf8, Thread_id/binary>>
).
-file("src/glopenai/chatkit.gleam", 1188).
-spec thread_retrieve_response(gleam@http@response:response(binary())) -> {ok,
thread_resource()} |
{error, glopenai@error:glopenai_error()}.
thread_retrieve_response(Response) ->
glopenai@internal:parse_response(Response, thread_resource_decoder()).
-file("src/glopenai/chatkit.gleam", 1194).
-spec thread_delete_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()).
thread_delete_request(Config, Thread_id) ->
glopenai@internal:delete_request(
Config,
<<"/chatkit/threads/"/utf8, Thread_id/binary>>
).
-file("src/glopenai/chatkit.gleam", 1201).
-spec thread_delete_response(gleam@http@response:response(binary())) -> {ok,
deleted_thread_resource()} |
{error, glopenai@error:glopenai_error()}.
thread_delete_response(Response) ->
glopenai@internal:parse_response(
Response,
deleted_thread_resource_decoder()
).
-file("src/glopenai/chatkit.gleam", 1207).
-spec thread_items_list_request(glopenai@config:config(), binary()) -> gleam@http@request:request(binary()).
thread_items_list_request(Config, Thread_id) ->
glopenai@internal:get_request(
Config,
<<<<"/chatkit/threads/"/utf8, Thread_id/binary>>/binary, "/items"/utf8>>
).
-file("src/glopenai/chatkit.gleam", 1214).
-spec thread_items_list_request_with_query(
glopenai@config:config(),
binary(),
list_chat_kit_thread_items_query()
) -> gleam@http@request:request(binary()).
thread_items_list_request_with_query(Config, Thread_id, Query) ->
_pipe = glopenai@internal:get_request(
Config,
<<<<"/chatkit/threads/"/utf8, Thread_id/binary>>/binary, "/items"/utf8>>
),
gleam@http@request:set_query(_pipe, list_thread_items_query_pairs(Query)).
-file("src/glopenai/chatkit.gleam", 1223).
-spec thread_items_list_response(gleam@http@response:response(binary())) -> {ok,
thread_item_list_resource()} |
{error, glopenai@error:glopenai_error()}.
thread_items_list_response(Response) ->
glopenai@internal:parse_response(
Response,
thread_item_list_resource_decoder()
).