app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from gpt4all import GPT4All
|
3 |
+
|
4 |
+
# Instantiate the GPT4All model
|
5 |
+
gptj = GPT4All("ggml-gpt4all-j-v1.3-groovy")
|
6 |
+
|
7 |
+
# Streamlit app
|
8 |
+
def main():
|
9 |
+
st.title("GPT4All Chatbot")
|
10 |
+
|
11 |
+
# User input
|
12 |
+
query = st.text_input("Enter your message:")
|
13 |
+
|
14 |
+
# Generate response
|
15 |
+
if st.button("Submit"):
|
16 |
+
messages = [{"role": "user", "content": query}]
|
17 |
+
response = gptj.chat_completion(messages)
|
18 |
+
answer = response['choices'][0]['message']['content']
|
19 |
+
|
20 |
+
# Display the response
|
21 |
+
st.text_area("Bot Response:", value=answer, height=100)
|
22 |
+
|
23 |
+
if __name__ == "__main__":
|
24 |
+
main()
|