shaneperry0101 commited on
Commit
2fffd93
·
verified ·
1 Parent(s): 6bd7f31

fix(test): find bug

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -3,7 +3,7 @@ from transformers import pipeline
3
 
4
 
5
  # Load the conversational model from Hugging Face
6
- chatbot = pipeline('conversational', model='microsoft/DialoGPT-medium')
7
 
8
  # Initialize session state for storing the conversation
9
  if 'conversation' not in st.session_state:
@@ -13,21 +13,21 @@ if 'conversation' not in st.session_state:
13
  st.title("Chatbot Application")
14
  user_input = st.text_input("You:", key="input")
15
 
16
- # if st.button("Send"):
17
- # if user_input:
18
- # # Append user input to the conversation
19
- # st.session_state.conversation.append({"role": "user", "content": user_input})
20
 
21
- # # Generate response
22
- # response = chatbot(user_input)
23
- # bot_response = response[0]['generated_text']
24
 
25
- # # Append bot response to the conversation
26
- # st.session_state.conversation.append({"role": "bot", "content": bot_response})
27
 
28
- # # Display the conversation
29
- # for message in st.session_state.conversation:
30
- # if message["role"] == "user":
31
- # st.text_area("You:", value=message["content"], key=f"user_{message['content']}", height=50)
32
- # else:
33
- # st.text_area("Bot:", value=message["content"], key=f"bot_{message['content']}", height=50)
 
3
 
4
 
5
  # Load the conversational model from Hugging Face
6
+ chatbot = pipeline('text-generation', model='shaneperry0101/Health-Llama-3.2-1B')
7
 
8
  # Initialize session state for storing the conversation
9
  if 'conversation' not in st.session_state:
 
13
  st.title("Chatbot Application")
14
  user_input = st.text_input("You:", key="input")
15
 
16
+ if st.button("Send"):
17
+ if user_input:
18
+ # Append user input to the conversation
19
+ st.session_state.conversation.append({"role": "user", "content": user_input})
20
 
21
+ # Generate response
22
+ response = chatbot(user_input)
23
+ bot_response = response[0]['generated_text']
24
 
25
+ # Append bot response to the conversation
26
+ st.session_state.conversation.append({"role": "bot", "content": bot_response})
27
 
28
+ # Display the conversation
29
+ for message in st.session_state.conversation:
30
+ if message["role"] == "user":
31
+ st.text_area("You:", value=message["content"], key=f"user_{message['content']}", height=50)
32
+ else:
33
+ st.text_area("Bot:", value=message["content"], key=f"bot_{message['content']}", height=50)