Formatting code
Browse files5 unmodified lines6789101118 unmodified lines3031323334353611 unmodified lines4849505152535455565758596061626364655 unmodified linesfrom langchain.indexes import VectorstoreIndexCreatorimport osdef set_openai_key(raw_key):logging.warning(raw_key)os.environ["OPENAI_API_KEY"] = raw_key18 unmodified linesdef ask_question(chain, question_text):logging.info(type(chain))return chain({"question": question_text})["result"]def create_ask(pdf_object, question_text):loader = PDFMinerLoader(pdf_object.name)index_creator = VectorstoreIndexCreator()11 unmodified lineswith gr.Blocks() as demo:# pdf_button = gr.Button(value="pdf_button")oai_token = gr.Textbox(label="OpenAI Token", placeholder="Lm-iIas452gaw3erGtPar26gERGSA5RVkFJQST23WEG524EWEl")oai_token.change(set_openai_key, oai_token)pdf_object = gr.File(label="Upload your CV in PDF format",file_count="single",type="file")chain_state = gr.State()# pdf_button.click(create_langchain, inputs=pdf_object, outputs=chain_state)question_box = gr.Textbox(label="Question", value="Which are the candidate top hard skills? Enumerate in few bullet points.")qa_button = gr.Button(value="Submit question", interactive=False)lchain = pdf_object.change(create_langchain, inputs=pdf_object, outputs=[chain_state, qa_button])qa_button.click(ask_question, inputs=[chain_state, question_box], outputs=gr.Textbox(label="Answer"))demo.launch(debug=True)5 unmodified lines678910111218 unmodified lines313233343536373811 unmodified lines5051525354555657585960616263646566676869707172737475767778795 unmodified linesfrom langchain.indexes import VectorstoreIndexCreatorimport osdef set_openai_key(raw_key):logging.warning(raw_key)os.environ["OPENAI_API_KEY"] = raw_key18 unmodified linesdef ask_question(chain, question_text):logging.info(type(chain))return chain({"question": question_text})["result"]def create_ask(pdf_object, question_text):loader = PDFMinerLoader(pdf_object.name)index_creator = VectorstoreIndexCreator()11 unmodified lineswith gr.Blocks() as demo:# pdf_button = gr.Button(value="pdf_button")oai_token = gr.Textbox(label="OpenAI Token",placeholder="Lm-iIas452gaw3erGtPar26gERGSA5RVkFJQST23WEG524EWEl",)oai_token.change(set_openai_key, oai_token)pdf_object = gr.File(label="Upload your CV in PDF format", file_count="single", type="file")chain_state = gr.State()question_placeholder = """Enumerate the candidate's top 5 hard skills and rate them by importance from 0 to 5.Example:- Algebra 5/5"""question_box = gr.Textbox(label="Question", value=question_placeholder)qa_button = gr.Button(value="Submit question", interactive=False)lchain = pdf_object.change(create_langchain, inputs=pdf_object, outputs=[chain_state, qa_button])qa_button.click(ask_question,inputs=[chain_state, question_box],outputs=gr.Textbox(label="Answer"),)demo.launch(debug=True)
app.py+24-10