virtUOS / kiwi

A simple and configurable portal to proxy to llms.
https://virtuos.github.io/kiwi/
GNU Affero General Public License v3.0
2 stars 3 forks source link

Error due to deprecated function #11

Closed tibroc closed 7 months ago

tibroc commented 7 months ago
st.cache is deprecated. Please use one of Streamlit's new caching commands, st.cache_data or st.cache_resource. Based on this function's return value of type bytes, we recommend using st.cache_data.

https://docs.streamlit.io/library/advanced-features/caching

Odrec commented 7 months ago

In the file encrypted_cookie_manager.py from the package streamlit_cookies_manager. Change this:

@st.cache
def key_from_parameters(salt: bytes, iterations: int, password: str):
    kdf = PBKDF2HMAC(
        algorithm=hashes.SHA256(),
        length=32,
        salt=salt,
        iterations=iterations,
    )

    return base64.urlsafe_b64encode(kdf.derive(password.encode('utf-8')))

to this

@st.cache_data
def key_from_parameters(salt: bytes, iterations: int, password: str):
    kdf = PBKDF2HMAC(
        algorithm=hashes.SHA256(),
        length=32,
        salt=salt,
        iterations=iterations,
    )

    return base64.urlsafe_b64encode(kdf.derive(password.encode('utf-8')))

That should solve the issue.

tibroc commented 7 months ago

The package seems to be unmaintained since three years, we should switch to another, or we need to maintain this ourselves.

tibroc commented 7 months ago

Maybe something like https://discuss.streamlit.io/t/streamlit-cookies-which-package-to-use-so-many-of-them/50500

Odrec commented 7 months ago

Ok, I'll check it out

Odrec commented 7 months ago

Maybe something like https://discuss.streamlit.io/t/streamlit-cookies-which-package-to-use-so-many-of-them/50500

I remember now why I chose this package. The one of extra_streamlit_components apparently has the issue of not working with a docker container

https://discuss.streamlit.io/t/cookies-support-in-streamlit/16144/50?page=2

I am using the cookies manager with following code. my code works in local environment, but i need to deploy my application in a docker container, and surprisingly application is not able to store cookies there, and not even throwing any error.

Odrec commented 7 months ago

In the meantime, installing this: https://github.com/ktosiek/streamlit-cookies-manager/pull/7/commits/6bf9704f0813f69bc770da2192bd718749ae2d4b

Should solve the deprecated error message without having to change any files manually. I updated the requirements