ysharma's picture
ysharma HF Staff
update button
e60a54a
raw
history blame
1.58 kB
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
#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])
demo.launch(debug=True, enable_queue=True)