Update src/streamlit_app.py
Browse files- src/streamlit_app.py +16 -8
src/streamlit_app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
-
import os
|
2 |
-
|
|
|
3 |
import streamlit as st
|
|
|
|
|
4 |
from huggingface_hub import InferenceClient
|
5 |
import re
|
6 |
import gspread
|
@@ -45,7 +48,9 @@ class ConfigManager:
|
|
45 |
self.google_creds_json = os.getenv("GOOGLE_SHEETS_CREDENTIALS")
|
46 |
self.google_sheets_id = os.getenv("GOOGLE_SHEETS_ID")
|
47 |
|
48 |
-
|
|
|
|
|
49 |
missing_vars = []
|
50 |
|
51 |
def get_google_client(self):
|
@@ -127,13 +132,16 @@ class GoogleSheetsLogger:
|
|
127 |
|
128 |
|
129 |
class AIAssistant:
|
130 |
-
def __init__(self, config
|
131 |
-
self.model =
|
|
|
|
|
|
|
|
|
132 |
self.client = InferenceClient(
|
133 |
model=self.model,
|
134 |
-
token=
|
135 |
timeout=60.0,
|
136 |
-
provider="hf-inference",
|
137 |
)
|
138 |
|
139 |
self.base_prompt = f"""
|
@@ -846,4 +854,4 @@ def main():
|
|
846 |
|
847 |
|
848 |
if __name__ == "__main__":
|
849 |
-
main()
|
|
|
1 |
+
import os, pathlib
|
2 |
+
os.environ.setdefault("HOME", "/tmp")
|
3 |
+
pathlib.Path("/tmp/.streamlit").mkdir(parents =True , exist_ok=True)
|
4 |
import streamlit as st
|
5 |
+
st.set_option("browser.gatherUsageStats", False)
|
6 |
+
import time
|
7 |
from huggingface_hub import InferenceClient
|
8 |
import re
|
9 |
import gspread
|
|
|
48 |
self.google_creds_json = os.getenv("GOOGLE_SHEETS_CREDENTIALS")
|
49 |
self.google_sheets_id = os.getenv("GOOGLE_SHEETS_ID")
|
50 |
|
51 |
+
|
52 |
+
|
53 |
+
|
54 |
missing_vars = []
|
55 |
|
56 |
def get_google_client(self):
|
|
|
132 |
|
133 |
|
134 |
class AIAssistant:
|
135 |
+
def __init__(self, config):
|
136 |
+
self.model = os.getenv("HF_MODEL", "HuggingFaceH4/zephyr-7b-beta")
|
137 |
+
token = os.getenv("HF_TOKEN")
|
138 |
+
if os.getenv("SPACE_ID") or os.getenv("HF_SPACE_ID"):
|
139 |
+
token = None
|
140 |
+
|
141 |
self.client = InferenceClient(
|
142 |
model=self.model,
|
143 |
+
token=token,
|
144 |
timeout=60.0,
|
|
|
145 |
)
|
146 |
|
147 |
self.base_prompt = f"""
|
|
|
854 |
|
855 |
|
856 |
if __name__ == "__main__":
|
857 |
+
main()
|