Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -864,58 +864,58 @@ with gr.Blocks(fill_height=True, title="Enhanced ThinkFlow") as demo:
|
|
| 864 |
temperature = gr.Slider(0.1, 1.0, 0.7, step=0.1, label="์จ๋")
|
| 865 |
memory_weight = gr.Slider(0.0, 1.0, 0.5, step=0.1, label="๋ฉ๋ชจ๋ฆฌ ๋ฐ์ ๊ฐ์ค์น")
|
| 866 |
|
| 867 |
-
# ํผ๋๋ฐฑ ์ฒ๋ฆฌ ํจ์
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
|
| 920 |
|
| 921 |
|
|
|
|
| 864 |
temperature = gr.Slider(0.1, 1.0, 0.7, step=0.1, label="์จ๋")
|
| 865 |
memory_weight = gr.Slider(0.0, 1.0, 0.5, step=0.1, label="๋ฉ๋ชจ๋ฆฌ ๋ฐ์ ๊ฐ์ค์น")
|
| 866 |
|
| 867 |
+
# ํผ๋๋ฐฑ ์ฒ๋ฆฌ ํจ์
|
| 868 |
+
def process_positive_feedback():
|
| 869 |
+
global buffer_manager, current_contexts
|
| 870 |
+
if buffer_manager:
|
| 871 |
+
buffer_manager.update_retrieval_reward(current_contexts, reward=1.0)
|
| 872 |
+
return "ํผ๋๋ฐฑ ๊ฐ์ฌํฉ๋๋ค! ์ด ์ ๊ทผ ๋ฐฉ์์ ํฅํ ์ ์ฌํ ์ง๋ฌธ์ ๋ ์์ฃผ ์ฌ์ฉํ๊ฒ ์ต๋๋ค."
|
| 873 |
+
|
| 874 |
+
def process_negative_feedback():
|
| 875 |
+
global buffer_manager, current_contexts
|
| 876 |
+
if buffer_manager:
|
| 877 |
+
buffer_manager.update_retrieval_reward(current_contexts, reward=-0.5)
|
| 878 |
+
return "ํผ๋๋ฐฑ ๊ฐ์ฌํฉ๋๋ค! ์ด ์ ๊ทผ ๋ฐฉ์์ ๊ฐ์ ํ๊ฒ ์ต๋๋ค."
|
| 879 |
+
|
| 880 |
+
def clear_memory():
|
| 881 |
+
global buffer_manager
|
| 882 |
+
if buffer_manager:
|
| 883 |
+
buffer_manager.clear()
|
| 884 |
+
return "๋ฉ๋ชจ๋ฆฌ๊ฐ ์ด๊ธฐํ๋์์ต๋๋ค."
|
| 885 |
+
|
| 886 |
+
def update_memory_displays():
|
| 887 |
+
global buffer_manager
|
| 888 |
+
if not buffer_manager:
|
| 889 |
+
return "๋ฉ๋ชจ๋ฆฌ๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค.", "๊ทธ๋ํ๊ฐ ์ด๊ธฐํ๋์ง ์์์ต๋๋ค."
|
| 890 |
|
| 891 |
+
semantic_text = "ํ์ฌ ์ ์ฅ๋ ๋ฉ๋ชจ๋ฆฌ:\n\n"
|
| 892 |
+
for i, mem in enumerate(buffer_manager.semantic_memory.memories[:5]): # ์ต๋ 5๊ฐ๋ง ํ์
|
| 893 |
+
semantic_text += f"{i+1}. {mem['text'][:100]}...\n\n"
|
| 894 |
|
| 895 |
+
graph_text = "ํ์ฌ ๊ทธ๋ํ ๋
ธ๋:\n\n"
|
| 896 |
+
for node in buffer_manager.graph_memory.graph.nodes():
|
| 897 |
+
node_text = buffer_manager.graph_memory.get_text_by_node(node)
|
| 898 |
+
neighbors = list(buffer_manager.graph_memory.graph.neighbors(node))
|
| 899 |
+
graph_text += f"๋
ธ๋: {node}\n์ค๋ช
: {node_text[:50]}...\n์ฐ๊ฒฐ: {', '.join(neighbors[:3])}\n\n"
|
| 900 |
|
| 901 |
+
return semantic_text, graph_text
|
| 902 |
+
|
| 903 |
+
# ์ด๊ธฐํ ํจ์
|
| 904 |
+
def initialize_models():
|
| 905 |
+
global pipe, buffer_manager, model_name
|
| 906 |
+
try:
|
| 907 |
+
pipe, buffer_manager = initialize_model_and_manager(model_name)
|
| 908 |
+
semantic_text, graph_text = update_memory_displays()
|
| 909 |
+
return "๋ชจ๋ธ์ด ์ด๊ธฐํ๋์์ต๋๋ค.", semantic_text, graph_text
|
| 910 |
+
except Exception as e:
|
| 911 |
+
return f"๋ชจ๋ธ ์ด๊ธฐํ ์ค๋ฅ: {str(e)}", "", ""
|
| 912 |
+
|
| 913 |
+
# ๋ชจ๋ธ ์ ํ ๋ณ๊ฒฝ ์ ์ฒ๋ฆฌ
|
| 914 |
+
def change_model(new_model_name):
|
| 915 |
+
global model_name
|
| 916 |
+
model_name = new_model_name
|
| 917 |
+
status, semantic_text, graph_text = initialize_models()
|
| 918 |
+
return status, semantic_text, graph_text
|
| 919 |
|
| 920 |
|
| 921 |
|