mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-19 00:02:11 +00:00
Fix+1
This commit is contained in:
@@ -602,17 +602,17 @@ async def handle_response(prompt, vykidailo, bartender, history, username, music
|
|||||||
json.dump(file_data, file_memory, indent=4)
|
json.dump(file_data, file_memory, indent=4)
|
||||||
history = []
|
history = []
|
||||||
history.append(GPT_SETTINGS[0])
|
history.append(GPT_SETTINGS[0])
|
||||||
tokens = num_tokens_from_string(GPT_SETTINGS[0], "gpt-4")
|
chat_GPT_tokens = num_tokens_from_string(GPT_SETTINGS[0], "gpt-4")
|
||||||
|
|
||||||
for (slowo, reakcja) in word_reactions.items():
|
for (slowo, reakcja) in word_reactions.items():
|
||||||
if not reakcja[3]:
|
if not reakcja[3]:
|
||||||
content = "Kiedy słyszysz " + slowo + " to reagujesz lub dzieje się to " + reakcja[0]
|
content = "Kiedy słyszysz " + slowo + " to reagujesz lub dzieje się to " + reakcja[0]
|
||||||
temp = {"role": "system", "content": content}
|
temp = {"role": "system", "content": content}
|
||||||
tokens += num_tokens_from_string(temp, "gpt-4")
|
chat_GPT_tokens += num_tokens_from_string(temp, "gpt-4")
|
||||||
history.append(temp)
|
history.append(temp)
|
||||||
|
|
||||||
final_prompt = username + ":" + prompt
|
final_prompt = username + ":" + prompt
|
||||||
logger.error("Liczba tokenów przed dodaniem historii %s", tokens)
|
logger.error("Liczba tokenów przed dodaniem historii %s", chat_GPT_tokens)
|
||||||
if music:
|
if music:
|
||||||
algorithm = "gpt-3.5-turbo-16k"
|
algorithm = "gpt-3.5-turbo-16k"
|
||||||
table = message_table_muzyka
|
table = message_table_muzyka
|
||||||
@@ -623,16 +623,17 @@ async def handle_response(prompt, vykidailo, bartender, history, username, music
|
|||||||
token_amount = 8192
|
token_amount = 8192
|
||||||
|
|
||||||
prompt_tokens = num_tokens_from_string({"role": "user", "content": final_prompt}, "gpt-4")
|
prompt_tokens = num_tokens_from_string({"role": "user", "content": final_prompt}, "gpt-4")
|
||||||
|
temptable = []
|
||||||
for i in reversed(table):
|
for i in reversed(table):
|
||||||
temp_token = num_tokens_from_string(i, "gpt-4")
|
temp_token = num_tokens_from_string(i, "gpt-4")
|
||||||
logger.error("Liczba tokenow %s prompt token %s temp token %s", tokens, prompt_tokens, temp_token)
|
logger.error("Liczba tokenow %s prompt token %s temp token %s", chat_GPT_tokens, prompt_tokens, temp_token)
|
||||||
if tokens < token_amount + prompt_tokens + temp_token:
|
if chat_GPT_tokens < token_amount + prompt_tokens + temp_token:
|
||||||
history.append(i)
|
temptable.insert(1, i)
|
||||||
tokens += temp_token
|
chat_GPT_tokens += temp_token
|
||||||
|
history.extend(temptable)
|
||||||
temp = {"role": "user", "content": final_prompt}
|
temp = {"role": "user", "content": final_prompt}
|
||||||
history.append(temp)
|
history.append(temp)
|
||||||
logger.error("Liczba tokenów wyslana %s", tokens)
|
logger.error("Liczba tokenów wyslana %s", chat_GPT_tokens)
|
||||||
|
|
||||||
response = await openai.ChatCompletion.acreate(
|
response = await openai.ChatCompletion.acreate(
|
||||||
model=algorithm, messages=history
|
model=algorithm, messages=history
|
||||||
|
|||||||
Reference in New Issue
Block a user