foropenai_ChatCompletion Module


Uses

  • module~~foropenai_chatcompletion~~UsesGraph module~foropenai_chatcompletion foropenai_ChatCompletion module~foropenai_base foropenai_base module~foropenai_chatcompletion->module~foropenai_base

Used by

  • module~~foropenai_chatcompletion~~UsedByGraph module~foropenai_chatcompletion foropenai_ChatCompletion module~foropenai foropenai module~foropenai->module~foropenai_chatcompletion program~test_base test_base program~test_base->module~foropenai program~test_chatcompletion test_ChatCompletion program~test_chatcompletion->module~foropenai program~test_imagegeneration test_ImageGeneration program~test_imagegeneration->module~foropenai program~test_transcription test_Transcription program~test_transcription->module~foropenai program~test_translation test_Translation program~test_translation->module~foropenai

Derived Types

type, private ::  usage

Components

Type Visibility Attributes Name Initial
integer, public :: prompt_tokens = 0
integer, public :: completion_tokens = 0
integer, public :: total_tokens = 0

Type-Bound Procedures

procedure, private :: print_prompt_tokens
procedure, private :: print_completion_tokens
procedure, private :: print_total_tokens
procedure, public :: print => print_usage

type, private ::  ChatCompletion_messages

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: role
character(len=:), public, allocatable :: content
character(len=:), public, allocatable :: name

Type-Bound Procedures

procedure, private :: deallocate_role
procedure, private :: deallocate_content
procedure, private :: deallocate_name
procedure, public :: finalize => deallocate_ChatCompletion_messages
procedure, public :: set => set_message
procedure, private :: set_role
procedure, private :: set_content
procedure, private :: set_name

type, public, extends(openai) ::  ChatCompletion

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: organization
character(len=:), public, allocatable :: api_key
character(len=:), public, allocatable :: file_name
character(len=14), public :: api_key_env = 'OPENAI_API_KEY'
character(len=10), public :: organization_env = 'OPENAI_ORG'
character(len=:), public, allocatable :: url
character(len=:), public, allocatable :: model
character(len=:), public, allocatable :: user_name
character(len=256), public, allocatable :: model_list(:)
type(ChatCompletion_messages), public, allocatable :: messages(:)
integer, public :: max_tokens
type(usage), public :: usage
real, public :: temperature = 1.0
real, public :: presence_penalty = 0.0
real, public :: frequency_penalty = 0.0
real, public :: top_p = 1.0
logical, public :: stream = .false.
integer, public :: n = 1
character(len=:), public, allocatable :: finish_reason

Type-Bound Procedures

procedure, public :: load_base_data
procedure, public :: print_api_key
procedure, public :: print_organization
procedure, public :: print_file_name
procedure, public :: set_file_name
procedure, public :: set_base_data
procedure, public :: check => check_chat_completion
procedure, public :: create => create_chat_completion
procedure, public :: conversation
procedure, private :: deallocate_messages
procedure, private :: deallocate_model_list
procedure, private :: deallocate_url
procedure, private :: deallocate_model
procedure, private :: deallocate_user_name
procedure, private :: deallocate_finish_reason
procedure, public :: finalize => deallocate_ChatCompletion
procedure, private :: get_assistant_response
procedure, private :: get_user_message
procedure, public :: init_messages
procedure, private :: load => load_ChatCompletion_data
procedure, private :: load_user_name
procedure, private :: load_url
procedure, private :: load_model
procedure, private :: load_temperature
procedure, private :: load_presence_penalty
procedure, private :: load_frequency_penalty
procedure, private :: load_top_p
procedure, private :: load_n
procedure, private :: load_stream
procedure, private :: load_max_tokens
procedure, private :: read_user_message
procedure, private :: print_user_name
procedure, private :: print_model_list
procedure, private :: print_model
procedure, private :: print_temperature
procedure, private :: print_presence_penalty
procedure, private :: print_frequency_penalty
procedure, private :: print_top_p
procedure, private :: print_n
procedure, private :: print_stream
procedure, private :: print_max_tokens
procedure, public :: print_user_message
procedure, public :: print_assistant_response
procedure, private :: set_user_name
procedure, private :: set_url
procedure, private :: set_model
procedure, private :: set_model_list
procedure, private :: select_model
procedure, private :: set_temperature
procedure, private :: set_presence_penalty
procedure, private :: set_frequency_penalty
procedure, private :: set_top_p
procedure, private :: set_n
procedure, private :: set_stream
procedure, private :: set_max_tokens
procedure, private :: set_asisstant_response
procedure, private :: set_user_message
procedure, public :: set => set_ChatCompletion_data
procedure, private :: write_history
procedure, private :: print_finish_reason

Functions

