arxivgpt kim commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,52 +1,69 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import streamlit.components.v1 as components
|
|
|
|
| 3 |
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
st.title('Vapi.ai Voice Widget Integration')
|
| 6 |
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
<script>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
s = d.getElementsByTagName(t)[0];
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
</script>
|
| 45 |
"""
|
| 46 |
|
| 47 |
-
# ๋ฒํผ ํด๋ฆญ์ผ๋ก
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 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)
|
|
|