Spaces:
Runtime error
Runtime error
GitLab CI
commited on
Commit
·
3256e71
1
Parent(s):
0f6f535
Update game build from GitLab CI
Browse files- server/ActionProcessor.py +24 -12
- server/AudioTranscriber.py +2 -0
- server/static/godot/index.pck +0 -0
server/ActionProcessor.py
CHANGED
|
@@ -43,18 +43,21 @@ class ActionProcessor(Thread):
|
|
| 43 |
|
| 44 |
1. **Reconstruct the most logical full command** by analyzing the given fragments and arranging them into a coherent order.
|
| 45 |
2. **Select the closest matching three-word action** from the following predefined options:
|
| 46 |
-
["drop it", "don't drink", "None", "stay back", "stop touching", "move away"].
|
| 47 |
Always choose the most contextually relevant option. If no match is appropriate, select "None."
|
| 48 |
-
3.
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
Your response should strictly follow this JSON format:
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
"SENTIMENT": "negative"
|
| 56 |
-
}}
|
| 57 |
|
|
|
|
|
|
|
|
|
|
| 58 |
Transcription fragments: "{input_text}"
|
| 59 |
""",
|
| 60 |
}
|
|
@@ -62,7 +65,16 @@ class ActionProcessor(Thread):
|
|
| 62 |
|
| 63 |
response = self.mistral_client.chat.complete(
|
| 64 |
model="mistral-large-latest",
|
| 65 |
-
messages=messages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
)
|
| 67 |
|
| 68 |
result: str = response.choices[0].message.content
|
|
@@ -77,12 +89,12 @@ class ActionProcessor(Thread):
|
|
| 77 |
if len(self.text_buffers) < 3:
|
| 78 |
return None
|
| 79 |
|
| 80 |
-
if len(self.text_buffers)
|
| 81 |
_ = self.text_buffers.pop(0)
|
| 82 |
|
| 83 |
-
candidate = self.text_buffers[
|
| 84 |
|
| 85 |
-
if len(self.text_buffers[0])
|
| 86 |
sentiment_and_action = self.get_sentiment_and_action(candidate)
|
| 87 |
return {"type": "action", "sentiment": sentiment_and_action}
|
| 88 |
|
|
|
|
| 43 |
|
| 44 |
1. **Reconstruct the most logical full command** by analyzing the given fragments and arranging them into a coherent order.
|
| 45 |
2. **Select the closest matching three-word action** from the following predefined options:
|
| 46 |
+
["drop it", "don't drink", "None", "stay back", "stop touching", "move away", "none"].
|
| 47 |
Always choose the most contextually relevant option. If no match is appropriate, select "None."
|
| 48 |
+
3. Determine whether the parenting sentiment behind the command is positive or negative**, based on the following criteria:
|
| 49 |
+
- If the statement includes the baby’s name ("Harold"), it is considered **positive parenting**.
|
| 50 |
+
- If the statement consists only of direct commands without affectionate or encouraging words (e.g., "good boy," "better"), it is considered **negative parenting**.
|
| 51 |
|
| 52 |
+
Your response should strictly follow this JSON format as an array of strings:
|
| 53 |
|
| 54 |
+
```json
|
| 55 |
+
[action,sentiment]
|
| 56 |
+
```
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
for example:
|
| 59 |
+
["drop it", "negative"]
|
| 60 |
+
["none", "positive"]
|
| 61 |
Transcription fragments: "{input_text}"
|
| 62 |
""",
|
| 63 |
}
|
|
|
|
| 65 |
|
| 66 |
response = self.mistral_client.chat.complete(
|
| 67 |
model="mistral-large-latest",
|
| 68 |
+
messages=messages
|
| 69 |
+
+ [
|
| 70 |
+
{
|
| 71 |
+
"role": "assistant",
|
| 72 |
+
"content": "[",
|
| 73 |
+
"prefix": True,
|
| 74 |
+
}
|
| 75 |
+
],
|
| 76 |
+
response_format={"type": "json_object"},
|
| 77 |
+
temperature=0.0,
|
| 78 |
)
|
| 79 |
|
| 80 |
result: str = response.choices[0].message.content
|
|
|
|
| 89 |
if len(self.text_buffers) < 3:
|
| 90 |
return None
|
| 91 |
|
| 92 |
+
if len(self.text_buffers) > 3:
|
| 93 |
_ = self.text_buffers.pop(0)
|
| 94 |
|
| 95 |
+
candidate = self.text_buffers[1]
|
| 96 |
|
| 97 |
+
if len(self.text_buffers[0]) < len(candidate) >= len(self.text_buffers[2]):
|
| 98 |
sentiment_and_action = self.get_sentiment_and_action(candidate)
|
| 99 |
return {"type": "action", "sentiment": sentiment_and_action}
|
| 100 |
|
server/AudioTranscriber.py
CHANGED
|
@@ -69,6 +69,8 @@ class AudioTranscriber(threading.Thread):
|
|
| 69 |
logger.info(
|
| 70 |
f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}"
|
| 71 |
)
|
|
|
|
|
|
|
| 72 |
|
| 73 |
except Empty:
|
| 74 |
continue # If queue is empty, continue waiting
|
|
|
|
| 69 |
logger.info(
|
| 70 |
f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}"
|
| 71 |
)
|
| 72 |
+
else:
|
| 73 |
+
self.action_queue.put("")
|
| 74 |
|
| 75 |
except Empty:
|
| 76 |
continue # If queue is empty, continue waiting
|
server/static/godot/index.pck
CHANGED
|
Binary files a/server/static/godot/index.pck and b/server/static/godot/index.pck differ
|
|
|