Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,14 +16,12 @@ from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
|
|
| 16 |
from settings import EVENTS
|
| 17 |
from player import Player
|
| 18 |
from utils import PROMPT, INPUT_PROMPT, extract_after_final_answer
|
| 19 |
-
from llm import *
|
| 20 |
|
| 21 |
# Initialize the HF Inference Client
|
| 22 |
# It will automatically pick up the HF_TOKEN environment variable if it's set
|
| 23 |
|
| 24 |
# Define the models we want to use from the Hugging Face Hub
|
| 25 |
LLM_MODEL = "Qwen/Qwen2.5-7B-Instruct"
|
| 26 |
-
MODEL_CONFIG = HUGGINGFACE_LITE
|
| 27 |
|
| 28 |
target_size=(1024, 1024)
|
| 29 |
|
|
@@ -124,17 +122,15 @@ def play_turn(human_response, loc, player, cur, custom_token, request: gr.Reques
|
|
| 124 |
]
|
| 125 |
|
| 126 |
try:
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
# temperature=0.7
|
| 137 |
-
# )
|
| 138 |
except Exception as e:
|
| 139 |
yield (
|
| 140 |
f"Error calling API: {str(e)}",
|
|
@@ -145,10 +141,8 @@ def play_turn(human_response, loc, player, cur, custom_token, request: gr.Reques
|
|
| 145 |
)
|
| 146 |
return
|
| 147 |
|
| 148 |
-
|
| 149 |
-
processed_response = extract_after_final_answer(response.content)
|
| 150 |
|
| 151 |
-
print(processed_response)
|
| 152 |
# 2. Update Game State / Location
|
| 153 |
loc = cur._next(processed_response, player)
|
| 154 |
attribute = player.get_attribute()
|
|
|
|
| 16 |
from settings import EVENTS
|
| 17 |
from player import Player
|
| 18 |
from utils import PROMPT, INPUT_PROMPT, extract_after_final_answer
|
|
|
|
| 19 |
|
| 20 |
# Initialize the HF Inference Client
|
| 21 |
# It will automatically pick up the HF_TOKEN environment variable if it's set
|
| 22 |
|
| 23 |
# Define the models we want to use from the Hugging Face Hub
|
| 24 |
LLM_MODEL = "Qwen/Qwen2.5-7B-Instruct"
|
|
|
|
| 25 |
|
| 26 |
target_size=(1024, 1024)
|
| 27 |
|
|
|
|
| 122 |
]
|
| 123 |
|
| 124 |
try:
|
| 125 |
+
client = InferenceClient(
|
| 126 |
+
api_key=chosen_token
|
| 127 |
+
)
|
| 128 |
+
response = client.chat_completion(
|
| 129 |
+
model=LLM_MODEL,
|
| 130 |
+
messages=messages,
|
| 131 |
+
max_tokens=500,
|
| 132 |
+
temperature=0.7
|
| 133 |
+
)
|
|
|
|
|
|
|
| 134 |
except Exception as e:
|
| 135 |
yield (
|
| 136 |
f"Error calling API: {str(e)}",
|
|
|
|
| 141 |
)
|
| 142 |
return
|
| 143 |
|
| 144 |
+
processed_response = extract_after_final_answer(response.choices[0].message.content)
|
|
|
|
| 145 |
|
|
|
|
| 146 |
# 2. Update Game State / Location
|
| 147 |
loc = cur._next(processed_response, player)
|
| 148 |
attribute = player.get_attribute()
|