fiona commited on
Commit
fd6114e
·
1 Parent(s): bb26e07

replaced with Streamlit.

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -4,6 +4,7 @@ from langchain.text_splitter import CharacterTextSplitter
4
  from langchain.chains.question_answering import load_qa_chain
5
  from langchain.llms import OpenAI
6
  import os
 
7
 
8
  with open("guide1.txt") as f:
9
  hitchhikersguide = f.read()
@@ -21,16 +22,12 @@ def make_inference(query):
21
  docs = docsearch.get_relevant_documents(query)
22
  return(chain.run(input_documents=docs, question=query))
23
 
24
- if __name__ == "__main__":
25
- # make a gradio interface
26
- import gradio as gr
27
-
28
- gr.Interface(
29
- make_inference,
30
- [
31
- gr.inputs.Textbox(lines=2, label="Query"),
32
- ],
33
- gr.outputs.Textbox(label="Response"),
34
- title="🗣️TalkToMyDoc📄",
35
- description="🗣️TalkToMyDoc📄 is a tool that allows you to ask questions about a document. In this case - Hitch Hitchhiker's Guide to the Galaxy.",
36
- ).launch()
 
4
  from langchain.chains.question_answering import load_qa_chain
5
  from langchain.llms import OpenAI
6
  import os
7
+ import streamlit as st
8
 
9
  with open("guide1.txt") as f:
10
  hitchhikersguide = f.read()
 
22
  docs = docsearch.get_relevant_documents(query)
23
  return(chain.run(input_documents=docs, question=query))
24
 
25
+
26
+ # Title of the web application
27
+ st.title('🗣️TalkToMyDoc📄')
28
+
29
+ # Text input widget
30
+ user_input = st.text_input('Enter a query:', '')
31
+
32
+ # Displaying output directly below the input field
33
+ st.write('Answer:', make_inference(user_input))