You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while loading a saved session, and I noticed the load_session() function never loads the messages from the saved session. Was that intended? or am i missing something?
to work around it i am using using the following code instead of using ai.load_session()
with open("chat_session.json", "rb") as f:
sess_dict = orjson.loads(f.read())
ai.new_session(**sess_dict, api_key=OPENAI_API_KEY)
list_dict = sess_dict['messages']
chat_messages = [ChatMessage.model_validate(item) for item in list_dict]
ai.default_session.messages = chat_messages
i can create a pull request if the maintainers of this repository find this to be a bug
The text was updated successfully, but these errors were encountered:
It does load the messages from a saved session file. This is the main reason I use the library, it makes few-shot prompting super simple. I have saved session files with fake user and assistant messages so that it knows how to respond to future prompts.
I did try but I can't seem to replicate your issue. All the messages load for me when using the load_session() method and I verified by dumping the messages using the get_session() method. Is it possible that the session file you are loading doesn't have any messages or maybe not formatted correctly?
Here is the code I used to test:
# create an instance of AIChat classai=AIChat(api_key=_key_, console=False, model="gpt-4-turbo", params={"temperature": 0.78, "max_tokens": 2048})
# Load a saved session JSON fileai.load_session(api_key=_key_, input_path="./ai_context/defender_generic.json")
# Dump the messages in that session as a list of ChatMessage objectsai.get_session(id="defender").messages
while loading a saved session, and I noticed the load_session() function never loads the messages from the saved session. Was that intended? or am i missing something?
to work around it i am using using the following code instead of using ai.load_session()
i can create a pull request if the maintainers of this repository find this to be a bug
The text was updated successfully, but these errors were encountered: