Kirili4ik commited on
Commit
3e462aa
1 Parent(s): 81b9e78

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
  from util_funcs import get_length_param
5
 
6
- def chat_function(Message, Length_of_the_answer, Who_is_next, Base_to_On_subject): # model, tokenizer
7
 
8
  input_user = Message
9
 
@@ -21,9 +21,7 @@ def chat_function(Message, Length_of_the_answer, Who_is_next, Base_to_On_subject
21
  elif Who_is_next == 'Me':
22
  next_who = 'H'
23
 
24
-
25
-
26
- history = gr.get_state() or []
27
  chat_history_ids = torch.zeros((1, 0), dtype=torch.int) if history == [] else torch.tensor(history[-1][2], dtype=torch.long)
28
 
29
  # encode the new user input, add parameters and return a tensor in Pytorch
@@ -106,7 +104,8 @@ iface = gr.Interface(chat_function,
106
  "text",
107
  gr.inputs.Radio(["short", "medium", "long"], default='medium'),
108
  gr.inputs.Radio(["Kirill", "Me"], default='Kirill'),
109
- gr.inputs.Slider(0, 1, default=0.5)
 
110
  ],
111
  "html",
112
  title=title, description=description, article=article, examples=examples,
 
3
  from transformers import AutoModelForCausalLM, AutoTokenizer
4
  from util_funcs import get_length_param
5
 
6
+ def chat_function(Message, Length_of_the_answer, Who_is_next, Base_to_On_subject, history): # model, tokenizer
7
 
8
  input_user = Message
9
 
 
21
  elif Who_is_next == 'Me':
22
  next_who = 'H'
23
 
24
+ history = history or []
 
 
25
  chat_history_ids = torch.zeros((1, 0), dtype=torch.int) if history == [] else torch.tensor(history[-1][2], dtype=torch.long)
26
 
27
  # encode the new user input, add parameters and return a tensor in Pytorch
 
104
  "text",
105
  gr.inputs.Radio(["short", "medium", "long"], default='medium'),
106
  gr.inputs.Radio(["Kirill", "Me"], default='Kirill'),
107
+ gr.inputs.Slider(0, 1, default=0.5),
108
+ "state"
109
  ],
110
  "html",
111
  title=title, description=description, article=article, examples=examples,