|
import gradio as gr |
|
|
|
|
|
widget_html = """ |
|
<div id="vapi-widget-container"></div> |
|
<script> |
|
var vapiInstance = null; |
|
const assistant = "d7aa8e1f-e2c6-4c97-a7d7-b32101eb1e0a"; // Assistant IDλ‘ λ체 |
|
const apiKey = "ea671a92-bb34-46dc-b999-70ef53b64a4b"; // Public keyλ‘ λ체 |
|
const buttonConfig = { |
|
position: "bottom-right", |
|
offset: "40px", |
|
width: "50px", |
|
height: "50px", |
|
idle: { |
|
color: `rgb(93, 254, 202)`, |
|
type: "pill", |
|
title: "Have a quick question?", |
|
subtitle: "Talk with our AI assistant", |
|
icon: `https://unpkg.com/[email protected]/icons/phone.svg`, |
|
}, |
|
loading: { |
|
color: `rgb(93, 124, 202)`, |
|
type: "pill", |
|
title: "Connecting...", |
|
subtitle: "Please wait", |
|
icon: `https://unpkg.com/[email protected]/icons/loader-2.svg`, |
|
}, |
|
active: { |
|
color: `rgb(255, 0, 0)`, |
|
type: "pill", |
|
title: "Call is in progress...", |
|
subtitle: "End the call.", |
|
icon: `https://unpkg.com/[email protected]/icons/phone-off.svg`, |
|
}, |
|
}; |
|
|
|
(function (d, t) { |
|
var g = d.createElement(t), s = d.getElementsByTagName(t)[0]; |
|
g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js"; |
|
g.defer = true; |
|
g.async = true; |
|
s.parentNode.insertBefore(g, s); |
|
g.onload = function () { |
|
vapiInstance = window.vapiSDK.run({ |
|
apiKey: apiKey, |
|
assistant: assistant, |
|
config: buttonConfig, |
|
containerId: 'vapi-widget-container', // Vapi μμ ―μ ν¬ν¨ν 컨ν
μ΄λ ID |
|
}); |
|
}; |
|
})(document, "script"); |
|
</script> |
|
""" |
|
|
|
def show_widget(): |
|
|
|
return widget_html |
|
|
|
|
|
iface = gr.Interface( |
|
fn=show_widget, |
|
inputs=[], |
|
outputs=gr.outputs.HTML(label="Vapi Voice Widget"), |
|
title="Vapi Voice Widget Integration Example", |
|
description="This is an example of integrating the Vapi Voice Widget into a Gradio web app." |
|
) |
|
|
|
|
|
iface.launch() |
|
|