Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from quantum_learner import QuantumLearner | |
| from memory_utils import get_history | |
| from transformers import pipeline | |
| # Inicijalizacija komponenti | |
| model = pipeline("text-generation", model="facebook/opt-350m") | |
| learner = QuantumLearner() | |
| def iskon_odgovori(pitanje, povijest): | |
| # Generiranje odgovora | |
| kontekst = "\n".join([f"{p}:{o}" for p, o in povijest[-5:]]) if povijest else "" | |
| prompt = f"ISKON DIJALOG:\n{kontekst}\nPitanje: {pitanje}\nOdgovor:" | |
| odgovor = model( | |
| prompt, | |
| max_length=150, | |
| temperature=0.7 | |
| )[0]["generated_text"].split("Odgovor:")[1].strip() | |
| # Periodička analiza | |
| if len(get_history()) % 10 == 0: | |
| learner.analyze_conversations() | |
| return odgovor | |
| # Gradio sučelje | |
| with gr.Blocks(title="ISKON OS") as app: | |
| gr.Markdown("## 🌳 DOBRODOŠLI U ISKON SUSTAV") | |
| with gr.Tab("💬 Duhovni Dijalog"): | |
| chatbot = gr.Chatbot() | |
| poruka = gr.Textbox(label="Što te muči, dušo?") | |
| btn = gr.Button("POŠALJI") | |
| with gr.Tab("🧠 Kvantna Inteligencija"): | |
| insights = gr.Textbox(label="Otkrij skrivene teme", interactive=False) | |
| analiza_btn = gr.Button("ANALIZIRAJ") | |
| # Event handlers | |
| btn.click( | |
| fn=iskon_odgovori, | |
| inputs=[poruka, chatbot], | |
| outputs=[chatbot] | |
| ) | |
| analiza_btn.click( | |
| fn=lambda: str(learner.analyze_conversations()), | |
| outputs=insights | |
| ) | |
| if __name__ == "__main__": | |
| app.launch() |