sqfoo commited on
Commit
086d943
·
verified ·
1 Parent(s): ce0d7c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
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
- async 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,11 +115,14 @@ async def play_turn(human_response, loc, player, cur, custom_token, request: gr.
115
  }
116
  ]
117
  try:
118
- response = await client.chat_completion(
119
- model=LLM_MODEL,
120
- messages=messages,
121
- max_tokens=500,
122
- temperature=0.7
 
 
 
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 (