Spaces:
Sleeping
Sleeping
File size: 3,828 Bytes
d6a3aa4 636ca5f d6a3aa4 636ca5f d6a3aa4 636ca5f d6a3aa4 636ca5f d6a3aa4 636ca5f d6a3aa4 636ca5f d6a3aa4 636ca5f d6a3aa4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
import os
import time
import gradio as gr
import requests
import json
import numpy as np
import google.generativeai as genai
from openai import OpenAI
from typing import List, Dict, Tuple
from sklearn.metrics.pairwise import cosine_similarity
from sentence_transformers import SentenceTransformer
# Animation CSS and HTML
LOADING_ANIMATION = """
<style>
.thinking-animation {
display: flex;
justify-content: center;
align-items: center;
height: 100px;
}
.dot-flashing {
position: relative;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: #4CAF50;
color: #4CAF50;
animation: dotFlashing 1s infinite linear alternate;
animation-delay: .5s;
}
.dot-flashing::before, .dot-flashing::after {
content: '';
display: inline-block;
position: absolute;
top: 0;
}
.dot-flashing::before {
left: -15px;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: #4CAF50;
color: #4CAF50;
animation: dotFlashing 1s infinite alternate;
animation-delay: 0s;
}
.dot-flashing::after {
left: 15px;
width: 10px;
height: 10px;
border-radius: 5px;
background-color: #4CAF50;
color: #4CAF50;
animation: dotFlashing 1s infinite alternate;
animation-delay: 1s;
}
@keyframes dotFlashing {
0% { background-color: #4CAF50; }
50%, 100% { background-color: rgba(76, 175, 80, 0.2); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.thinking-text {
text-align: center;
margin-top: 20px;
font-weight: bold;
color: #4CAF50;
}
</style>
<div class="thinking-animation">
<div class="dot-flashing"></div>
<div class="thinking-text">AGI Thinking...</div>
</div>
"""
class AGICognitiveSystem:
# ... (keep previous class implementation unchanged) ...
def create_agi_interface():
try:
agi = AGICognitiveSystem()
except ValueError as e:
return gr.Blocks().launch(error_message=str(e))
with gr.Blocks(title="Advanced AGI System", theme=gr.themes.Soft(), css="""
.cognitive-node { padding: 15px; margin: 10px; border-radius: 8px; background: #f8f9fa; }
.confidence-meter { height: 10px; background: #eee; border-radius: 5px; margin: 10px 0; }
.confidence-fill { height: 100%; border-radius: 5px; background: #4CAF50; }
""") as demo:
gr.Markdown("# 🧠 Advanced AGI Cognitive System")
with gr.Row():
input_panel = gr.Textbox(label="Input Query", lines=3,
placeholder="Enter complex query...")
with gr.Accordion("Cognitive Controls", open=False):
depth = gr.Slider(1, 10, value=5, label="Reasoning Depth")
creativity = gr.Slider(0, 1, value=0.7, label="Creativity Level")
loading = gr.HTML(LOADING_ANIMATION, visible=False)
output_panel = gr.Markdown()
visualization = gr.HTML()
metrics = gr.DataFrame(headers=["Metric", "Value"])
def toggle_loading():
return gr.HTML(visible=True)
def process_query(query):
start_time = time.time()
result, metrics = agi.cognitive_flow(query)
return result, metrics
input_panel.submit(
fn=toggle_loading,
inputs=None,
outputs=loading,
queue=False
).then(
fn=process_query,
inputs=input_panel,
outputs=[output_panel, metrics],
).then(
lambda: gr.HTML(visible=False),
inputs=None,
outputs=loading,
queue=False
)
return demo
if __name__ == "__main__":
create_agi_interface().launch(server_port=7860) |