Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,7 +21,6 @@ temperature=0.9
|
|
| 21 |
top_p=0.95
|
| 22 |
repetition_penalty=1.0
|
| 23 |
|
| 24 |
-
|
| 25 |
def compress_history(history,temperature=temperature,top_p=top_p,repetition_penalty=repetition_penalty):
|
| 26 |
formatted_prompt=f"{COMPRESS_HISTORY.format(history=history)}"
|
| 27 |
generate_kwargs = dict(
|
|
@@ -64,8 +63,8 @@ def generate(prompt, history,max_new_tokens,temperature=temperature,top_p=top_p,
|
|
| 64 |
cnt+=len(l.split("\n"))
|
| 65 |
print(f'cnt:: {cnt}')
|
| 66 |
if cnt > MAX_HISTORY:
|
| 67 |
-
|
| 68 |
-
formatted_prompt = format_prompt(f"{GAME_MASTER.format(history=
|
| 69 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 70 |
output = ""
|
| 71 |
|
|
@@ -92,9 +91,9 @@ def generate(prompt, history,max_new_tokens,temperature=temperature,top_p=top_p,
|
|
| 92 |
|
| 93 |
if history:
|
| 94 |
history.append((prompt,output))
|
| 95 |
-
|
| 96 |
else:
|
| 97 |
-
|
| 98 |
|
| 99 |
def clear_fn():
|
| 100 |
return None,None
|
|
|
|
| 21 |
top_p=0.95
|
| 22 |
repetition_penalty=1.0
|
| 23 |
|
|
|
|
| 24 |
def compress_history(history,temperature=temperature,top_p=top_p,repetition_penalty=repetition_penalty):
|
| 25 |
formatted_prompt=f"{COMPRESS_HISTORY.format(history=history)}"
|
| 26 |
generate_kwargs = dict(
|
|
|
|
| 63 |
cnt+=len(l.split("\n"))
|
| 64 |
print(f'cnt:: {cnt}')
|
| 65 |
if cnt > MAX_HISTORY:
|
| 66 |
+
history1 = compress_history(str(history), temperature, max_new_tokens, top_p, repetition_penalty)
|
| 67 |
+
formatted_prompt = format_prompt(f"{GAME_MASTER.format(history=history1)}, {prompt}", history)
|
| 68 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 69 |
output = ""
|
| 70 |
|
|
|
|
| 91 |
|
| 92 |
if history:
|
| 93 |
history.append((prompt,output))
|
| 94 |
+
yield "",history
|
| 95 |
else:
|
| 96 |
+
yield "",[(prompt,output)]
|
| 97 |
|
| 98 |
def clear_fn():
|
| 99 |
return None,None
|