Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -65,7 +65,7 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
65 |
print(f'cnt:: {cnt}')
|
66 |
if cnt > MAX_HISTORY:
|
67 |
history1 = compress_history(str(history), temperature, max_new_tokens, top_p, repetition_penalty)
|
68 |
-
formatted_prompt = format_prompt(f"{GAME_MASTER.format(history=history1
|
69 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
70 |
output = ""
|
71 |
|
@@ -76,13 +76,19 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
76 |
else:
|
77 |
yield "",[(prompt,output)],health
|
78 |
|
79 |
-
lines = output.strip().strip("\n").split("\n")
|
80 |
#history=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
for i,line in enumerate(lines):
|
82 |
if line.startswith("Health: "):
|
83 |
try:
|
84 |
new_health = line.split("Health: ")[1]
|
85 |
-
health
|
86 |
print(health)
|
87 |
except Exception as e:
|
88 |
print (f'{health}--Error :: {e}')
|
@@ -94,7 +100,8 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
94 |
print(line)
|
95 |
if line.startswith("5. "):
|
96 |
print(line)
|
97 |
-
|
|
|
98 |
if history:
|
99 |
history.append((prompt,output))
|
100 |
yield "",history,health
|
|
|
65 |
print(f'cnt:: {cnt}')
|
66 |
if cnt > MAX_HISTORY:
|
67 |
history1 = compress_history(str(history), temperature, max_new_tokens, top_p, repetition_penalty)
|
68 |
+
formatted_prompt = format_prompt(f"{GAME_MASTER.format(history=history1)}, {prompt}", history)
|
69 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
70 |
output = ""
|
71 |
|
|
|
76 |
else:
|
77 |
yield "",[(prompt,output)],health
|
78 |
|
|
|
79 |
#history=""
|
80 |
+
#formatted_prompt2 = format_prompt(f"{ADJUST_STATS.format(history=output,health=health)}, {prompt}", history)
|
81 |
+
stream2 = client.text_generation(f"{ADJUST_STATS.format(history=output,health=health)}", **generate_kwargs, stream=True, details=True, return_full_text=False)
|
82 |
+
output2=""
|
83 |
+
for response in stream2:
|
84 |
+
output2 += response.token.text
|
85 |
+
|
86 |
+
lines = output2.strip().strip("\n").split("\n")
|
87 |
for i,line in enumerate(lines):
|
88 |
if line.startswith("Health: "):
|
89 |
try:
|
90 |
new_health = line.split("Health: ")[1]
|
91 |
+
health=int(new_health)
|
92 |
print(health)
|
93 |
except Exception as e:
|
94 |
print (f'{health}--Error :: {e}')
|
|
|
100 |
print(line)
|
101 |
if line.startswith("5. "):
|
102 |
print(line)
|
103 |
+
else:
|
104 |
+
print(f'Line:: {line}')
|
105 |
if history:
|
106 |
history.append((prompt,output))
|
107 |
yield "",history,health
|