Spaces:
Sleeping
Sleeping
File size: 708 Bytes
b1229df 8943693 a61d0da 8943693 86b5c4d 8943693 37e3916 c743029 37e3916 a61d0da 8943693 |
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 |
import os
import openai
import streamlit as st
openai.api_key = os.getenv("OPENAI_API_KEY")
temperature = 0
input = st.text_area("Input")
if st.button("Submit", type="primary"):
st.markdown("----")
res_box = st.empty()
content = []
for chunk in openai.ChatCompletion.create(
model="gpt-3.5-turbo",
temperature=temperature,
messages=[{"role": "user", "content": input}],
stream=True,
):
chunk_content = chunk["choices"][0].get("delta", {}).get("content")
if chunk_content is not None:
content.append(chunk_content)
result = "".join(content).strip()
res_box.markdown(f"```\n{result}\n```")
st.markdown("----") |