* Construct the initial prompt with embeddings searching. * @throw std::invalid_argument When chat_history is empty. */
| 14 | * @throw std::invalid_argument When chat_history is empty. |
| 15 | */ |
| 16 | void Completion::construct_initial() { |
| 17 | if (!chat_history->empty()) { |
| 18 | if (documents) { |
| 19 | constructed_initial = prompt::construct_reference(initial_prompt, chat_history->back()->getInputEmbeddings(), |
| 20 | documents, max_reference_length); |
| 21 | } else { |
| 22 | constructed_initial = prompt::construct_reference(initial_prompt, chat_history->back()->getInputEmbeddings(), |
| 23 | chat_history, search_response, max_reference_length, |
| 24 | max_short_memory_length, me_id, bot_id); |
| 25 | } |
| 26 | } else { |
| 27 | throw std::invalid_argument("Field chat_history is empty."); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Call the OpenAI API. |
no test coverage detected