write_history Subroutine

private impure elemental subroutine write_history(this, file_name)

Type Bound

ChatCompletion

Arguments

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

Calls

proc~~write_history~~CallsGraph proc~write_history foropenai_ChatCompletion::ChatCompletion%write_history proc~get_assistant_response foropenai_ChatCompletion::ChatCompletion%get_assistant_response proc~write_history->proc~get_assistant_response proc~get_user_message foropenai_ChatCompletion::ChatCompletion%get_user_message proc~write_history->proc~get_user_message

Called by

proc~~write_history~~CalledByGraph proc~write_history foropenai_ChatCompletion::ChatCompletion%write_history proc~conversation foropenai_ChatCompletion::ChatCompletion%conversation proc~conversation->proc~write_history

Source Code

   elemental impure subroutine write_history(this, file_name)
      class(ChatCompletion), intent(inout) :: this
      character(len=*),      intent(in)    :: file_name
      integer                              :: iounit

      open(newunit=iounit, file=trim(file_name), status='unknown', access='append', action='write')
      write(iounit,"(A,': ',A)") this%user_name, this%get_user_message()
      write(iounit,"('ChatGPT: ',A)") this%get_assistant_response()
      close(iounit)
   end subroutine write_history