INNER CODE UNIT · Python
get_user_answer
adamyodinsky/TerminalGPT · terminalgpt/chat.py:134
def get_user_answer(self, messages: list):
"""Returns the answer from OpenAI API."""
while True:
try:
with yaspin(
Spinners.earth,
text=Style.BRIGHT + "Assistant:" + Style.RESET_ALL,
color="blue",
side="right",
):
return self.__client.chat.completions.create(
model=self.__model, messages=messages
)
except openai.RateLimitError:
self.__messages.pop(1)
time.sleep(0.5)
def exceeding_token_limit(self):