suriya7 commited on
Commit
e1a7c4f
·
verified ·
1 Parent(s): d91a982

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -14,12 +14,12 @@ llm = HuggingFaceHub(repo_id="suriya7/MaxMini-Instruct-248M",
14
  })
15
 
16
 
17
- template = """
18
- Please Answer the Question:
19
- previous chat: {previous_history}
20
- Human:{question}
21
- chatbot:
22
- """
23
 
24
  prompt = PromptTemplate(template=template,input_variables=['question','previous_history'])
25
 
@@ -45,10 +45,10 @@ st.info("MaxMini-Instruct-248M is a T5 (Text-To-Text Transfer Transformer) model
45
 
46
  st.session_state['history'] = []
47
 
48
- if 'message' not in st.session_state:
49
- st.session_state['message'] = ['Hey There! How Can I Assist You']
50
 
51
- st.session_state['past'] = [" "]
52
 
53
 
54
  # Create containers for chat history and user input
@@ -61,14 +61,14 @@ with container:
61
  if user_input:
62
  output = conversational_chat(user_input)
63
  # answer = response_generator(output)
64
- st.session_state['past'].append(user_input)
65
- st.session_state['message'].append(output)
66
 
67
 
68
- # Display chat history
69
- if st.session_state['message']:
70
  with response_container:
71
- for i in range(len(st.session_state['message'])):
72
- if i != 0:
73
- message(st.session_state["past"][i], is_user=True, key=str(i) + '_user', avatar_style="adventurer")
74
- message(st.session_state["message"][i], key=str(i), avatar_style="bottts")
 
14
  })
15
 
16
 
17
+ template = """You are a friendly chatbot called "MAXMINI" who give clear an well having a conversation with a human and you are created by suriya an AI Enthusiastic.
18
+ previous chat:
19
+ {previous_history}
20
+ Human:
21
+ {question}
22
+ Chatbot:"""
23
 
24
  prompt = PromptTemplate(template=template,input_variables=['question','previous_history'])
25
 
 
45
 
46
  st.session_state['history'] = []
47
 
48
+ if 'assistant' not in st.session_state:
49
+ st.session_state['assistant'] = ['Hey There! How Can I Assist You']
50
 
51
+ st.session_state['human'] = [" "]
52
 
53
 
54
  # Create containers for chat history and user input
 
61
  if user_input:
62
  output = conversational_chat(user_input)
63
  # answer = response_generator(output)
64
+ st.session_state['human'].append(user_input)
65
+ st.session_state['assistant'].append(output)
66
 
67
 
68
+ ## Display chat history
69
+ if st.session_state['assistant']:
70
  with response_container:
71
+ for i in range(len(st.session_state['assistant'])):
72
+ if i < len(st.session_state["human"]): # Check if 'human' list has enough elements
73
+ message(st.session_state["human"][i], is_user=True, key=str(i) + '_user', avatar_style="adventurer")
74
+ message(st.session_state["assistant"][i], key=str(i), avatar_style="bottts")