File size: 1,459 Bytes
51ef060
69e0484
 
51ef060
 
 
31a8dd3
51ef060
 
 
 
 
 
 
 
 
47a0a0e
31a8dd3
51ef060
 
 
 
 
 
 
 
 
fdd0d57
51ef060
69e0484
 
31a8dd3
51ef060
 
 
 
 
 
 
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
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()