Spaces:
Sleeping
Sleeping
Download app.py from HugThang/EndPointMistral: direct link, hf CLI and curl.
- Browser
- Download file 882 Bytes
-
https://huggingface.co/spaces/HugThang/EndPointMistral/resolve/main/app.py
- Command line
-
hf download hf://spaces/HugThang/EndPointMistral/app.py
-
curl -L -o app.py https://huggingface.co/spaces/HugThang/EndPointMistral/resolve/main/app.py
882 Bytes
| import streamlit as st | |
| from inference import * | |
| st.title("💬 Chatbot") | |
| st.caption("🚀 A streamlit chatbot powered by Mistral LLM") | |
| if "messages" not in st.session_state: | |
| st.session_state["messages"] = [{"role": "assistant", "content": "How can I help you?"}] | |
| for msg in st.session_state.messages: | |
| st.chat_message(msg["role"]).write(msg["content"]) | |
| if prompt := st.chat_input(): | |
| # client = OpenAI(api_key=openai_api_key) | |
| st.session_state.messages.append({"role": "user", "content": prompt}) | |
| st.chat_message("user").write(prompt) | |
| response = generate_text(st.session_state.messages) #client.chat.completions.create(model="gpt-3.5-turbo", messages=st.session_state.messages) | |
| msg = response #response.choices[0].message.content | |
| st.session_state.messages.append({"role": "assistant", "content": msg}) | |
| st.chat_message("assistant").write(msg) | |