hf / app.py
stevafernandes's picture
Upload 4 files
450f43c verified
Raw History Blame Contribute Delete
1.46 kB
"""Gradio front end for customer_support.py, used as the Hugging Face Space.
Run locally: python app.py
"""
import gradio as gr
from customer_support import crew
# Free Hugging Face accounts run Gradio Spaces on ZeroGPU, which refuses to
# start an app without a @spaces.GPU function. This one is never called.
try:
import spaces
@spaces.GPU
def zerogpu_startup():
pass
except ImportError:
pass
def answer(customer, person, inquiry):
result = crew.kickoff(
inputs={"customer": customer, "person": person, "inquiry": inquiry}
)
return result.raw
demo = gr.Interface(
fn=answer,
inputs=[
gr.Textbox(label="Customer", value="DeepLearningAI"),
gr.Textbox(label="Person", value="Andrew Ng"),
gr.Textbox(
label="Inquiry",
lines=4,
value="I need help with setting up a Crew "
"and kicking it off, specifically "
"how can I add memory to my crew? "
"Can you provide guidance?",
),
],
outputs=gr.Markdown(),
title="Multi-agent customer support automation",
description="A support representative answers the inquiry using the "
"CrewAI docs, then a QA specialist reviews the answer.",
flagging_mode="never",
# The crew object is shared, so requests must run one at a time.
concurrency_limit=1,
)
if __name__ == "__main__":
demo.launch()