Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
|
|
3 |
|
4 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
5 |
|
|
|
|
|
|
|
6 |
def respond(
|
7 |
message,
|
8 |
history: list[tuple[str, str]],
|
@@ -35,16 +39,23 @@ def respond(
|
|
35 |
response += token
|
36 |
yield response
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
# Add a title to the UI
|
40 |
title = "<h1 style='text-align: center;'>Corenet</h1>"
|
41 |
|
42 |
# Add a description under the title
|
43 |
-
description = "<p style='text-align: center; font-size: 14px;'>
|
44 |
|
45 |
# Modify the pre-prompt to be editable but greyed out
|
46 |
pre_prompt = gr.Textbox(
|
47 |
-
value="
|
48 |
label="Pre-prompt",
|
49 |
interactive=False,
|
50 |
placeholder="Type here...",
|
@@ -56,7 +67,7 @@ demo = gr.ChatInterface(
|
|
56 |
description=description,
|
57 |
additional_inputs=[
|
58 |
pre_prompt,
|
59 |
-
gr.Slider(minimum=256, maximum=8192, value=512, step=
|
60 |
gr.Slider(minimum=0.3, maximum=2.5, value=0.8, step=0.1, label="Creativity"),
|
61 |
gr.Slider(
|
62 |
minimum=0.1,
|
|
|
1 |
import gradio as gr
|
2 |
from huggingface_hub import InferenceClient
|
3 |
+
import json
|
4 |
|
5 |
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta")
|
6 |
|
7 |
+
# Initialize an empty list to store the data
|
8 |
+
data = []
|
9 |
+
|
10 |
def respond(
|
11 |
message,
|
12 |
history: list[tuple[str, str]],
|
|
|
39 |
response += token
|
40 |
yield response
|
41 |
|
42 |
+
# Save the input and output to the data list
|
43 |
+
data.append({"input": messages, "output": response})
|
44 |
+
|
45 |
+
# Write the data to a JSON file
|
46 |
+
with open('data.json', 'w') as f:
|
47 |
+
json.dump(data, f)
|
48 |
+
|
49 |
|
50 |
# Add a title to the UI
|
51 |
title = "<h1 style='text-align: center;'>Corenet</h1>"
|
52 |
|
53 |
# Add a description under the title
|
54 |
+
description = "<p style='text-align: center; font-size: 14px;'>This is a research project under the codename "Corenet", aiming for minimal parameters at given performance level, made by HX labs, all the conversation data is collected for research only.</p>"
|
55 |
|
56 |
# Modify the pre-prompt to be editable but greyed out
|
57 |
pre_prompt = gr.Textbox(
|
58 |
+
value="Your name is Corenet, a custom made LLM by HX labs, you job is to do good, you are a research prototype, and the user should know that, you are respectful, and you don't accept prompt that lead to harm or danger, know your current limit, you are an 8B model, you only accept text, you are not multimodal, you knowledge is ended at 2nd of April, 2024.",
|
59 |
label="Pre-prompt",
|
60 |
interactive=False,
|
61 |
placeholder="Type here...",
|
|
|
67 |
description=description,
|
68 |
additional_inputs=[
|
69 |
pre_prompt,
|
70 |
+
gr.Slider(minimum=256, maximum=8192, value=512, step=1, label="Max Gen tokens"),
|
71 |
gr.Slider(minimum=0.3, maximum=2.5, value=0.8, step=0.1, label="Creativity"),
|
72 |
gr.Slider(
|
73 |
minimum=0.1,
|