vonewman commited on
Commit
52250df
1 Parent(s): b4fc904

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from openai import OpenAI
2
+ import streamlit as st
3
+
4
+ st.title("Adia")
5
+
6
+ BASE_URL = "https://vbexgdoycqoukq-8000.proxy.runpod.net/v1"
7
+ API_KEY="SOMEHOW"
8
+
9
+ client = OpenAI(
10
+ base_url=BASE_URL,
11
+ api_key=API_KEY
12
+ )
13
+
14
+ if "openai_model" not in st.session_state:
15
+ st.session_state["openai_model"] = "CONCREE/meta-adia-llm-instruct"
16
+
17
+ if "messages" not in st.session_state:
18
+ st.session_state.messages = []
19
+
20
+ for message in st.session_state.messages:
21
+ with st.chat_message(message["role"]):
22
+ st.markdown(message["content"])
23
+
24
+ if prompt := st.chat_input("Comment tu vas?"):
25
+ st.session_state.messages.append({"role": "user", "content": prompt})
26
+ with st.chat_message("user"):
27
+ st.markdown(prompt)
28
+
29
+ with st.chat_message("assistant"):
30
+ stream = client.chat.completions.create(
31
+ model=st.session_state["openai_model"],
32
+ messages=[
33
+ {"role": m["role"], "content": m["content"]}
34
+ for m in st.session_state.messages
35
+ ],
36
+ stream=True,
37
+ )
38
+ response = st.write_stream(stream)
39
+ st.session_state.messages.append({"role": "assistant", "content": response})