f64
commited on
Commit
·
2e745f7
1
Parent(s):
9d107de
- app.py +5 -6
- my_static_methods.py +13 -8
- pages/4_Просмотр_CSV.py +2 -2
- pages/8_Chat.py +10 -2
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -1,19 +1,18 @@
|
|
| 1 |
import streamlit as st, pandas as pd, numpy as np
|
| 2 |
|
| 3 |
-
st.set_page_config(
|
| 4 |
|
| 5 |
import my_static_methods as my_stm
|
| 6 |
-
st.
|
| 7 |
|
| 8 |
-
st.sidebar.markdown("
|
| 9 |
|
| 10 |
df = pd.DataFrame([
|
| 11 |
{"command": "st.selectbox", "rating": 4, "is_widget": True},
|
| 12 |
{"command": "st.balloons", "rating": 5, "is_widget": False},
|
| 13 |
{"command": "st.time_input", "rating": 3, "is_widget": True},
|
| 14 |
])
|
| 15 |
-
edited_df = st.data_editor(df, num_rows="dynamic")
|
| 16 |
|
|
|
|
| 17 |
favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
|
| 18 |
-
|
| 19 |
-
st.markdown(f"Your favorite command is **{favorite_command}** 🎚️")
|
|
|
|
| 1 |
import streamlit as st, pandas as pd, numpy as np
|
| 2 |
|
| 3 |
+
st.set_page_config(page_title="Предсказание V", page_icon="🦋", layout="wide") # set_page_config() can only be called once per app page, and must be called as the first Streamlit command in your script.
|
| 4 |
|
| 5 |
import my_static_methods as my_stm
|
| 6 |
+
st.html(my_stm.STYLE_CORRECTION)
|
| 7 |
|
| 8 |
+
st.sidebar.markdown("💎 Стартовая страница")
|
| 9 |
|
| 10 |
df = pd.DataFrame([
|
| 11 |
{"command": "st.selectbox", "rating": 4, "is_widget": True},
|
| 12 |
{"command": "st.balloons", "rating": 5, "is_widget": False},
|
| 13 |
{"command": "st.time_input", "rating": 3, "is_widget": True},
|
| 14 |
])
|
|
|
|
| 15 |
|
| 16 |
+
edited_df = st.sidebar.data_editor(df, num_rows="dynamic")
|
| 17 |
favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
|
| 18 |
+
st.sidebar.markdown(f"Your favorite command is **{favorite_command}** 🎚️")
|
|
|
my_static_methods.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
|
|
| 1 |
import os, io
|
| 2 |
-
import pandas as pd
|
|
|
|
| 3 |
import plotly.express as px
|
| 4 |
-
from typing import Union
|
| 5 |
import huggingface_hub
|
| 6 |
|
|
|
|
| 7 |
### remove decoration and popup menu button at top
|
| 8 |
STYLE_CORRECTION = " ".join([
|
| 9 |
"<style>",
|
|
@@ -46,11 +48,12 @@ def df_process_v_column(df: pd.DataFrame) -> pd.DataFrame:
|
|
| 46 |
|
| 47 |
|
| 48 |
###
|
| 49 |
-
def
|
|
|
|
| 50 |
#https://huggingface.co/datasets/f64k/gaziev/blob/main/TestData3_2204_noAB_gaziev.zip
|
| 51 |
dict_res = {}
|
| 52 |
-
for fl_name in
|
| 53 |
-
file_loaded = huggingface_hub.hf_hub_download(repo_id=
|
| 54 |
if os.path.exists(file_loaded):
|
| 55 |
df_loaded = pd.read_csv(file_loaded, sep=";", encoding = "utf-8", compression="zip")
|
| 56 |
dict_res[file_loaded] = df_process_v_column(df_loaded)
|
|
@@ -58,14 +61,16 @@ def load_gaziev_from_hf(repo_Id: str, lstTestFiles: list[str]) -> {str, pd.DataF
|
|
| 58 |
|
| 59 |
### список файлов (без уровня вложенности) в репо dataset
|
| 60 |
### https://huggingface.co/docs/huggingface_hub/en/guides/hf_file_system
|
| 61 |
-
def list_files_hf(
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
lst = fs.ls(path_hf, detail=False)
|
| 65 |
lst = [fname for fname in map(os.path.basename, lst) if fname[0] != "."]
|
| 66 |
return lst
|
| 67 |
|
| 68 |
def plotly_xyzv_scatter_gray(df3D):
|
|
|
|
| 69 |
color_discrete_map = dict(o='rgb(220,220,220)', p='rgb(90,1,1)', n='rgb(1,1,90)')
|
| 70 |
fig = px.scatter_3d(df3D, x='X', y='Y', z='Z', color="Vposneg", opacity=0.4, height=800, color_discrete_map=color_discrete_map)
|
| 71 |
fig.update_scenes(xaxis={"gridcolor":"rgba(30, 0, 0, 0.2)","color":"rgb(100, 0, 0)","showbackground":False},
|
|
|
|
| 1 |
+
from typing import Union
|
| 2 |
import os, io
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import numpy as np
|
| 5 |
import plotly.express as px
|
|
|
|
| 6 |
import huggingface_hub
|
| 7 |
|
| 8 |
+
|
| 9 |
### remove decoration and popup menu button at top
|
| 10 |
STYLE_CORRECTION = " ".join([
|
| 11 |
"<style>",
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
###
|
| 51 |
+
def load_dataframes_from_hf(repo_id: str, lstCsvFiles: list[str], hftoken: str) -> {str, pd.DataFrame}:
|
| 52 |
+
""" load dataframes from hf """
|
| 53 |
#https://huggingface.co/datasets/f64k/gaziev/blob/main/TestData3_2204_noAB_gaziev.zip
|
| 54 |
dict_res = {}
|
| 55 |
+
for fl_name in lstCsvFiles:
|
| 56 |
+
file_loaded = huggingface_hub.hf_hub_download(repo_id=repo_id, filename=fl_name, repo_type="dataset", token=hftoken)
|
| 57 |
if os.path.exists(file_loaded):
|
| 58 |
df_loaded = pd.read_csv(file_loaded, sep=";", encoding = "utf-8", compression="zip")
|
| 59 |
dict_res[file_loaded] = df_process_v_column(df_loaded)
|
|
|
|
| 61 |
|
| 62 |
### список файлов (без уровня вложенности) в репо dataset
|
| 63 |
### https://huggingface.co/docs/huggingface_hub/en/guides/hf_file_system
|
| 64 |
+
def list_files_hf(repo_id: str, hftoken: str) -> list[str]:
|
| 65 |
+
""" List files in HF repo """
|
| 66 |
+
fs = huggingface_hub.HfFileSystem(token=hftoken)
|
| 67 |
+
path_hf = f"datasets/{repo_id}"
|
| 68 |
lst = fs.ls(path_hf, detail=False)
|
| 69 |
lst = [fname for fname in map(os.path.basename, lst) if fname[0] != "."]
|
| 70 |
return lst
|
| 71 |
|
| 72 |
def plotly_xyzv_scatter_gray(df3D):
|
| 73 |
+
""" """
|
| 74 |
color_discrete_map = dict(o='rgb(220,220,220)', p='rgb(90,1,1)', n='rgb(1,1,90)')
|
| 75 |
fig = px.scatter_3d(df3D, x='X', y='Y', z='Z', color="Vposneg", opacity=0.4, height=800, color_discrete_map=color_discrete_map)
|
| 76 |
fig.update_scenes(xaxis={"gridcolor":"rgba(30, 0, 0, 0.2)","color":"rgb(100, 0, 0)","showbackground":False},
|
pages/4_Просмотр_CSV.py
CHANGED
|
@@ -12,7 +12,7 @@ st.html(my_stm.STYLE_CORRECTION)
|
|
| 12 |
REPO_ID = "f64k/gaziev"
|
| 13 |
st.sidebar.info("💽 сохраненные\n таблицы CSV")
|
| 14 |
|
| 15 |
-
lstTestFiles = my_stm.list_files_hf(REPO_ID)
|
| 16 |
#dictXYZV = my_stm.load_gaziev_from_hf(REPO_ID, lstTestFiles)
|
| 17 |
|
| 18 |
cols = st.columns(2)
|
|
@@ -20,7 +20,7 @@ cols = st.columns(2)
|
|
| 20 |
#key_xyz = st.selectbox("Выберите файл данных для просмотра таблицы и точек", dictXYZV.keys())
|
| 21 |
one_file_selected = cols[0].selectbox("Выберите файл данных для просмотра таблицы и точек", lstTestFiles)
|
| 22 |
if one_file_selected:
|
| 23 |
-
dict_ONE_XYZV = my_stm.
|
| 24 |
df_xyz = list(dict_ONE_XYZV.values())[0] #df_xyz = dictXYZV[key_xyz]
|
| 25 |
fig = my_stm.plotly_xyzv_scatter_gray(df_xyz)
|
| 26 |
|
|
|
|
| 12 |
REPO_ID = "f64k/gaziev"
|
| 13 |
st.sidebar.info("💽 сохраненные\n таблицы CSV")
|
| 14 |
|
| 15 |
+
lstTestFiles = my_stm.list_files_hf(REPO_ID, st.secrets["HF_WRITE"])
|
| 16 |
#dictXYZV = my_stm.load_gaziev_from_hf(REPO_ID, lstTestFiles)
|
| 17 |
|
| 18 |
cols = st.columns(2)
|
|
|
|
| 20 |
#key_xyz = st.selectbox("Выберите файл данных для просмотра таблицы и точек", dictXYZV.keys())
|
| 21 |
one_file_selected = cols[0].selectbox("Выберите файл данных для просмотра таблицы и точек", lstTestFiles)
|
| 22 |
if one_file_selected:
|
| 23 |
+
dict_ONE_XYZV = my_stm.load_dataframes_from_hf(REPO_ID, [one_file_selected], st.secrets["HF_WRITE"])
|
| 24 |
df_xyz = list(dict_ONE_XYZV.values())[0] #df_xyz = dictXYZV[key_xyz]
|
| 25 |
fig = my_stm.plotly_xyzv_scatter_gray(df_xyz)
|
| 26 |
|
pages/8_Chat.py
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
|
|
| 1 |
import streamlit as st, pandas as pd, numpy as np
|
| 2 |
import my_static_methods as my_stm
|
|
|
|
| 3 |
st.markdown(my_stm.STYLE_CORRECTION, unsafe_allow_html=True)
|
| 4 |
st.sidebar.markdown("# Переговоры 💬")
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
messages = st.container() # height=300
|
| 8 |
if prompt := st.chat_input("Спрашивайте тут : "):
|
| 9 |
messages.chat_message("user").write(prompt)
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os, re, sys, time, math, shutil, urllib, string, random, pickle, zipfile, datetime
|
| 2 |
import streamlit as st, pandas as pd, numpy as np
|
| 3 |
import my_static_methods as my_stm
|
| 4 |
+
from faker import Faker
|
| 5 |
st.markdown(my_stm.STYLE_CORRECTION, unsafe_allow_html=True)
|
| 6 |
st.sidebar.markdown("# Переговоры 💬")
|
| 7 |
|
| 8 |
+
fake = Faker()
|
| 9 |
+
fakeRU = Faker("ru_RU")
|
| 10 |
+
|
| 11 |
messages = st.container() # height=300
|
| 12 |
if prompt := st.chat_input("Спрашивайте тут : "):
|
| 13 |
messages.chat_message("user").write(prompt)
|
| 14 |
+
answer = prompt[::-1]
|
| 15 |
+
strEnFakeText = fake.paragraph(nb_sentences=4, variable_nb_sentences=False)
|
| 16 |
+
strRuFakeText = fakeRU.paragraph(nb_sentences=4, variable_nb_sentences=False)
|
| 17 |
+
answer = f"{datetime.datetime.now():%d.%m.%Y %H:%M:%S}\n {strEnFakeText}\n {strRuFakeText}"
|
| 18 |
+
messages.chat_message("boss").write(f"{answer}") # assistant
|
requirements.txt
CHANGED
|
@@ -4,4 +4,5 @@ datasets
|
|
| 4 |
scikit-learn
|
| 5 |
plotly
|
| 6 |
pandas
|
| 7 |
-
numpy
|
|
|
|
|
|
| 4 |
scikit-learn
|
| 5 |
plotly
|
| 6 |
pandas
|
| 7 |
+
numpy
|
| 8 |
+
faker
|