timmy / Streamlit 整合 Lit Web Component
0 вподобань
0 форк(-ів)
1 файл(-ів)
Остання активність 10 months ago
此範例展示如何在 Streamlit 應用中嵌入 Lit Web Component,而不依賴 CDN。使用 Web Components 技術,可封裝自訂 UI 元件,並透過 JavaScript 互動,適用於建立模組化的前端元件,提升 Web 應用的可維護性與重用性。
| 1 | import streamlit as st |
| 2 | import streamlit.components.v1 as components |
| 3 | |
| 4 | st.title("使用 Lit Web Component (無 CDN)") |
| 5 | |
| 6 | lit_component = """ |
| 7 | <script type="module"> |
| 8 | class MyLitComponent extends HTMLElement { |
| 9 | constructor() { |
| 10 | super(); |
timmy / Streamlit 聊天應用示範
0 вподобань
0 форк(-ів)
1 файл(-ів)
Остання активність 10 months ago
| 1 | import streamlit as st |
| 2 | import random |
| 3 | import time |
| 4 | |
| 5 | st.write("Streamlit loves LLMs! 🤖 [Build your own chat app](https://docs.streamlit.io/develop/tutorials/llms/build-conversational-apps) in minutes, then make it powerful by adding images, dataframes, or even input widgets to the chat.") |
| 6 | |
| 7 | st.caption("Note that this demo app isn't actually connected to any LLMs. Those are expensive ;)") |
| 8 | |
| 9 | # Initialize chat history |
| 10 | if "messages" not in st.session_state: |
Новіше
Пізніше