import os, re, sys, time, math, shutil, urllib, string, random, pickle, zipfile, datetime import streamlit as st, pandas as pd, numpy as np from faker import Faker import my_static_tools as mst from my_static_tools import HF_tools as hft from my_static_tools import XYZV_tools as xvt st.set_page_config(page_title="Чат страница недоделанная", page_icon="💬", layout="wide", initial_sidebar_state="expanded") # https://docs.gspread.org/en/latest/user-guide.html#updating-cells # https://docs.streamlit.io/develop/tutorials/databases/private-gsheet # https://github.com/streamlit/gsheets-connection/blob/main/examples/pages/Service_Account_Example.py#L167 #from streamlit_gsheets import GSheetsConnection # st-gsheets-connection - конфликт с pandas 2.2.2 st.html(mst.STYLE_CORRECTION) st.sidebar.markdown("# Переговоры 💬") # Create a connection object. #conn = st.connection("gsheets", type=GSheetsConnection) #st.write(conn) #st.help(conn) REPO = mst.HfRepo("f64k/gaziev", "dataset", lambda: st.secrets["HF_WRITE"]) lstRepoFiles = hft.list_files_hf(REPO) # список уже имеющихся в репозитории файлов dictTestFilesIdXyz = {f.upper().replace("ID_XYZ/",""): f.upper() for f in lstRepoFiles if f.upper().startswith("ID_XYZ/")} _ = """ if st.button("Update worksheet"): dict_ONE_IDXYZ = my_stm.load_dataframes_from_hf(REPO, ["ID_XYZ/IDXYZ_5X7_BBB011116_DDD011112.CSV"]) if len(dict_ONE_IDXYZ) > 0: df_idxyz = list(dict_ONE_IDXYZ.values())[0] dfUpdSheet = conn.update(worksheet="sh2", data=df_idxyz) st.write(dfUpdSheet) """ fake = Faker() fakeRU = Faker("ru_RU") messages = st.container() # height=300 if prompt := st.chat_input("Спрашивайте тут : "): messages.chat_message("user").write(prompt) answer = prompt[::-1] strEnFakeText = fake.paragraph(nb_sentences=4, variable_nb_sentences=False) strRuFakeText = fakeRU.paragraph(nb_sentences=4, variable_nb_sentences=False) answer = f"{datetime.datetime.now():%d.%m.%Y %H:%M:%S} \n {strEnFakeText} \n {strRuFakeText}" messages.chat_message("ai").write(f"{answer}") # assistant