import gradio as gr from qiskit import QuantumCircuit from qiskit_aer import AerSimulator from goldbach_core import run_quantum import matplotlib.pyplot as plt def goldbach_interface(N): N = int(N) if N % 2 != 0 or N < 4: return "Введите чётное N ≥ 4" res = run_quantum(N) if res: p, q = res fig, ax = plt.subplots() ax.bar([f"{p}+{q}"], [1], color='teal') ax.set_title(f"{N} = {p} + {q}") ax.set_ylabel("Сигнал") return fig else: return "Пара не найдена (маловероятно для N ≤ 1000)" demo = gr.Interface( fn=goldbach_interface, inputs=gr.Number(label="Чётное N", value=30), outputs=gr.Plot(), title="Q-GoH: Quantum Goldbach Hypothesis", description="Квантовый поиск пары (p,q) такой, что p+q=N." ) if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860)