from openai import OpenAI import streamlit as st st.markdown(''' Hey there, I wrote a book titled "**:purple[Hands-On Retrieval-Augmented Generation]**," which includes this interactive example. If you\'re interested in exploring more practical applications of Retrieval-Augmented Generation, be sure to [check it out](https://retrieval-augmented-generation.com)! ''') st.header('Question-Answering System', divider='rainbow') client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"]) text_search = st.text_input("Ask a question", value="") if st.button("Ask"): with st.spinner("Searching for an answer..."): response = client.chat.completions.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": text_search}], stream=False, ) st.write(response)