fehmikaya commited on
Commit
b4165d8
·
verified ·
1 Parent(s): 97b7315

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -9,7 +9,7 @@ st.title("Llama Chatbot")
9
  # Get the API key from the environment variable
10
  API_KEY = os.getenv("HF_TOKEN")
11
 
12
- icons = {"assistant": "robot.png", "user": "man-kddi.png"}
13
 
14
  if API_KEY is None:
15
  st.error("API key not found. Please set the HF_TOKEN secret in your Hugging Face Space.")
@@ -30,6 +30,7 @@ if "messages" not in st.session_state:
30
  You give the information about Fehmi only when specificly asked.
31
  """
32
  }]
 
33
 
34
  def handle_query(query):
35
  response = requests.post(API_URL, headers=headers, json={"inputs": json.dumps(st.session_state.messages)})
@@ -44,9 +45,6 @@ def streamer(text):
44
  yield i
45
  time.sleep(0.001)
46
 
47
- if 'messages' not in st.session_state:
48
- st.session_state.messages = [{'role': 'assistant', "content": 'ask me anything'}]
49
-
50
  for message in st.session_state.messages:
51
  with st.chat_message(message['role'], avatar=icons[message['role']]):
52
  st.write(message['content'])
 
9
  # Get the API key from the environment variable
10
  API_KEY = os.getenv("HF_TOKEN")
11
 
12
+ icons = {"assistant": "robot.png", "user": "man-kddi.png", "system": "man-kddi.png"}
13
 
14
  if API_KEY is None:
15
  st.error("API key not found. Please set the HF_TOKEN secret in your Hugging Face Space.")
 
30
  You give the information about Fehmi only when specificly asked.
31
  """
32
  }]
33
+ st.session_state.messages.append({'role': 'assistant', "content": 'ask me anything'})
34
 
35
  def handle_query(query):
36
  response = requests.post(API_URL, headers=headers, json={"inputs": json.dumps(st.session_state.messages)})
 
45
  yield i
46
  time.sleep(0.001)
47
 
 
 
 
48
  for message in st.session_state.messages:
49
  with st.chat_message(message['role'], avatar=icons[message['role']]):
50
  st.write(message['content'])