arxivgpt kim commited on
Commit
4734803
ยท
verified ยท
1 Parent(s): ab0608f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -40
app.py CHANGED
@@ -1,52 +1,69 @@
1
  import streamlit as st
2
  import streamlit.components.v1 as components
 
3
 
4
- # Streamlit ์•ฑ ํƒ€์ดํ‹€ ์„ค์ •
 
 
 
 
5
  st.title('Vapi.ai Voice Widget Integration')
6
 
7
- # Vapi Voice Widget HTML ๋ฐ JavaScript ์Šค๋‹ˆํŽซ
8
- vapi_widget_snippet = """
9
  <script>
10
- var vapiInstance = null;
11
- const assistant = "36f0a337-96e4-48e0-b13d-ad632eeea312"; // ์—ฌ๊ธฐ์— ์‹ค์ œ ์–ด์‹œ์Šคํ„ดํŠธ ID ์ž…๋ ฅ
12
- const apiKey = "ea671a92-bb34-46dc-b999-70ef53b64a4b"; // ์—ฌ๊ธฐ์— ์‹ค์ œ Public API ํ‚ค ์ž…๋ ฅ
13
- const buttonConfig = {
14
- // ๋ฒ„ํŠผ ๊ตฌ์„ฑ ์„ค์ •
15
- position: "bottom-right",
16
- offset: "40px",
17
- width: "50px",
18
- height: "50px",
19
- idle: {
20
- color: `rgb(93, 254, 202)`,
21
- type: "pill",
22
- title: "Have a quick question?",
23
- subtitle: "Talk with our AI assistant",
24
- icon: `https://unpkg.com/lucide-static@0.321.0/icons/phone.svg`,
25
- }
26
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- (function(d, t) {
29
- var g = d.createElement(t),
30
  s = d.getElementsByTagName(t)[0];
31
- g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js";
32
- g.defer = true;
33
- g.async = true;
34
- s.parentNode.insertBefore(g, s);
35
-
36
- g.onload = function() {
37
- vapiInstance = window.vapiSDK.run({
38
- apiKey: apiKey,
39
- assistant: assistant,
40
- config: buttonConfig,
41
- });
42
- };
43
- })(document, "script");
44
  </script>
45
  """
46
 
47
- # ๋ฒ„ํŠผ ํด๋ฆญ์œผ๋กœ ์œ„์ ฏ์˜ ์‹คํ–‰/์ค‘์ง€๋ฅผ ์ œ์–ดํ•˜๊ธฐ ์œ„ํ•œ ์Šค๋‹ˆํŽซ์„ Streamlit ์ปดํฌ๋„ŒํŠธ๋กœ ์‚ฝ์ž…
48
- components.html(vapi_widget_snippet, height=0)
49
 
50
- st.markdown("""
51
- **Note:** ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ Vapi Voice Widget์„ ์‹คํ–‰/์ค‘์ง€ํ•˜์„ธ์š”.
52
- """)
 
1
  import streamlit as st
2
  import streamlit.components.v1 as components
3
+ import os
4
 
5
+ # Vapi.ai Voice Widget ์„ค์ •์„ ์œ„ํ•œ ๋ณ€์ˆ˜
6
+ assistant_id = "36f0a337-96e4-48e0-b13d-ad632eeea312"
7
+ public_api_key = "ea671a92-bb34-46dc-b999-70ef53b64a4b"
8
+
9
+ # Streamlit ํŽ˜์ด์ง€ ํƒ€์ดํ‹€ ์„ค์ •
10
  st.title('Vapi.ai Voice Widget Integration')
11
 
12
+ # HTML ๋ฐ JavaScript ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด Vapi.ai Voice Widget ์‚ฝ์ž…
13
+ html_code = f"""
14
  <script>
15
+ var vapiInstance = null;
16
+ const assistant = "{assistant_id}"; // ์–ด์‹œ์Šคํ„ดํŠธ ID
17
+ const apiKey = "{public_api_key}"; // ๊ณต๊ฐœ API ํ‚ค
18
+ const buttonConfig = {{
19
+ position: "bottom-right",
20
+ offset: "40px",
21
+ width: "50px",
22
+ height: "50px",
23
+ idle: {{
24
+ color: "rgb(93, 254, 202)",
25
+ type: "pill",
26
+ title: "Have a quick question?",
27
+ subtitle: "Talk with our AI assistant",
28
+ icon: "https://unpkg.com/lucide-static@0.321.0/icons/phone.svg",
29
+ }},
30
+ loading: {{
31
+ color: "rgb(93, 124, 202)",
32
+ type: "pill",
33
+ title: "Connecting...",
34
+ subtitle: "Please wait",
35
+ icon: "https://unpkg.com/lucide-static@0.321.0/icons/loader-2.svg",
36
+ }},
37
+ active: {{
38
+ color: "rgb(255, 0, 0)",
39
+ type: "pill",
40
+ title: "Call is in progress...",
41
+ subtitle: "End the call.",
42
+ icon: "https://unpkg.com/lucide-static@0.321.0/icons/phone-off.svg",
43
+ }},
44
+ }};
45
 
46
+ (function (d, t) {{
47
+ var g = d.createElement(t),
48
  s = d.getElementsByTagName(t)[0];
49
+ g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js";
50
+ g.defer = true;
51
+ g.async = true;
52
+ s.parentNode.insertBefore(g, s);
53
+
54
+ g.onload = function () {{
55
+ vapiInstance = window.vapiSDK.run({{
56
+ apiKey: apiKey,
57
+ assistant: assistant,
58
+ config: buttonConfig,
59
+ }});
60
+ }};
61
+ }})(document, "script");
62
  </script>
63
  """
64
 
65
+ # ๋ฒ„ํŠผ ํด๋ฆญ์œผ๋กœ Vapi Voice Widget ์‹คํ–‰/์ค‘์ง€ ์•ˆ๋‚ด
66
+ st.markdown("Note: ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ Vapi Voice Widget์„ ์‹คํ–‰/์ค‘์ง€ํ•˜์„ธ์š”.")
67
 
68
+ # Streamlit ์ปดํฌ๋„ŒํŠธ๋ฅผ ํ†ตํ•ด HTML & JavaScript ์ฝ”๋“œ ์‚ฝ์ž…
69
+ components.html(html_code, height=0)