OpenaiEx.ChatMessage (openai_ex v0.9.4)

View Source

This module provides an elixir map wrapper around the OpenAI message JSON object which is used in the chat completions and assistants APIs.

Summary

Functions

Create a ChatMessage map with role assistant.

Create a ChatMessage map with role developer.

Create a ChatMessage map with role system.

Create a ChatMessage map with role function.

Create a ChatMessage map with role user.

Functions

assistant(content)

Create a ChatMessage map with role assistant.

Example usage:

iex> _message = OpenaiEx.ChatMessage.assistant("Hello, world!")
%{content: "Hello, world!", role: "assistant"}

developer(content)

Create a ChatMessage map with role developer.

Example usage:

iex> _message = OpenaiEx.ChatMessage.developer("Hello, world!")
%{content: "Hello, world!", role: "developer"}

system(content)

Create a ChatMessage map with role system.

Example usage:

iex> _message = OpenaiEx.ChatMessage.system("Hello, world!")
%{content: "Hello, world!", role: "system"}

tool(tool_call_id, name, content)

Create a ChatMessage map with role function.

Example usage:

iex> _message = OpenaiEx.ChatMessage.tool("call_sjflkje", "greet", "Hello, world!")
%{content: "Hello, world!", role: "tool", name: "greet", tool_call_id: "call_sjflkje"}

user(content)

Create a ChatMessage map with role user.

Example usage:

iex> _message = OpenaiEx.ChatMessage.user("Hello, world!")
%{content: "Hello, world!", role: "user"}