Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,13 +6,13 @@ client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
| 6 |
from prompts import GAME_MASTER, COMPRESS_HISTORY, ADJUST_STATS
|
| 7 |
def format_prompt(message, history):
|
| 8 |
prompt=""
|
| 9 |
-
|
| 10 |
prompt = "<s>"
|
| 11 |
|
| 12 |
for user_prompt, bot_response in history:
|
| 13 |
prompt += f"[INST] {user_prompt} [/INST]"
|
| 14 |
prompt += f" {bot_response}</s> "
|
| 15 |
-
|
| 16 |
prompt += f"[INST] {message} [/INST]"
|
| 17 |
return prompt
|
| 18 |
|
|
@@ -60,10 +60,10 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
| 60 |
history1=history
|
| 61 |
stats=f'''
|
| 62 |
*******************
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
*******************
|
| 68 |
'''
|
| 69 |
for ea in history:
|
|
@@ -102,14 +102,14 @@ def generate(prompt, history,max_new_tokens,health,temperature=temperature,top_p
|
|
| 102 |
|
| 103 |
lines = output.strip().strip("\n").split("\n")
|
| 104 |
for i,line in enumerate(lines):
|
| 105 |
-
if
|
| 106 |
try:
|
| 107 |
new_health = line.split("Health: ")[1]
|
| 108 |
health=int(new_health)
|
| 109 |
print(health)
|
| 110 |
except Exception as e:
|
| 111 |
print (f'{health}--Error :: {e}')
|
| 112 |
-
if
|
| 113 |
print(line)
|
| 114 |
if line.startswith("3. "):
|
| 115 |
print(line)
|
|
|
|
| 6 |
from prompts import GAME_MASTER, COMPRESS_HISTORY, ADJUST_STATS
|
| 7 |
def format_prompt(message, history):
|
| 8 |
prompt=""
|
| 9 |
+
|
| 10 |
prompt = "<s>"
|
| 11 |
|
| 12 |
for user_prompt, bot_response in history:
|
| 13 |
prompt += f"[INST] {user_prompt} [/INST]"
|
| 14 |
prompt += f" {bot_response}</s> "
|
| 15 |
+
|
| 16 |
prompt += f"[INST] {message} [/INST]"
|
| 17 |
return prompt
|
| 18 |
|
|
|
|
| 60 |
history1=history
|
| 61 |
stats=f'''
|
| 62 |
*******************
|
| 63 |
+
Health: {health}
|
| 64 |
+
Power: 1
|
| 65 |
+
Strength: 20
|
| 66 |
+
Magic: 24
|
| 67 |
*******************
|
| 68 |
'''
|
| 69 |
for ea in history:
|
|
|
|
| 102 |
|
| 103 |
lines = output.strip().strip("\n").split("\n")
|
| 104 |
for i,line in enumerate(lines):
|
| 105 |
+
if "Health: " in line:
|
| 106 |
try:
|
| 107 |
new_health = line.split("Health: ")[1]
|
| 108 |
health=int(new_health)
|
| 109 |
print(health)
|
| 110 |
except Exception as e:
|
| 111 |
print (f'{health}--Error :: {e}')
|
| 112 |
+
if "Power: " in line:
|
| 113 |
print(line)
|
| 114 |
if line.startswith("3. "):
|
| 115 |
print(line)
|