Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from gpt4all import GPT4All
|
| 3 |
+
|
| 4 |
+
model = GPT4All("orca-mini-3b-gguf2-q4_0.gguf")
|
| 5 |
+
|
| 6 |
+
def chatbot_response(input_text):
|
| 7 |
+
tokens = []
|
| 8 |
+
with model.chat_session() as session:
|
| 9 |
+
for token in model.generate(input_text, streaming=True):
|
| 10 |
+
tokens.append(token)
|
| 11 |
+
response = ''.join(tokens)
|
| 12 |
+
return response
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=chatbot_response,
|
| 16 |
+
inputs=gr.components.Textbox(lines=2, placeholder="Ask me anything..."),
|
| 17 |
+
outputs="text",
|
| 18 |
+
title="GPT-4All Chatbot",
|
| 19 |
+
description="This chatbot uses the GPT-4All model to answer your questions."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
iface.launch()
|