Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
from gpt4all import GPT4All
|
|
|
|
|
3 |
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
def
|
|
|
|
|
|
|
|
|
|
|
7 |
output = model.generate(input_text, max_tokens=100)
|
8 |
return output
|
9 |
|
|
|
10 |
input_text = gr.Textbox(lines=5, label="Input Text")
|
11 |
output_text = gr.Textbox(lines=5, label="Generated Text")
|
12 |
|
13 |
-
gr.Interface(fn=generate_text,
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gpt4all import GPT4All
|
3 |
+
import urllib
|
4 |
+
import json
|
5 |
|
6 |
+
url = "https://raw.githubusercontent.com/nomic-ai/gpt4all/main/gpt4all-chat/metadata/models3.json"
|
7 |
+
response = urlopen(url)
|
8 |
+
data_json = json.loads(response.read())
|
9 |
|
10 |
+
def model_choices():
|
11 |
+
model_list = [data_json[i]['filename'] for i in range(len(data_json))]
|
12 |
+
return model_list
|
13 |
+
|
14 |
+
def generate_text(input_text, selected_model):
|
15 |
+
model = GPT4All(selected_model)
|
16 |
output = model.generate(input_text, max_tokens=100)
|
17 |
return output
|
18 |
|
19 |
+
model_dropdown = gr.Dropdown(choices=model_choices(), multiselect=False, label="LLMs to choose from", type="value")
|
20 |
input_text = gr.Textbox(lines=5, label="Input Text")
|
21 |
output_text = gr.Textbox(lines=5, label="Generated Text")
|
22 |
|
23 |
+
gr.Interface(fn=generate_text,
|
24 |
+
inputs=[input_text, model_dropdown],
|
25 |
+
outputs=output_text,
|
26 |
+
theme = gr.themes.Soft(),
|
27 |
+
analytics_enabled=True,
|
28 |
+
title="GPT4All Text Generation Experiment").launch()
|