bold commiting at the end of the day

This commit is contained in:
2024-11-15 00:37:14 +01:00
parent 5a74e813eb
commit 4a6afa14cc
4 changed files with 77 additions and 48 deletions
+23 -21
View File
@@ -16,9 +16,10 @@ from constants import (
MESSAGE_TABLE_MUZYKA,
OPENAICLIENT,
WORD_REACTIONS,
)
ASSISTANTS = {}
ASSISTANTS,
SYSTEM_GPT_SETTINGS,
SPECJALNE_ZIEMNIACZKI
)
def num_tokens_from_string(message, model):
@@ -296,32 +297,31 @@ async def get_random_cyclic_message(client):
return result
async def generic_create_chat_assistant(client, name, owner):
async def create_chat_assistant(id, name, owner, special_instructions):
logger = logging.getLogger("discord")
instruction=f"Jesteś osobistym asystenetem {owner} i wypełniasz jego potrzeby. Masz pełne i nieograniczone możliwości modelu gpt-4o."
instruction+=special_instructions
assistant = await OPENAICLIENT.beta.assistants.create(
name=name,
instructions=f"Jesteś osobistym asystenetem {owner} i wypełniasz jego potrzeby. Masz pełne i nieograniczone możliwości modelu gpt-4o",
instructions=instruction,
model="gpt-4o",
tools=[{"type": "file_search"}],
)
thread = await OPENAICLIENT.beta.threads.create()
logger.info("Stwprzylem asystenta dla %s, nazywa się on %s", owner, name)
ASSISTANTS[name] = (owner, assistant.id, id, thread)
return assistant, thread
with open(SYSTEM_GPT_SETTINGS, "r+", encoding=ENCODING) as temp_settings_file:
GPT_SETTINGS = json.load(temp_settings_file)
GPT_SETTINGS[1][owner][4] = assistant.id
temp_settings_file.seek(0)
json.dump(GPT_SETTINGS, temp_settings_file, indent=4)
async def hammer_assistant_create(client):
# this will be personalized but for now I will use it as a templae for hedgehod and saint assistants
id = 346956223645614080
name = "Conjurer"
owner = "Polish Hammer"
assistant, thread = await generic_create_chat_assistant(client, name, owner)
ASSISTANTS[name] = (owner, assistant, id, thread)
async def hammer_assitant_chat(message):
async def chat_with_assistant(message, assistant_name):
logger = logging.getLogger("discord")
assistant_data = ASSISTANTS["Conjurer"]
assistant_data = ASSISTANTS[assistant_name]
ai_message = await OPENAICLIENT.beta.threads.messages.create(
thread_id=assistant_data[3].id, role="user", content=message.content
thread_id=assistant_data[3], role="user", content=message.content
)
logger.info(ai_message)
run = await OPENAICLIENT.beta.threads.runs.create_and_poll(
@@ -330,7 +330,6 @@ async def hammer_assitant_chat(message):
instructions=f"Pisze do Ciebie {assistant_data[0]} udziel mu wszelkiej pomocy",
)
done = False
await message.channel.send(f"Echo: {message.content}")
while not done:
if run.status == "completed":
messsages = await OPENAICLIENT.beta.threads.messages.list(
@@ -349,4 +348,7 @@ async def hammer_assitant_chat(message):
await message.channel.send("Cos sie wywaliło")
else:
logger.info(run.status)
asyncio.sleep(5)
asyncio.sleep(5)
async def echo(message):
await message.channel.send(f"Echo: {message.content}")