omerdan03 commited on
Commit
7da8368
1 Parent(s): 519b826

use demo chat

Browse files
Files changed (4) hide show
  1. LLM.py +5 -1
  2. app.py +44 -7
  3. app2.py +11 -0
  4. app22.py +0 -22
LLM.py CHANGED
@@ -28,6 +28,7 @@ class Chat:
28
  self.history.append(["human", qn])
29
  self.history.append(["AI", respond])
30
  print(f"AI: {respond}")
 
31
 
32
  class LLM:
33
  MODEL = "mosaicml/mpt-7b-chat"
@@ -77,11 +78,14 @@ class LLM:
77
  if __name__ == "__main__":
78
  # model = input("model name: ")
79
  model = "gorkemgoknar/gpt2chatbotenglish"
 
 
80
  llm = LLM(model)
81
 
82
  chat = llm.get_chat(context=LLM.CONSTEXT)
 
83
  while True:
84
  qn = input("Question: ")
85
- if qn == "exit":
86
  break
87
  chat.answerStoreHistory(qn=qn)
 
28
  self.history.append(["human", qn])
29
  self.history.append(["AI", respond])
30
  print(f"AI: {respond}")
31
+ return respond
32
 
33
  class LLM:
34
  MODEL = "mosaicml/mpt-7b-chat"
 
78
  if __name__ == "__main__":
79
  # model = input("model name: ")
80
  model = "gorkemgoknar/gpt2chatbotenglish"
81
+ model = "decapoda-research/llama-7b-hf"
82
+ model = "mosaicml/mpt-7b-chat"
83
  llm = LLM(model)
84
 
85
  chat = llm.get_chat(context=LLM.CONSTEXT)
86
+ print("type 'exit' or 'end' to end the chat")
87
  while True:
88
  qn = input("Question: ")
89
+ if qn in ["exit", "end"]:
90
  break
91
  chat.answerStoreHistory(qn=qn)
app.py CHANGED
@@ -1,11 +1,48 @@
 
1
  import streamlit as st
2
 
3
- # Title and input
4
- st.title("Reverse Text")
5
- input_text = st.text_input("Enter some text")
 
 
6
 
7
- # Reverse the input text
8
- reversed_text = input_text[::-1]
9
 
10
- # Display the reversed text
11
- st.write("Reversed text:", reversed_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from LLM import LLM
2
  import streamlit as st
3
 
4
+ def format_chat_history(chat_history):
5
+ formatted_history = ""
6
+ for chat in chat_history:
7
+ formatted_history += f"{chat[0]}: {chat[1]}\n"
8
+ return formatted_history
9
 
10
+ def main():
11
+ st.title("LLM Chat")
12
 
13
+ model = "gpt2"
14
+ llm = LLM(model)
15
+
16
+ chat_history = []
17
+ context = "You are an helpfully assistant in a school. You are helping a student with his homework."
18
+ chat = llm.get_chat(context=context)
19
+ while True:
20
+ user_input = st.text_input("User:")
21
+ if st.button("Send"):
22
+ if user_input:
23
+ chat_history.append(("User", user_input))
24
+ bot_response = chat.answerStoreHistory(qn=user_input)
25
+ chat_history.append(("Bot", bot_response))
26
+
27
+ st.text_area("Chat History:", value=format_chat_history(chat_history), readonly=True)
28
+
29
+
30
+
31
+ # model = st.text_input("model name: ")
32
+ #
33
+ # while model == "":
34
+ # time.sleep(0.1)
35
+ #
36
+ # # model = "mosaicml/mpt-7b-chat"
37
+ #
38
+ #
39
+ # st.write("Model name: ", model)
40
+ # st.write("Loading model...")
41
+ #
42
+ # llm = LLM(model)
43
+ # chat = llm.get_chat(context=context)
44
+ # while True:
45
+ # qn = input("Question: ")
46
+ # if qn == "exit":
47
+ # break
48
+ # chat.answerStoreHistory(qn=qn)
app2.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ # Title and input
4
+ st.title("Reverse Text")
5
+ input_text = st.text_input("Enter some text")
6
+
7
+ # Reverse the input text
8
+ reversed_text = input_text[::-1]
9
+
10
+ # Display the reversed text
11
+ st.write("Reversed text:", reversed_text)
app22.py DELETED
@@ -1,22 +0,0 @@
1
- from LLM import LLM
2
- import time
3
- import streamlit as st
4
-
5
- model = st.text_input("model name: ")
6
-
7
- while model == "":
8
- time.sleep(0.1)
9
-
10
- # model = "mosaicml/mpt-7b-chat"
11
- context = "You are an helpfully assistant in a school. You are helping a student with his homework."
12
-
13
- st.write("Model name: ", model)
14
- st.write("Loading model...")
15
-
16
- llm = LLM(model)
17
- chat = llm.get_chat(context=context)
18
- while True:
19
- qn = input("Question: ")
20
- if qn == "exit":
21
- break
22
- chat.answerStoreHistory(qn=qn)