Spaces:
Running
Running
File size: 1,669 Bytes
dc84669 f904c62 dc84669 f904c62 dc84669 f904c62 dc84669 f904c62 dc84669 f904c62 dc84669 f904c62 ffe9928 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import gradio as gr
from bedrock_client import claude_llm
from utils import load_users
AUTHS = load_users('user.csv')
def chat(user_message, history):
# append the user message
messages = history + [{"role":"user","content":user_message}]
# pick the right LLM
llm = claude_llm
full = ""
# stream tokens as they arrive
for token in llm.stream(user_message):
full += token
# yield an updated history snapshot
yield messages + [{"role":"assistant","content": full}]
# final history
messages.append({"role":"assistant","content":full})
yield messages
with gr.Blocks(css_paths=["static/deval.css"],theme = gr.themes.Default(primary_hue="blue", secondary_hue="yellow"),) as demo:
# ββ Logo + Header + Logout ββββββββββββββββββββββββββββββββ
gr.Image(
value="static/logo.png",
show_label=False,
interactive=False,
show_download_button=False,
show_fullscreen_button=False,
elem_id="logo-primary", # matches the CSS above
)
#logout_btn = gr.Button("Logout", elem_id="logout-btn")
# inject auto-reload script
gr.HTML(
"""
<script>
// Reload the page after 1 minutes (300β000 ms)
setTimeout(() => {
window.location.reload();
}, 1000);
</script>
"""
)
gr.ChatInterface(
chat,
type="messages",
editable=True,
concurrency_limit=200,
save_history=True,
)
demo.queue().launch(auth=AUTHS,share=True, ssr_mode=False,share=True) |