conversation Subroutine

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

Type Bound

ChatCompletion

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

Calls

proc~~conversation~~CallsGraph proc~conversation foropenai_ChatCompletion::ChatCompletion%conversation proc~create_chat_completion foropenai_ChatCompletion::ChatCompletion%create_chat_completion proc~conversation->proc~create_chat_completion proc~get_assistant_response foropenai_ChatCompletion::ChatCompletion%get_assistant_response proc~conversation->proc~get_assistant_response proc~get_user_message foropenai_ChatCompletion::ChatCompletion%get_user_message proc~conversation->proc~get_user_message proc~init_messages foropenai_ChatCompletion::ChatCompletion%init_messages proc~conversation->proc~init_messages proc~print_assistant_response~2 foropenai_ChatCompletion::ChatCompletion%print_assistant_response proc~conversation->proc~print_assistant_response~2 proc~print_completion_tokens foropenai_ChatCompletion::usage%print_completion_tokens proc~conversation->proc~print_completion_tokens proc~print_prompt_tokens foropenai_ChatCompletion::usage%print_prompt_tokens proc~conversation->proc~print_prompt_tokens proc~print_total_tokens foropenai_ChatCompletion::usage%print_total_tokens proc~conversation->proc~print_total_tokens proc~read_user_message foropenai_ChatCompletion::ChatCompletion%read_user_message proc~conversation->proc~read_user_message proc~set_asisstant_response foropenai_ChatCompletion::ChatCompletion%set_asisstant_response proc~conversation->proc~set_asisstant_response proc~set_base_data foropenai_base::openai%set_base_data proc~conversation->proc~set_base_data proc~set_chatcompletion_data foropenai_ChatCompletion::ChatCompletion%set_ChatCompletion_data proc~conversation->proc~set_chatcompletion_data proc~set_role foropenai_ChatCompletion::ChatCompletion_messages%set_role proc~conversation->proc~set_role proc~write_history foropenai_ChatCompletion::ChatCompletion%write_history proc~conversation->proc~write_history proc~create_chat_completion->proc~set_asisstant_response add add proc~create_chat_completion->add deserialize deserialize proc~create_chat_completion->deserialize destroy destroy proc~create_chat_completion->destroy get get proc~create_chat_completion->get initialize initialize proc~create_chat_completion->initialize pair_type pair_type proc~create_chat_completion->pair_type print_to_string print_to_string proc~create_chat_completion->print_to_string proc~check_chat_completion foropenai_ChatCompletion::ChatCompletion%check_chat_completion proc~create_chat_completion->proc~check_chat_completion request request proc~create_chat_completion->request colorize colorize proc~print_assistant_response~2->colorize proc~read_user_message->colorize proc~set_user_message foropenai_ChatCompletion::ChatCompletion%set_user_message proc~read_user_message->proc~set_user_message proc~set_content foropenai_ChatCompletion::ChatCompletion_messages%set_content proc~set_asisstant_response->proc~set_content proc~load_api_key foropenai_base::openai%load_api_key proc~set_base_data->proc~load_api_key proc~load_organization foropenai_base::openai%load_organization proc~set_base_data->proc~load_organization proc~set_api_key foropenai_base::openai%set_api_key proc~set_base_data->proc~set_api_key proc~set_api_key_env foropenai_base::openai%set_api_key_env proc~set_base_data->proc~set_api_key_env proc~set_file_name foropenai_base::openai%set_file_name proc~set_base_data->proc~set_file_name proc~set_organization foropenai_base::openai%set_organization proc~set_base_data->proc~set_organization proc~set_organization_env foropenai_base::openai%set_organization_env proc~set_base_data->proc~set_organization_env proc~load_chatcompletion_data foropenai_ChatCompletion::ChatCompletion%load_ChatCompletion_data proc~set_chatcompletion_data->proc~load_chatcompletion_data proc~set_chatcompletion_data->proc~set_file_name proc~set_frequency_penalty foropenai_ChatCompletion::ChatCompletion%set_frequency_penalty proc~set_chatcompletion_data->proc~set_frequency_penalty proc~set_max_tokens foropenai_ChatCompletion::ChatCompletion%set_max_tokens proc~set_chatcompletion_data->proc~set_max_tokens proc~set_model~2 foropenai_ChatCompletion::ChatCompletion%set_model proc~set_chatcompletion_data->proc~set_model~2 proc~set_n foropenai_ChatCompletion::ChatCompletion%set_n proc~set_chatcompletion_data->proc~set_n proc~set_presence_penalty foropenai_ChatCompletion::ChatCompletion%set_presence_penalty proc~set_chatcompletion_data->proc~set_presence_penalty proc~set_stream foropenai_ChatCompletion::ChatCompletion%set_stream proc~set_chatcompletion_data->proc~set_stream proc~set_temperature~2 foropenai_ChatCompletion::ChatCompletion%set_temperature proc~set_chatcompletion_data->proc~set_temperature~2 proc~set_top_p foropenai_ChatCompletion::ChatCompletion%set_top_p proc~set_chatcompletion_data->proc~set_top_p proc~set_url~2 foropenai_ChatCompletion::ChatCompletion%set_url proc~set_chatcompletion_data->proc~set_url~2 proc~set_user_name foropenai_ChatCompletion::ChatCompletion%set_user_name proc~set_chatcompletion_data->proc~set_user_name proc~write_history->proc~get_assistant_response proc~write_history->proc~get_user_message proc~load_api_key->destroy proc~load_api_key->get proc~load_api_key->initialize proc~load_api_key->proc~set_file_name load_file load_file proc~load_api_key->load_file proc~load_chatcompletion_data->proc~set_file_name proc~load_frequency_penalty foropenai_ChatCompletion::ChatCompletion%load_frequency_penalty proc~load_chatcompletion_data->proc~load_frequency_penalty proc~load_max_tokens foropenai_ChatCompletion::ChatCompletion%load_max_tokens proc~load_chatcompletion_data->proc~load_max_tokens proc~load_model~2 foropenai_ChatCompletion::ChatCompletion%load_model proc~load_chatcompletion_data->proc~load_model~2 proc~load_n foropenai_ChatCompletion::ChatCompletion%load_n proc~load_chatcompletion_data->proc~load_n proc~load_presence_penalty foropenai_ChatCompletion::ChatCompletion%load_presence_penalty proc~load_chatcompletion_data->proc~load_presence_penalty proc~load_stream foropenai_ChatCompletion::ChatCompletion%load_stream proc~load_chatcompletion_data->proc~load_stream proc~load_temperature~2 foropenai_ChatCompletion::ChatCompletion%load_temperature proc~load_chatcompletion_data->proc~load_temperature~2 proc~load_top_p foropenai_ChatCompletion::ChatCompletion%load_top_p proc~load_chatcompletion_data->proc~load_top_p proc~load_url~2 foropenai_ChatCompletion::ChatCompletion%load_url proc~load_chatcompletion_data->proc~load_url~2 proc~load_user_name foropenai_ChatCompletion::ChatCompletion%load_user_name proc~load_chatcompletion_data->proc~load_user_name proc~load_organization->destroy proc~load_organization->get proc~load_organization->initialize proc~load_organization->proc~set_file_name proc~load_organization->load_file proc~set_api_key_env->proc~set_api_key proc~set_organization_env->proc~set_organization proc~set_user_message->proc~set_content proc~load_frequency_penalty->destroy proc~load_frequency_penalty->get proc~load_frequency_penalty->initialize proc~load_frequency_penalty->load_file proc~load_max_tokens->destroy proc~load_max_tokens->get proc~load_max_tokens->initialize proc~load_max_tokens->load_file proc~load_model~2->destroy proc~load_model~2->get proc~load_model~2->initialize proc~load_model~2->load_file proc~load_n->destroy proc~load_n->get proc~load_n->initialize proc~load_n->load_file proc~load_presence_penalty->destroy proc~load_presence_penalty->get proc~load_presence_penalty->initialize proc~load_presence_penalty->load_file proc~load_stream->destroy proc~load_stream->get proc~load_stream->initialize proc~load_stream->load_file proc~load_temperature~2->destroy proc~load_temperature~2->get proc~load_temperature~2->initialize proc~load_temperature~2->load_file proc~load_top_p->destroy proc~load_top_p->get proc~load_top_p->initialize proc~load_top_p->load_file proc~load_url~2->destroy proc~load_url~2->get proc~load_url~2->initialize proc~load_url~2->load_file proc~load_user_name->destroy proc~load_user_name->get proc~load_user_name->initialize proc~load_user_name->load_file

Source Code

   elemental impure subroutine conversation(this, file_name_base, file_name_ChatCompletion, &
      input_file, output_file, inputfile_command, exit_command)
      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

      call this%set_base_data(file_name_base)
      call this%set(file_name_ChatCompletion)

      call this%init_messages(n=3)
      call this%messages(1)%set(role='system', content='You are a helpful assistant.')
      call this%messages(2)%set(role='assistant', content='')
      call this%messages(3)%set_role(role='user')

      do
         call this%read_user_message(file_name=trim(input_file), command=trim(inputfile_command))
         if (trim(this%get_user_message()) == trim(exit_command)) exit
         call this%create()
         call this%set_asisstant_response(response=this%get_assistant_response())
         call this%print_assistant_response()
         call this%write_history(file_name=trim(output_file))
      end do

      call this%usage%print_prompt_tokens()
      call this%usage%print_completion_tokens()
      call this%usage%print_total_tokens()
   end subroutine conversation