File size: 1,580 Bytes
bbfe5fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e60a54a
bbfe5fa
 
 
 
 
 
 
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
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)