Loewolf commited on
Commit
bc36cc9
·
1 Parent(s): f32085b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -31
app.py CHANGED
@@ -10,7 +10,7 @@ def generate_text(prompt):
10
  input_ids = tokenizer.encode(prompt, return_tensors="pt")
11
  attention_mask = torch.ones(input_ids.shape, dtype=torch.bool)
12
 
13
- max_length = model.config.n_positions if len(input_ids[0]) > model.config.n_positions else len(input_ids[0]) + 50
14
  beam_output = model.generate(
15
  input_ids,
16
  attention_mask=attention_mask,
@@ -35,40 +35,34 @@ DESCRIPTION = """\
35
  #Löwolf GPT1 Chat
36
  """
37
  css = """
38
- body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; }
39
- .gradio_app { display: flex; flex-direction: column-reverse; max-width: 800px; margin: auto; }
40
- .gradio_interface { box-shadow: 0 0 20px rgba(0,0,0,0.1); }
41
- .gradio_text_input { border-radius: 20px; }
42
- .gradio_text_output { height: calc(100vh - 150px); border-radius: 20px; overflow-y: auto; }
43
- button { border-radius: 20px; }
44
- #input-box { order: 2; }
45
- #output-box { order: 1; }
46
- #input { height: 50px; }
47
- #output { height: calc(100vh - 150px); }
 
 
 
 
 
 
 
48
  """
49
 
50
- # Update the Blocks structure to reflect the desired layout
51
- with gr.Blocks(css=css) as demo:
52
- gr.Markdown(DESCRIPTION)
 
53
 
54
- gr.DuplicateButton(value="Duplicate Space for private use", elem_id="duplicate-button")
55
- with gr.Row().style(equal_height=False):
56
- output_box = gr.Textbox(interactive=False, lines=25, placeholder="Responses will appear here...", elem_id="output-box")
57
- input_box = gr.Textbox(lines=1, placeholder="Type a message...", elem_id="input-box")
58
- generate_button = gr.Button("Submit")
59
- generate_button.click(
60
- fn=generate,
61
- inputs=[input_box],
62
- outputs=output_box
63
- )
64
-
65
- if __name__ == "__main__":
66
- demo.queue(max_size=20).launch()
67
-
68
-
69
-
70
-
71
 
 
72
 
73
 
74
 
 
10
  input_ids = tokenizer.encode(prompt, return_tensors="pt")
11
  attention_mask = torch.ones(input_ids.shape, dtype=torch.bool)
12
 
13
+ max_length = model.config.n_positions if len(input_ids[0]) > model.config.n_positions else len(input_ids[0]) + 20
14
  beam_output = model.generate(
15
  input_ids,
16
  attention_mask=attention_mask,
 
35
  #Löwolf GPT1 Chat
36
  """
37
  css = """
38
+ h1 {
39
+ text-align: center;
40
+ }
41
+
42
+ #duplicate-button {
43
+ margin: auto;
44
+ color: white;
45
+ background: #1565c0;
46
+ border-radius: 100vh;
47
+ }
48
+
49
+ .contain {
50
+ max-width: 900px;
51
+ margin: auto;
52
+ padding-top: 1.5rem;
53
+ }
54
+
55
  """
56
 
57
+ iface = gr.Interface(
58
+ fn=generate_text,
59
+ inputs=gr.Textbox(lines=2, placeholder="Type a message...", label="Your Message"),
60
+ outputs=gr.Textbox(label="Löwolf Chat Responses", placeholder="Responses will appear here...", interactive=False, lines=10),
61
 
62
+ css=css
63
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ iface.launch()
66
 
67
 
68