View Source OpenaiEx.ChatMessage (openai_ex v0.3.0)
This module provides an implementation of the OpenAI chat message API. Information about these messages can be found at https://platform.openai.com/docs/guides/chat/introduction.
API Fields
The following fields can be used as parameters when creating a new chat message:
:content
:role
:function_call
:name
Summary
Functions
Create a ChatMessage
map with role assistant
.
Create a ChatMessage
map with role function
.
Create a ChatMessage
map with role system
.
Create a ChatMessage
map with role user
.
Functions
Create a ChatMessage
map with role assistant
.
Example usage:
iex> _message = OpenaiEx.ChatMessage.assistant("Hello, world!")
%{content: "Hello, world!", role: "assistant"}
Create a ChatMessage
map with role function
.
Example usage:
iex> _message = OpenaiEx.ChatMessage.function("greet", "Hello, world!")
%{content: "Hello, world!", role: "function", name: "greet"}
Create a ChatMessage
map with role system
.
Example usage:
iex> _message = OpenaiEx.ChatMessage.system("Hello, world!")
%{content: "Hello, world!", role: "system"}
Create a ChatMessage
map with role user
.
Example usage:
iex> _message = OpenaiEx.ChatMessage.user("Hello, world!")
%{content: "Hello, world!", role: "user"}