Spaces:
Running
Running
initialize safety client once on helper function, then use it in run_action for inference
Browse files
helper.py
CHANGED
@@ -297,6 +297,14 @@ def initialize_inference_client():
|
|
297 |
raise
|
298 |
|
299 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
def load_world(filename):
|
301 |
with open(filename, "r") as f:
|
302 |
return json.load(f)
|
@@ -817,7 +825,8 @@ Inventory: {json.dumps(game_state['inventory'])}"""
|
|
817 |
# response = response.replace("...", ".")
|
818 |
|
819 |
# Initialize client and make API call
|
820 |
-
client = initialize_inference_client()
|
|
|
821 |
|
822 |
# Generate response using Inference API
|
823 |
completion = client.chat.completions.create(
|
|
|
297 |
raise
|
298 |
|
299 |
|
300 |
+
# Initialize inference client and make API call
|
301 |
+
try:
|
302 |
+
inference_client = initialize_inference_client()
|
303 |
+
|
304 |
+
except Exception as e:
|
305 |
+
logger.error(f"Failed to initialize the inference client model: {str(e)}")
|
306 |
+
|
307 |
+
|
308 |
def load_world(filename):
|
309 |
with open(filename, "r") as f:
|
310 |
return json.load(f)
|
|
|
825 |
# response = response.replace("...", ".")
|
826 |
|
827 |
# Initialize client and make API call
|
828 |
+
# client = initialize_inference_client()
|
829 |
+
client = inference_client
|
830 |
|
831 |
# Generate response using Inference API
|
832 |
completion = client.chat.completions.create(
|