import gradio as gr from langchain.vectorstores import Chroma from langchain.docstore.document import Document from langchain.embeddings import HuggingFaceEmbeddings from langchain.text_splitter import CharacterTextSplitter embeddings = HuggingFaceEmbeddings() #with open('Gita.txt') as f: #gita = f.read() gita="story of Arjun and Krishna refered to as song celestial" text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) texts = text_splitter.split_text(gita) docsearch = Chroma.from_texts(texts, embeddings) def answer(query): #docs = docsearch.similarity_search(query) #out=docs[0].page_content out=gita return out demo = gr.Interface(fn=answer, inputs='text',outputs='text',examples=[['song celestial']]) demo.launch()