Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
|
@@ -83,7 +83,7 @@ def start_game():
|
|
| 83 |
initial_event # sets state_cur
|
| 84 |
)
|
| 85 |
|
| 86 |
-
|
| 87 |
"""Executes a single turn of the game loop based on user input."""
|
| 88 |
status = player.get_attribute()
|
| 89 |
if not human_response.strip():
|
|
@@ -115,11 +115,14 @@ async def play_turn(human_response, loc, player, cur, custom_token, request: gr.
|
|
| 115 |
}
|
| 116 |
]
|
| 117 |
try:
|
| 118 |
-
response =
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
|
|
|
|
|
|
|
|
|
| 123 |
)
|
| 124 |
except Exception as e:
|
| 125 |
yield (
|
|
|
|
| 1 |
import os
|
| 2 |
+
import asyncio
|
| 3 |
import gradio as gr
|
| 4 |
import numpy as np
|
| 5 |
from PIL import Image
|
|
|
|
| 83 |
initial_event # sets state_cur
|
| 84 |
)
|
| 85 |
|
| 86 |
+
def play_turn(human_response, loc, player, cur, custom_token, request: gr.Request):
|
| 87 |
"""Executes a single turn of the game loop based on user input."""
|
| 88 |
status = player.get_attribute()
|
| 89 |
if not human_response.strip():
|
|
|
|
| 115 |
}
|
| 116 |
]
|
| 117 |
try:
|
| 118 |
+
response = asyncio.run(
|
| 119 |
+
asyncio.to_thread(
|
| 120 |
+
client.chat_completion,
|
| 121 |
+
model=LLM_MODEL,
|
| 122 |
+
messages=messages,
|
| 123 |
+
max_tokens=500,
|
| 124 |
+
temperature=0.7
|
| 125 |
+
)
|
| 126 |
)
|
| 127 |
except Exception as e:
|
| 128 |
yield (
|