arxivgpt kim commited on
Commit
0006fec
ยท
verified ยท
1 Parent(s): 75e40a4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -0
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()