File size: 2,179 Bytes
2e745f7
72813c4
2e745f7
ef9cc97
74fa2db
 
 
 
bf0d601
74fa2db
55e5ff9
ef9cc97
 
b34e7e7
9b5fd46
74fa2db
72813c4
 
9b5fd46
b34e7e7
 
9b5fd46
b34e7e7
5d61439
74fa2db
9b5fd46
 
7d38799
9b5fd46
 
 
 
 
 
b34e7e7
9b5fd46
2e745f7
 
 
fb555cd
3a25d0d
72813c4
2e745f7
 
 
ed3ce54
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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