Feature #3642
Task #3653: Launch with first chapter support - Phase 1 - Practice for Decent Learners (Top 5 Themes, No DetailedQNAs, No Detailed Answers)
Changes to call_openai_api to handle context limitations
100%
Description
Add an additional argument num_tokens. Add an additional output num_tokens.
Clients interested in handling the context limitation must send num_tokens received in the previous call in the thread as argument. First time, the value is 0.
As always, get assistant, instructions, prompt_prefix and prompt_suffix based on model and index. In addition, also get periodic_prompt from DS.
So far, prompt used is concat(prompt_prefix, <prompt>, prompt_suffix). If num_tokens is not zero, continue this. Otherwise prompt should be concat(periodic_prompt, prompt_prefix, <prompt>, prompt_suffix).
One more change: add response['usage']['total_tokens'] (tokens used in this api call) to num_tokens and return it.