Spestly commited on
Commit
77fcbba
Β·
verified Β·
1 Parent(s): fb78f43

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -4
app.py CHANGED
@@ -3,9 +3,7 @@ import torch
3
  import streamlit as st
4
  from transformers import AutoTokenizer, AutoModelForCausalLM
5
  from huggingface_hub import login
6
- import re
7
  import os
8
- from PIL import Image
9
 
10
  # Load Hugging Face token
11
  HF_TOKEN = os.getenv("HF_TOKEN")
@@ -29,6 +27,28 @@ MODELS = {
29
  USER_PFP = "user.png" # Hugging Face user avatar
30
  AI_PFP = "ai_pfp.png" # Replace with the path to your AI's image or a URL
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  class AtlasInferenceApp:
33
  def __init__(self):
34
  if "current_model" not in st.session_state:
@@ -81,7 +101,7 @@ class AtlasInferenceApp:
81
  "config": {
82
  "name": f"{MODELS[model_key]['name']} {model_size}",
83
  "path": model_path,
84
- "system_prompt": os.getenv(MODELS[model_key]["system_prompt_env"]), # Load system prompt from env
85
  }
86
  })
87
  return f"βœ… {MODELS[model_key]['name']} {model_size} loaded successfully!"
@@ -89,7 +109,7 @@ class AtlasInferenceApp:
89
  return f"❌ Error: {str(e)}"
90
 
91
  def respond(self, message, max_tokens, temperature, top_p, top_k, image=None):
92
- if not st.session_state.current_model["model"]:
93
  return "⚠️ Please select and load a model first"
94
 
95
  try:
 
3
  import streamlit as st
4
  from transformers import AutoTokenizer, AutoModelForCausalLM
5
  from huggingface_hub import login
 
6
  import os
 
7
 
8
  # Load Hugging Face token
9
  HF_TOKEN = os.getenv("HF_TOKEN")
 
27
  USER_PFP = "user.png" # Hugging Face user avatar
28
  AI_PFP = "ai_pfp.png" # Replace with the path to your AI's image or a URL
29
 
30
+ # Custom CSS for blue sliders and button
31
+ st.markdown(
32
+ """
33
+ <style>
34
+ /* Blue slider */
35
+ .stSlider > div > div > div > div {
36
+ background-color: #1f78b4 !important;
37
+ }
38
+ /* Blue button */
39
+ .stButton > button {
40
+ background-color: #1f78b4 !important;
41
+ color: white !important;
42
+ border: none !important;
43
+ }
44
+ .stButton > button:hover {
45
+ background-color: #16609a !important;
46
+ }
47
+ </style>
48
+ """,
49
+ unsafe_allow_html=True,
50
+ )
51
+
52
  class AtlasInferenceApp:
53
  def __init__(self):
54
  if "current_model" not in st.session_state:
 
101
  "config": {
102
  "name": f"{MODELS[model_key]['name']} {model_size}",
103
  "path": model_path,
104
+ "system_prompt": os.getenv(MODELS[model_key]["system_prompt_env"], "Default system prompt"), # Load system prompt from env
105
  }
106
  })
107
  return f"βœ… {MODELS[model_key]['name']} {model_size} loaded successfully!"
 
109
  return f"❌ Error: {str(e)}"
110
 
111
  def respond(self, message, max_tokens, temperature, top_p, top_k, image=None):
112
+ if not st.session_state.current_model["model"] or not st.session_state.current_model["tokenizer"]:
113
  return "⚠️ Please select and load a model first"
114
 
115
  try: