test2.f90 Source File


This file depends on

sourcefile~~test2.f90~~EfferentGraph sourcefile~test2.f90 test2.f90 sourcefile~foropenai.f90 foropenai.f90 sourcefile~test2.f90->sourcefile~foropenai.f90 sourcefile~foropenai_base.f90 foropenai_base.f90 sourcefile~foropenai.f90->sourcefile~foropenai_base.f90 sourcefile~foropenai_chatcompletion.f90 foropenai_ChatCompletion.f90 sourcefile~foropenai.f90->sourcefile~foropenai_chatcompletion.f90 sourcefile~foropenai_imagegeneration.f90 foropenai_ImageGeneration.f90 sourcefile~foropenai.f90->sourcefile~foropenai_imagegeneration.f90 sourcefile~foropenai_transcription.f90 foropenai_Transcription.f90 sourcefile~foropenai.f90->sourcefile~foropenai_transcription.f90 sourcefile~foropenai_translation.f90 foropenai_Translation.f90 sourcefile~foropenai.f90->sourcefile~foropenai_translation.f90 sourcefile~foropenai_chatcompletion.f90->sourcefile~foropenai_base.f90 sourcefile~foropenai_imagegeneration.f90->sourcefile~foropenai_base.f90 sourcefile~foropenai_transcription.f90->sourcefile~foropenai_base.f90 sourcefile~foropenai_translation.f90->sourcefile~foropenai_base.f90

Source Code

program test_ChatCompletion

   use foropenai, only: ChatCompletion

   implicit none

   type(ChatCompletion) :: chat

   call chat%set_base_data(file_name='foropenai.json')
   call chat%set(file_name='foropenai.json')

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

   call chat%print_user_message()
   call chat%create()
   call chat%print_assistant_response()

   call chat%usage%print()

   call chat%finalize()

end program test_ChatCompletion