Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from langchain import PromptTemplate, LLMChain
|
3 |
+
from langchain.llms import GPT4All
|
4 |
+
|
5 |
+
PATH = 'ggml-mpt-7b-instruct.bin'
|
6 |
+
|
7 |
+
llm = GPT4All(model=PATH, verbose=True)
|
8 |
+
|
9 |
+
prompt = PromptTemplate(input_variables=['question'], template="""
|
10 |
+
Question: {question}
|
11 |
+
|
12 |
+
Answer: Let's think step by step.
|
13 |
+
""")
|
14 |
+
|
15 |
+
llm_chain = LLMChain(prompt=prompt, llm=llm)
|
16 |
+
|
17 |
+
def generate_response(question):
|
18 |
+
response = llm_chain.run(question)
|
19 |
+
return response
|
20 |
+
|
21 |
+
inputs = gr.inputs.Textbox(lines=5, label='Enter your prompt here!')
|
22 |
+
outputs = gr.outputs.Textbox(label='Response')
|
23 |
+
|
24 |
+
title = 'π¦π GPT4ALL Y\'All'
|
25 |
+
description = 'This is using the MPT model!'
|
26 |
+
|
27 |
+
gr.Interface(generate_response, inputs, outputs, title=title, description=description).launch()
|