vpst2 / app.py
arxivgpt kim
Update app.py
4734803 verified
import streamlit as st
import streamlit.components.v1 as components
import os
# Vapi.ai Voice Widget ์„ค์ •์„ ์œ„ํ•œ ๋ณ€์ˆ˜
assistant_id = "36f0a337-96e4-48e0-b13d-ad632eeea312"
public_api_key = "ea671a92-bb34-46dc-b999-70ef53b64a4b"
# Streamlit ํŽ˜์ด์ง€ ํƒ€์ดํ‹€ ์„ค์ •
st.title('Vapi.ai Voice Widget Integration')
# HTML ๋ฐ JavaScript ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด Vapi.ai Voice Widget ์‚ฝ์ž…
html_code = f"""
<script>
var vapiInstance = null;
const assistant = "{assistant_id}"; // ์–ด์‹œ์Šคํ„ดํŠธ ID
const apiKey = "{public_api_key}"; // ๊ณต๊ฐœ API ํ‚ค
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/lucide-static@0.321.0/icons/phone.svg",
}},
loading: {{
color: "rgb(93, 124, 202)",
type: "pill",
title: "Connecting...",
subtitle: "Please wait",
icon: "https://unpkg.com/lucide-static@0.321.0/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/lucide-static@0.321.0/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,
}});
}};
}})(document, "script");
</script>
"""
# ๋ฒ„ํŠผ ํด๋ฆญ์œผ๋กœ Vapi Voice Widget ์‹คํ–‰/์ค‘์ง€ ์•ˆ๋‚ด
st.markdown("Note: ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ Vapi Voice Widget์„ ์‹คํ–‰/์ค‘์ง€ํ•˜์„ธ์š”.")
# Streamlit ์ปดํฌ๋„ŒํŠธ๋ฅผ ํ†ตํ•ด HTML & JavaScript ์ฝ”๋“œ ์‚ฝ์ž…
components.html(html_code, height=0)