kgc-agents / app.py
RubenPeeters
Change agents
47a0a0e
import gradio as gr
from agents import manager_agent
# Define a simple function that the Gradio app will use.
# This function takes a string as input and returns its reverse.
def start_process(text):
"""
Reverses the input string.
Args:
text (str): The input string to be reversed.
Returns:
str: The reversed string.
"""
return manager_agent.run(f"Please derive a knowledge graph from the text between <TEXT></TEXT>. Do NOT look up new facts. Make sure that your final output is a valid RDF file. \
<TEXT>{text}</TEXT>")
# Create the Gradio interface.
# gr.Interface takes:
# - fn: The function to wrap.
# - inputs: The input component(s). Here, a simple Textbox.
# - outputs: The output component(s). Here, another Textbox.
# - title: A title for the Gradio app.
# - description: A brief description of the app.
iface = gr.Interface(
fn=start_process,
inputs=gr.Textbox(lines=2, placeholder="Enter text here...", label="Input Text"),
outputs=gr.Textbox(label="Final output"),
title="KGC Agents",
description="Type some text into the input box, and the app will create a knowledge graph for you! (WIP)"
)
# Launch the Gradio app.
# The 'share=True' argument creates a public link for sharing (useful for testing).
# For Hugging Face Spaces, you typically don't need 'share=True' as Spaces handles deployment.
if __name__ == "__main__":
iface.launch()