|
import os |
|
os.system("pip install huggingface_hub") |
|
|
|
from huggingface_hub import space_info |
|
|
|
from summary_reverse_pred_eng_native import * |
|
import gradio as gr |
|
|
|
|
|
|
|
|
|
|
|
text0 = "The Wisconsin Territorial Centennial half dollar was designed by David Parsons and Benjamin Hawkins and minted by the United States Bureau of the Mint in 1936. The obverse (pictured) depicts a pick axe and lead ore, referring to the lead mining in early Wisconsin" |
|
|
|
|
|
example_sample = [ |
|
[text0, False], |
|
|
|
] |
|
|
|
def demo_func(prefix, do_sample): |
|
l = simple_pred(prefix, do_sample = do_sample) |
|
return { |
|
"Dialogue Context": l |
|
} |
|
|
|
markdown_exp_size = "##" |
|
lora_repo = "svjack/chatglm3-few-shot" |
|
lora_repo_link = "svjack/chatglm3-few-shot/?input_list_index=8" |
|
emoji_info = space_info(lora_repo).__dict__["cardData"]["emoji"] |
|
space_cnt = 1 |
|
task_name = "[---English Context Dialogue Generator---]" |
|
description = f"{markdown_exp_size} {task_name} few shot prompt in ChatGLM3 Few Shot space repo (click submit to activate) : [{lora_repo_link}](https://huggingface.co/spaces/{lora_repo_link}) {emoji_info}" |
|
|
|
|
|
|
|
demo = gr.Interface( |
|
fn=demo_func, |
|
inputs=[gr.Text(label = "Context"), |
|
gr.Checkbox(label="do sample"), |
|
], |
|
outputs="json", |
|
title=f"English Context Dialogue Generator 🦅 demonstration", |
|
description = 'This _example_ was **drive** from <br/><b><h4>[https://github.com/svjack/Context2Dialogue](https://github.com/svjack/Context2Dialogue)</h4></b>\n', |
|
|
|
examples=example_sample if example_sample else None, |
|
cache_examples = False |
|
) |
|
|
|
with demo: |
|
gr.HTML( |
|
''' |
|
<div style="justify-content: center; display: flex;"> |
|
<iframe |
|
src="https://svjack-chatglm3-few-shot-demo.hf.space/?input_list_index=8" |
|
frameborder="0" |
|
width="1400" |
|
height="768" |
|
></iframe> |
|
</div> |
|
''' |
|
) |
|
|
|
demo.launch(server_name=None, server_port=None) |
|
|