import os
import streamlit as st
from langchain.indexes import VectorstoreIndexCreator

api_key = st.text_input('openai_api_key')
if api_key:
    os.environ["OPENAI_API_KEY"] = api_key

article = st.text_area('article')
if article:
    from langchain.schema import Document
    documents = Document(page_content=article, metadata={})
    index = VectorstoreIndexCreator().from_documents([documents])

query = st.text_input('query')
if article and query:
    result = index.query(query)
    print(result)
    st.write(result)