Spaces:
Runtime error
Runtime error
PRANJAL KAR
commited on
Commit
·
713065f
1
Parent(s):
d1590ee
Tab Inface
Browse files
app.py
CHANGED
@@ -24,7 +24,22 @@ client = InferenceClient(
|
|
24 |
API_URL,
|
25 |
headers={"Authorization": f"Bearer {HF_TOKEN}"},
|
26 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
|
|
28 |
def format_prompt(message, history, system_prompt):
|
29 |
prompt = ""
|
30 |
if system_prompt:
|
@@ -135,11 +150,17 @@ with gr.Blocks() as demo:
|
|
135 |
⚠️ **Limitations**: the model can and will produce factually incorrect information, hallucinating facts and actions. As it has not undergone any advanced tuning/alignment, it can produce problematic outputs, especially if prompted to do so. Finally, this demo is limited to a session length of about 1,000 words.
|
136 |
"""
|
137 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
-
gr.ChatInterface(
|
140 |
generate,
|
141 |
examples=EXAMPLES,
|
142 |
additional_inputs=additional_inputs,
|
143 |
)
|
144 |
-
|
145 |
demo.queue(concurrency_count=100, api_open=False).launch(show_api=False)
|
|
|
24 |
API_URL,
|
25 |
headers={"Authorization": f"Bearer {HF_TOKEN}"},
|
26 |
)
|
27 |
+
################### mY code ############################
|
28 |
+
def generate_headlines(topic):
|
29 |
+
prompt = f"Create at most 5 headlines that highlight {topic}. The headlines should be concise, attention-grabbing, and suitable for use in a news video."
|
30 |
+
sequences = generate(
|
31 |
+
prompt,
|
32 |
+
history=[],
|
33 |
+
system_prompt="",
|
34 |
+
temperature=0.9,
|
35 |
+
max_new_tokens=256,
|
36 |
+
top_p=0.95,
|
37 |
+
repetition_penalty=1.0,
|
38 |
+
)
|
39 |
+
headlines = [seq for seq in sequences]
|
40 |
+
return "\n".join(headlines)
|
41 |
|
42 |
+
######################################################
|
43 |
def format_prompt(message, history, system_prompt):
|
44 |
prompt = ""
|
45 |
if system_prompt:
|
|
|
150 |
⚠️ **Limitations**: the model can and will produce factually incorrect information, hallucinating facts and actions. As it has not undergone any advanced tuning/alignment, it can produce problematic outputs, especially if prompted to do so. Finally, this demo is limited to a session length of about 1,000 words.
|
151 |
"""
|
152 |
)
|
153 |
+
iface_1 = gr.Interface(
|
154 |
+
fn=generate_headlines,
|
155 |
+
inputs=gr.inputs.Textbox(placeholder="Enter the topic"),
|
156 |
+
outputs="text",
|
157 |
+
examples=EXAMPLES
|
158 |
+
)
|
159 |
|
160 |
+
main_i = gr.ChatInterface(
|
161 |
generate,
|
162 |
examples=EXAMPLES,
|
163 |
additional_inputs=additional_inputs,
|
164 |
)
|
165 |
+
demo = gr.TabbedInterface([iface_1, main_i], ["Get headlines", "Chatbot Demo"])
|
166 |
demo.queue(concurrency_count=100, api_open=False).launch(show_api=False)
|