mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Fix tokens
This commit is contained in:
@@ -606,25 +606,27 @@ async def handle_response(prompt, vykidailo, bartender, history, username, music
|
||||
if music:
|
||||
algorithm = "gpt-3.5-turbo-16k"
|
||||
table = message_table_muzyka
|
||||
token_amount = 16000
|
||||
token_amount = 16384
|
||||
else:
|
||||
table = MESSAGE_TABLE
|
||||
algorithm = "gpt-4"
|
||||
token_amount = 80000
|
||||
token_amount = 8192
|
||||
|
||||
prompt_tokens = num_tokens_from_string(final_prompt, "gpt-4")
|
||||
for i in reversed(table):
|
||||
temp_token = num_tokens_from_string(i["content"], "gpt-4")
|
||||
logger.error("Liczba tokenow %s prompt token %s temp token %s", tokens, prompt_tokens, temp_token)
|
||||
if tokens < token_amount + prompt_tokens + temp_token:
|
||||
history.append(i)
|
||||
tokens += temp_token
|
||||
|
||||
temp = {"role": "user", "content": final_prompt}
|
||||
history.append(temp)
|
||||
logger.error("Liczba tokenów wyslana %s", tokens)
|
||||
|
||||
response = await openai.ChatCompletion.acreate(
|
||||
model=algorithm, messages=history
|
||||
)
|
||||
logger.error("Liczba tokenów przed dodaniem historii %s", tokens)
|
||||
logger.info("Historia wysłana:")
|
||||
logger.info(history)
|
||||
await asyncio.sleep(10)
|
||||
|
||||
Reference in New Issue
Block a user