AgentOS-Core-V2 / app.py
Tpayne101's picture
Update app.py
ffb65c0 verified
raw
history blame
3.15 kB
import gradio as gr
from agentos_core_v2 import AgentCore
agent = AgentCore()
def run_agent(prompt):
response = agent.run(prompt)
return response
iface = gr.Interface(
fn=run_agent,
inputs=gr.Textbox(label="Prompt"),
outputs=gr.Textbox(label="Agent Output"),
title="🧠 AgentOS MVP",
description="Self-learning agent with memory + telemetry."
)
if __name__ == "__main__":
iface.launch()
from identity_core import IdentityCore
import json
def verify_identity():
identity = IdentityCore()
with open("agent_identities.json", "r") as f:
data = json.load(f)
last_id = list(data.keys())[-1]
sig = data[last_id]["signature"]
result = identity.verify_identity(last_id, sig)
return f"Verification result for {last_id}: {result}"
verify_btn = gr.Interface(
fn=lambda: verify_identity(),
inputs=[],
outputs="text",
title="Verify Agent Identity",
description="Checks cryptographic DNA of the latest agent instance"
)
iface.launch(share=True)
verify_btn.launch(share=True)
import gradio as gr
import json, os
def show_identities():
if os.path.exists("agent_identities.json"):
with open("agent_identities.json", "r") as f:
return json.dumps(json.load(f), indent=2)
return "No digital DNA file found yet."
dna_viewer = gr.Interface(
fn=show_identities,
inputs=[],
outputs="text",
title="🔐 Digital DNA Viewer",
description="View all agent identities and their signatures."
)
# Combine both UIs into tabs
app = gr.TabbedInterface([iface, dna_viewer], ["AgentOS Core", "Digital DNA Viewer"])
app.launch()
import gradio as gr
from agentos_core import AgentCore
from context_graph import ContextGraph
import json, os
# --- Instantiate Core Systems ---
agent = AgentCore()
graph = ContextGraph()
# --- Define main agent function ---
def interact(prompt):
response = agent.run(prompt)
return response
iface = gr.Interface(
fn=interact,
inputs="text",
outputs="text",
title="🧠 AgentOS MVP",
description="Self-learning agent with memory + telemetry."
)
# --- Context Query Tab ---
def query_context_ui(agent_id, keyword):
return "\n".join(graph.query_context(agent_id, keyword))
context_view = gr.Interface(
fn=query_context_ui,
inputs=[
gr.Textbox(label="Agent ID"),
gr.Textbox(label="Keyword")
],
outputs="text",
title="🕸 Context Memory Query",
description="Search what the agent already knows or has linked in memory."
)
# --- Digital DNA Viewer Tab ---
def show_identities():
if os.path.exists("agent_identities.json"):
with open("agent_identities.json", "r") as f:
return json.dumps(json.load(f), indent=2)
return "No digital DNA file found yet."
dna_viewer = gr.Interface(
fn=show_identities,
inputs=[],
outputs="text",
title="🔐 Digital DNA Viewer",
description="View all agent identities and their signatures."
)
# --- Combine all interfaces ---
app = gr.TabbedInterface(
[iface, dna_viewer, context_view],
["AgentOS Core", "Digital DNA Viewer", "Context Query"]
)
app.launch()