Commit
·
ef86623
1
Parent(s):
c038b95
update engine
Browse files
app.py
CHANGED
@@ -20,14 +20,14 @@ def loading_pdf():
|
|
20 |
def pdf_changes(pdf_doc):
|
21 |
loader = OnlinePDFLoader(pdf_doc.name)
|
22 |
documents = loader.load()
|
23 |
-
text_splitter = CharacterTextSplitter(chunk_size=
|
24 |
texts = text_splitter.split_documents(documents)
|
25 |
embeddings = OpenAIEmbeddings()
|
26 |
db = Chroma.from_documents(texts, embeddings)
|
27 |
retriever = db.as_retriever()
|
28 |
global qa
|
29 |
qa = ConversationalRetrievalChain.from_llm(
|
30 |
-
llm=OpenAI(temperature=0.2),
|
31 |
retriever=retriever,
|
32 |
return_source_documents=False)
|
33 |
return "Ready"
|
@@ -96,7 +96,7 @@ with gr.Blocks(css=css) as demo:
|
|
96 |
load_pdf = gr.Button("Convert PDF to Magic AI language")
|
97 |
clear_btn = gr.Button("Clear Data")
|
98 |
|
99 |
-
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=
|
100 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
101 |
submit_btn = gr.Button("Send Message")
|
102 |
|
@@ -110,4 +110,4 @@ with gr.Blocks(css=css) as demo:
|
|
110 |
bot, chatbot, chatbot
|
111 |
)
|
112 |
|
113 |
-
demo.launch()
|
|
|
20 |
def pdf_changes(pdf_doc):
|
21 |
loader = OnlinePDFLoader(pdf_doc.name)
|
22 |
documents = loader.load()
|
23 |
+
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
|
24 |
texts = text_splitter.split_documents(documents)
|
25 |
embeddings = OpenAIEmbeddings()
|
26 |
db = Chroma.from_documents(texts, embeddings)
|
27 |
retriever = db.as_retriever()
|
28 |
global qa
|
29 |
qa = ConversationalRetrievalChain.from_llm(
|
30 |
+
llm=OpenAI(temperature=0.2, engine=GPT3-turbo, max_tokens=16000),
|
31 |
retriever=retriever,
|
32 |
return_source_documents=False)
|
33 |
return "Ready"
|
|
|
96 |
load_pdf = gr.Button("Convert PDF to Magic AI language")
|
97 |
clear_btn = gr.Button("Clear Data")
|
98 |
|
99 |
+
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=450)
|
100 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
101 |
submit_btn = gr.Button("Send Message")
|
102 |
|
|
|
110 |
bot, chatbot, chatbot
|
111 |
)
|
112 |
|
113 |
+
demo.launch()
|