Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,12 +16,12 @@ llm = HuggingFaceHub(repo_id="suriya7/MaxMini-Instruct-248M",
|
|
| 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 |
-
{
|
| 20 |
User:
|
| 21 |
{question}
|
| 22 |
Chatbot:"""
|
| 23 |
|
| 24 |
-
prompt = PromptTemplate(template=template,input_variables=['question','
|
| 25 |
|
| 26 |
llm_chain = LLMChain(
|
| 27 |
llm=llm,
|
|
@@ -33,10 +33,10 @@ previous_response = ""
|
|
| 33 |
def conversational_chat(user_query):
|
| 34 |
global previous_response
|
| 35 |
previous_response = "".join([f"User: {i[0]}\nChatbot: {i[1]}" for i in st.session_state['history'] if i is not None])
|
| 36 |
-
print(previous_response)
|
| 37 |
result = llm_chain.predict(
|
| 38 |
question=user_query,
|
| 39 |
-
|
| 40 |
)
|
| 41 |
st.session_state['history'].append((user_query, result))
|
| 42 |
return result
|
|
@@ -45,10 +45,14 @@ def conversational_chat(user_query):
|
|
| 45 |
st.title("Chat Bot MaxMini:")
|
| 46 |
st.text("I am MaxMini Your Friendly Assitant")
|
| 47 |
st.markdown("Built by [Suriya❤️](https://github.com/theSuriya)")
|
| 48 |
-
st.session_state['history'] = []
|
| 49 |
|
| 50 |
-
if '
|
|
|
|
|
|
|
|
|
|
| 51 |
st.session_state['human'] = ["Hello MaxMini"]
|
|
|
|
|
|
|
| 52 |
st.session_state['assistant'] = ['Hey There! How Can I Assist You']
|
| 53 |
|
| 54 |
|
|
|
|
| 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 |
+
{chat_history}
|
| 20 |
User:
|
| 21 |
{question}
|
| 22 |
Chatbot:"""
|
| 23 |
|
| 24 |
+
prompt = PromptTemplate(template=template,input_variables=['question','chat_history'])
|
| 25 |
|
| 26 |
llm_chain = LLMChain(
|
| 27 |
llm=llm,
|
|
|
|
| 33 |
def conversational_chat(user_query):
|
| 34 |
global previous_response
|
| 35 |
previous_response = "".join([f"User: {i[0]}\nChatbot: {i[1]}" for i in st.session_state['history'] if i is not None])
|
| 36 |
+
print(f"this is my previous {previous_response}")
|
| 37 |
result = llm_chain.predict(
|
| 38 |
question=user_query,
|
| 39 |
+
chat_history = previous_response
|
| 40 |
)
|
| 41 |
st.session_state['history'].append((user_query, result))
|
| 42 |
return result
|
|
|
|
| 45 |
st.title("Chat Bot MaxMini:")
|
| 46 |
st.text("I am MaxMini Your Friendly Assitant")
|
| 47 |
st.markdown("Built by [Suriya❤️](https://github.com/theSuriya)")
|
|
|
|
| 48 |
|
| 49 |
+
if 'history' not in st.session_state:
|
| 50 |
+
st.session_state['history'] = []
|
| 51 |
+
|
| 52 |
+
if 'human' not in st.session_state:
|
| 53 |
st.session_state['human'] = ["Hello MaxMini"]
|
| 54 |
+
|
| 55 |
+
if 'assistant' not in st.session_state:
|
| 56 |
st.session_state['assistant'] = ['Hey There! How Can I Assist You']
|
| 57 |
|
| 58 |
|