vericudebuget commited on
Commit
86a1cdb
·
verified ·
1 Parent(s): 7d03deb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -0
app.py CHANGED
@@ -18,6 +18,11 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=904
18
  temperature = max(float(temperature), 1e-2)
19
  top_p = float(top_p)
20
 
 
 
 
 
 
21
  generate_kwargs = dict(
22
  temperature=temperature,
23
  max_new_tokens=max_new_tokens,
@@ -31,6 +36,8 @@ def generate(prompt, history, system_prompt, temperature=0.9, max_new_tokens=904
31
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
32
  output = ""
33
 
 
 
34
  for response in stream:
35
  output += response.token.text
36
  yield output
 
18
  temperature = max(float(temperature), 1e-2)
19
  top_p = float(top_p)
20
 
21
+ if 'chat_history' in localStorage:
22
+ history = JSON.parse(localStorage.getItem('chat_history'))
23
+ else:
24
+ history = []
25
+
26
  generate_kwargs = dict(
27
  temperature=temperature,
28
  max_new_tokens=max_new_tokens,
 
36
  stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
37
  output = ""
38
 
39
+ localStorage.setItem('chat_history', JSON.stringify(history))
40
+
41
  for response in stream:
42
  output += response.token.text
43
  yield output