sudhir2016 commited on
Commit
3e1059d
·
1 Parent(s): 9cb35d1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from langchain.vectorstores import Chroma
3
+ docsearch = Chroma.from_texts(texts, embeddings,persist_directory=persist_directory)
4
+ def answer(question):
5
+ out=chain.run(question)
6
+ return out
7
+ demo = gr.Interface(fn=answer, inputs='text',outputs='text',examples=[['What is the capital of India ?']])
8
+ demo.launch()
9
+ from langchain.docstore.document import Document
10
+ from langchain.embeddings import HuggingFaceEmbeddings
11
+ from langchain.text_splitter import CharacterTextSplitter
12
+ embeddings = HuggingFaceEmbeddings()
13
+ with open('Gita full.txt') as f:
14
+ gita = f.read()
15
+ text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
16
+ texts = text_splitter.split_text(gita)
17
+ docsearch = Chroma.from_texts(texts, embeddings)
18
+ def answer(query):
19
+ docs = docsearch.similarity_search(query)
20
+ out=docs[0].page_content
21
+ return out
22
+ demo = gr.Interface(fn=answer, inputs='text',outputs='text',examples=[['song celestial']])
23
+ demo.launch()