Spaces:
Runtime error
Runtime error
File size: 1,948 Bytes
3178c9a 7e230a2 3178c9a 2c77b5e 3178c9a e068d38 a28bbb7 a0c43d5 e068d38 a0c43d5 e068d38 49bce84 42d28e5 49bce84 42d28e5 e068d38 df3ca99 d340e29 e068d38 a28bbb7 49bce84 e068d38 df3ca99 816659f 3178c9a e068d38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | import gradio as gr
import random
text_to_text_gm130b = gr.Blocks.load(name="spaces/THUDM/GLM-130B")
def block_inference(prompt):
#thudm glm 130 b space
#generated_text = text_to_text_gm130b(model_input=prompt, seed=1234, out_seq_length=256, min_gen_length=0, sampling_strategy='BeamSearchStrategy', num_beams=2, length_penalty=1, no_repeat_ngram_size=3, temperature=0.7, topk=1, topp=0)
generated_text = text_to_text_gm130b(prompt, 1234, 256, 0, 'BeamSearchStrategy', 2, 1, 3, 0.7, 1, 0)
return generated_text
def state_player(message, history):
history = history or []
message = message.lower()
response = block_inference(message)
history.append((message, response))
return history, history
def google_docs_embed(): #dummy
html_out = "<iframe src='https://docs.google.com/document/d/e/2PACX-1vQCMltKYqqUNbkM7yWIkzo7HKxCelusP1ocDKjjhRGv_4EHblWl_9hMIFBUdXSSdneTFo7dQUt70jN-/pub?embedded=true' width='640' height='718' frameborder='0' marginheight='0' marginwidth='0'></iframe>"
return html_out
#text_editor = gr.Textbox(lines=20, interactive=True, )
#embed_docs = gr.HTML()
#demo = gr.Interface(
# state_player,
# [text_editor, "state"],
# [text_editor, "state"],
# allow_flagging="never",
#)
#if __name__ == "__main__":
# demo.launch()
css = """ #g-doc {min-height: 500px; min-width: 500px;}
"""
#col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
with gr.Blocks(css=css) as demo:
with gr.Row():
text_editor = gr.Textbox(lines=20, interactive=True, )
state = gr.State()
with gr.Row():
b1 = gr.Button("Generate")
b2 = gr.Button("Docs API")
with gr.Row():
#in_dummy = gr.Textbox(visible=False) #, value='dummy')
embed_docs = gr.HTML(elem_id = "g-doc")
b1.click(fn=state_player, inputs=[text_editor,state], outputs=[text_editor,state])
b2.click(google_docs_embed,outputs=embed_docs) #in_dummy
demo.launch(debug=True, enable_queue=True) |