private pure function get_assistant_response(this) result(response)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(in) :: this

Return Value character(len=:), allocatable

private pure function get_user_message(this) result(message)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(in) :: this

Return Value character(len=:), allocatable


Subroutines

private impure elemental subroutine print_usage(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(usage), intent(inout) :: this

private impure elemental subroutine set_ChatCompletion_data(this, file_name, url, model, user_name, temperature, presence_penalty, frequency_penalty, top_p, n, stream, max_tokens)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in), optional :: file_name
character(len=*), intent(in), optional :: url
character(len=*), intent(in), optional :: model
character(len=*), intent(in), optional :: user_name
real, intent(in), optional :: temperature
real, intent(in), optional :: presence_penalty
real, intent(in), optional :: frequency_penalty
real, intent(in), optional :: top_p
integer, intent(in), optional :: n
logical, intent(in), optional :: stream
integer, intent(in), optional :: max_tokens

private pure elemental subroutine set_user_message(this, message)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: message

private pure elemental subroutine set_asisstant_response(this, response)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: response

private impure elemental subroutine print_assistant_response(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_user_message(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine deallocate_finish_reason(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_finish_reason(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine conversation(this, file_name_base, file_name_ChatCompletion, input_file, output_file, inputfile_command, exit_command)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: file_name_base
character(len=*), intent(in) :: file_name_ChatCompletion
character(len=*), intent(in) :: input_file
character(len=*), intent(in) :: output_file
character(len=*), intent(in) :: inputfile_command
character(len=*), intent(in) :: exit_command

private impure elemental subroutine write_history(this, file_name)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: file_name

private impure elemental subroutine read_user_message(this, file_name, command)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: file_name
character(len=*), intent(in) :: command

private pure elemental subroutine deallocate_ChatCompletion_messages(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this

private pure elemental subroutine deallocate_ChatCompletion(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine deallocate_url(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine deallocate_model(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine deallocate_user_name(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_ChatCompletion_data(this, file_name)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: file_name

private pure elemental subroutine set_message(this, role, content, name)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this
character(len=*), intent(in) :: role
character(len=*), intent(in) :: content
character(len=*), intent(in), optional :: name

private impure elemental subroutine load_max_tokens(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_temperature(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_presence_penalty(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_frequency_penalty(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_top_p(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_n(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_stream(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_url(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_model(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine load_user_name(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine deallocate_model_list(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine set_model_list(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_model_list(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine set_temperature(this, temperature)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
real, intent(in) :: temperature

private pure elemental subroutine set_presence_penalty(this, presence_penalty)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
real, intent(in) :: presence_penalty

private pure elemental subroutine set_frequency_penalty(this, frequency_penalty)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
real, intent(in) :: frequency_penalty

private pure elemental subroutine set_top_p(this, top_p)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
real, intent(in) :: top_p

private pure elemental subroutine set_n(this, n)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
integer, intent(in) :: n

private pure elemental subroutine set_stream(this, stream)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
logical, intent(in) :: stream

private pure elemental subroutine set_url(this, url)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: url

private pure elemental subroutine set_model(this, model)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: model

private pure elemental subroutine init_messages(this, n)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
integer, intent(in) :: n

private pure elemental subroutine set_role(this, role)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this
character(len=*), intent(in) :: role

private pure elemental subroutine set_content(this, content)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this
character(len=*), intent(in) :: content

private pure elemental subroutine set_name(this, name)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this
character(len=*), intent(in) :: name

private impure elemental subroutine check_chat_completion(this, error)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
integer, intent(out) :: error

private impure elemental subroutine create_chat_completion(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine deallocate_role(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this

private pure elemental subroutine deallocate_content(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this

private pure elemental subroutine deallocate_name(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion_messages), intent(inout) :: this

private pure elemental subroutine deallocate_messages(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine select_model(this, n)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
integer, intent(in) :: n

private impure elemental subroutine print_model(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_temperature(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_presence_penalty(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_frequency_penalty(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_top_p(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_n(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_stream(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine set_max_tokens(this, max_tokens)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
integer, intent(in) :: max_tokens

private impure elemental subroutine print_max_tokens(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private pure elemental subroutine set_user_name(this, user_name)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this
character(len=*), intent(in) :: user_name

private impure elemental subroutine print_user_name(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(ChatCompletion), intent(inout) :: this

private impure elemental subroutine print_prompt_tokens(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(usage), intent(inout) :: this

private impure elemental subroutine print_completion_tokens(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(usage), intent(inout) :: this

private impure elemental subroutine print_total_tokens(this)

Author
Seyed Ali Ghasemi

Arguments

Type IntentOptional Attributes Name
class(usage), intent(inout) :: this