arxivgpt kim
commited on
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# HTML ์์ ฏ ์ฝ๋. ์ค์ `<assistant_id>`์ `<your_public_api_key>`๋ ์ ์ ํ ๊ฐ์ผ๋ก ๋์ฒดํด์ผ ํฉ๋๋ค.
|
4 |
+
widget_html = """
|
5 |
+
<div id="vapi-widget-container"></div>
|
6 |
+
<script>
|
7 |
+
var vapiInstance = null;
|
8 |
+
const assistant = "d7aa8e1f-e2c6-4c97-a7d7-b32101eb1e0a"; // Assistant ID๋ก ๋์ฒด
|
9 |
+
const apiKey = "ea671a92-bb34-46dc-b999-70ef53b64a4b"; // Public key๋ก ๋์ฒด
|
10 |
+
const buttonConfig = {
|
11 |
+
position: "bottom-right",
|
12 |
+
offset: "40px",
|
13 |
+
width: "50px",
|
14 |
+
height: "50px",
|
15 |
+
idle: {
|
16 |
+
color: `rgb(93, 254, 202)`,
|
17 |
+
type: "pill",
|
18 |
+
title: "Have a quick question?",
|
19 |
+
subtitle: "Talk with our AI assistant",
|
20 |
+
icon: `https://unpkg.com/[email protected]/icons/phone.svg`,
|
21 |
+
},
|
22 |
+
loading: {
|
23 |
+
color: `rgb(93, 124, 202)`,
|
24 |
+
type: "pill",
|
25 |
+
title: "Connecting...",
|
26 |
+
subtitle: "Please wait",
|
27 |
+
icon: `https://unpkg.com/[email protected]/icons/loader-2.svg`,
|
28 |
+
},
|
29 |
+
active: {
|
30 |
+
color: `rgb(255, 0, 0)`,
|
31 |
+
type: "pill",
|
32 |
+
title: "Call is in progress...",
|
33 |
+
subtitle: "End the call.",
|
34 |
+
icon: `https://unpkg.com/[email protected]/icons/phone-off.svg`,
|
35 |
+
},
|
36 |
+
};
|
37 |
+
|
38 |
+
(function (d, t) {
|
39 |
+
var g = d.createElement(t), s = d.getElementsByTagName(t)[0];
|
40 |
+
g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js";
|
41 |
+
g.defer = true;
|
42 |
+
g.async = true;
|
43 |
+
s.parentNode.insertBefore(g, s);
|
44 |
+
g.onload = function () {
|
45 |
+
vapiInstance = window.vapiSDK.run({
|
46 |
+
apiKey: apiKey,
|
47 |
+
assistant: assistant,
|
48 |
+
config: buttonConfig,
|
49 |
+
containerId: 'vapi-widget-container', // Vapi ์์ ฏ์ ํฌํจํ ์ปจํ
์ด๋ ID
|
50 |
+
});
|
51 |
+
};
|
52 |
+
})(document, "script");
|
53 |
+
</script>
|
54 |
+
"""
|
55 |
+
|
56 |
+
def show_widget():
|
57 |
+
# Gradio HTML ์ปดํฌ๋ํธ์ ์์ ฏ ์ฝ๋๋ฅผ ์ ๋ฌํฉ๋๋ค.
|
58 |
+
return widget_html
|
59 |
+
|
60 |
+
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
61 |
+
iface = gr.Interface(
|
62 |
+
fn=show_widget,
|
63 |
+
inputs=[], # ์
๋ ฅ ์์
|
64 |
+
outputs=gr.outputs.HTML(label="Vapi Voice Widget"), # HTML ์ถ๋ ฅ
|
65 |
+
title="Vapi Voice Widget Integration Example",
|
66 |
+
description="This is an example of integrating the Vapi Voice Widget into a Gradio web app."
|
67 |
+
)
|
68 |
+
|
69 |
+
# ์ธํฐํ์ด์ค ์คํ
|
70 |
+
iface.launch()
|