Spaces:
Sleeping
Sleeping
Commit
·
280a867
1
Parent(s):
8943693
Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +5,21 @@ openai.api_key = os.getenv("OPENAI_API_KEY")
|
|
5 |
|
6 |
temperature = 0
|
7 |
|
8 |
-
input = st.text_input("
|
9 |
|
10 |
if st.button("Submit", type="primary"):
|
11 |
st.markdown("----")
|
12 |
res_box = st.empty()
|
13 |
|
14 |
content = []
|
15 |
-
for
|
16 |
model="gpt-3.5-turbo",
|
17 |
temperature=temperature,
|
18 |
messages=[{"role": "user", "content": input}],
|
19 |
stream=True,
|
20 |
):
|
21 |
-
content.append(
|
22 |
result = "".join(content).strip()
|
23 |
result = result.replace("\n", "")
|
24 |
-
res_box.markdown(
|
25 |
st.markdown("----")
|
|
|
5 |
|
6 |
temperature = 0
|
7 |
|
8 |
+
input = st.text_input("Input")
|
9 |
|
10 |
if st.button("Submit", type="primary"):
|
11 |
st.markdown("----")
|
12 |
res_box = st.empty()
|
13 |
|
14 |
content = []
|
15 |
+
for chunk in openai.Completion.create(
|
16 |
model="gpt-3.5-turbo",
|
17 |
temperature=temperature,
|
18 |
messages=[{"role": "user", "content": input}],
|
19 |
stream=True,
|
20 |
):
|
21 |
+
content.append(chunk["choices"][0].get("delta", {}).get("content"))
|
22 |
result = "".join(content).strip()
|
23 |
result = result.replace("\n", "")
|
24 |
+
res_box.markdown(result)
|
25 |
st.markdown("----")
|