Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -775,48 +775,48 @@ def create_agi_interface():
|
|
775 |
async def process_query(query, depth):
|
776 |
agi.log(f"Processing query with depth {depth}: {query}")
|
777 |
|
778 |
-
|
779 |
-
|
|
|
|
|
|
|
780 |
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
}
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
)
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
f"<div class='error'>Processing error: {str(e)}</div>",
|
818 |
-
{"error": str(e)}
|
819 |
-
)
|
820 |
|
821 |
def clear_interface():
|
822 |
return "", "", None
|
@@ -839,6 +839,5 @@ if __name__ == "__main__":
|
|
839 |
app = create_agi_interface()
|
840 |
app.launch(
|
841 |
server_name="0.0.0.0",
|
842 |
-
server_port=7860
|
843 |
-
share=True # Creates a public link for sharing
|
844 |
)
|
|
|
775 |
async def process_query(query, depth):
|
776 |
agi.log(f"Processing query with depth {depth}: {query}")
|
777 |
|
778 |
+
progress_bar = gr.Progress()
|
779 |
+
progress_bar(0, desc="Initializing...")
|
780 |
+
|
781 |
+
try:
|
782 |
+
start_time = time.time()
|
783 |
|
784 |
+
# Limit the steps based on depth setting
|
785 |
+
agi.thinking_steps = agi.thinking_steps[:depth] if agi.thinking_steps else []
|
786 |
+
|
787 |
+
final, metadata = await agi.hierarchical_reasoning(query)
|
788 |
+
process_time = time.time() - start_time
|
789 |
+
|
790 |
+
# Prepare performance metrics
|
791 |
+
steps_data = []
|
792 |
+
for step in agi.thinking_steps:
|
793 |
+
steps_data.append({
|
794 |
+
"name": step.name,
|
795 |
+
"time": step.execution_time,
|
796 |
+
"percentage": (step.execution_time / process_time) * 100
|
797 |
+
})
|
798 |
+
|
799 |
+
metrics_data = {
|
800 |
+
"total_time": process_time,
|
801 |
+
"steps_completed": len(agi.thinking_steps),
|
802 |
+
"average_step_time": sum(s["time"] for s in steps_data) / len(steps_data) if steps_data else 0,
|
803 |
+
"steps": steps_data,
|
804 |
+
"metadata": metadata
|
805 |
+
}
|
806 |
+
|
807 |
+
return (
|
808 |
+
f"## Optimized Response\n{final}\n\n"
|
809 |
+
f"**Processing Time**: {process_time:.2f}s\n"
|
810 |
+
f"**Cognitive Steps Executed**: {len(agi.thinking_steps)}",
|
811 |
+
agi.visualize_thought_process(),
|
812 |
+
metrics_data
|
813 |
+
)
|
814 |
+
except Exception as e:
|
815 |
+
return (
|
816 |
+
f"## Error Processing Query\n\nAn error occurred: {str(e)}",
|
817 |
+
f"<div class='error'>Processing error: {str(e)}</div>",
|
818 |
+
{"error": str(e)}
|
819 |
+
)
|
|
|
|
|
|
|
820 |
|
821 |
def clear_interface():
|
822 |
return "", "", None
|
|
|
839 |
app = create_agi_interface()
|
840 |
app.launch(
|
841 |
server_name="0.0.0.0",
|
842 |
+
server_port=7860
|
|
|
843 |
)
|