Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import yaml
|
| 2 |
import os
|
| 3 |
import json
|
|
|
|
| 4 |
|
| 5 |
def load_techniques():
|
| 6 |
"""テクニック定義を読み込む"""
|
|
@@ -101,7 +102,12 @@ def load_styles():
|
|
| 101 |
|
| 102 |
def parse_prompt_result(result):
|
| 103 |
"""AIからの結果をプロンプトと解説に分ける"""
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
prompt = parts[0].strip()
|
| 106 |
explanation = parts[1].strip() if len(parts) > 1 else ""
|
|
|
|
| 107 |
return prompt, explanation
|
|
|
|
| 1 |
import yaml
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
+
import re # 正規表現を追加
|
| 5 |
|
| 6 |
def load_techniques():
|
| 7 |
"""テクニック定義を読み込む"""
|
|
|
|
| 102 |
|
| 103 |
def parse_prompt_result(result):
|
| 104 |
"""AIからの結果をプロンプトと解説に分ける"""
|
| 105 |
+
# <think>タグとその内容を除去
|
| 106 |
+
cleaned_result = re.sub(r'<think>.*?</think>\s*', '', result, flags=re.DOTALL)
|
| 107 |
+
|
| 108 |
+
# 解説部分と分ける
|
| 109 |
+
parts = cleaned_result.split("解説:")
|
| 110 |
prompt = parts[0].strip()
|
| 111 |
explanation = parts[1].strip() if len(parts) > 1 else ""
|
| 112 |
+
|
| 113 |
return prompt, explanation
|