Leon-Sander / local_multimodal_ai_chat

GNU General Public License v3.0
101 stars 66 forks source link

Improper chat session file format on Windows #3

Closed NEUR0515 closed 5 months ago

NEUR0515 commented 5 months ago

Hey Leon! Thank you so much for taking the time to put all this together! I had exactly the same project in mind and am really glad I came across your YouTube video!

When trying to run this on Windows I had errors with creating a new chat session as the filename had the character : in the name.

I resolved this with a very basic fix of importing datetime into app.py and changing the save_chat_history() function to the below:

def save_chat_history():
    if st.session_state.history != []:
        if st.session_state.session_key == "new_session":
            now = datetime.now() # current date and time
            st.session_state.new_session_key = now.strftime("%m%d%Y%H%M%S") + ".json"
            save_chat_history_json(st.session_state.history, config["chat_history_path"] + st.session_state.new_session_key)
        else:
            save_chat_history_json(st.session_state.history, config["chat_history_path"] + st.session_state.session_key)

Thought I'd create an issue just in case someone else has the same problem. Thank you again for the time and effort you put into this.

NEUR0515 commented 5 months ago

Hey Leon! Thank you so much for taking the time to put all this together! I had exactly the same project in mind and am really glad I came across your YouTube video!

When trying to run this on Windows I had errors with creating a new chat session as the filename had the character : in the name.

I resolved this with a very basic fix of importing datetime into app.py and changing the save_chat_history() function to the below:

def save_chat_history():
    if st.session_state.history != []:
        if st.session_state.session_key == "new_session":
            now = datetime.now() # current date and time
            st.session_state.new_session_key = now.strftime("%m%d%Y%H%M%S") + ".json"
            save_chat_history_json(st.session_state.history, config["chat_history_path"] + st.session_state.new_session_key)
        else:
            save_chat_history_json(st.session_state.history, config["chat_history_path"] + st.session_state.session_key)

Thought I'd create an issue just in case someone else has the same problem. Thank you again for the time and effort you put into this.

Scratch this, I just found the get_timestamp() function in utils.py.

I amended line 17 in utils.py to look like the below: return datetime.now().strftime("%Y%m%d%H%M%S")

Leon-Sander commented 5 months ago

@NEUR0515 Thank you for mentioning that, I am going to change the format to "%Y%m%d%H%M_%S", then hopefully no one will have this issue anymore.