AminMemon commited on
Commit
bb7c702
·
1 Parent(s): 98409ae

Initial Upload

Browse files
Files changed (2) hide show
  1. app.py +88 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import os
3
+ from paperqa import Docs
4
+ import gradio as gr
5
+ from langchain.document_loaders import PyPDFLoader
6
+ from langchain.vectorstores import Chroma
7
+ from langchain.embeddings.openai import OpenAIEmbeddings
8
+ from langchain.document_loaders import UnstructuredPDFLoader
9
+ from langchain.llms import OpenAI
10
+ from langchain.chains.question_answering import load_qa_chain
11
+ from langchain.chat_models import ChatOpenAI
12
+
13
+ css_style = """
14
+
15
+ .gradio-container {
16
+ font-family: "IBM Plex Mono";
17
+ }
18
+
19
+ .answerText p {
20
+ font-size: 24px !important;
21
+ color: red !important;
22
+ }
23
+ """
24
+
25
+
26
+
27
+ def run(uploaded_files):
28
+ all_files = []
29
+ if uploaded_files is None:
30
+ return all_files
31
+ for file in uploaded_files:
32
+ if file.name.endswith('.pdf'):
33
+ all_files.append(file.name)
34
+ print(all_files)
35
+ return all_files
36
+
37
+
38
+ def createAnswer(files, designation, openaikey):
39
+ openai.api_key = openaikey
40
+ docs = Docs(llm='gpt-3.5-turbo')
41
+ for d in files:
42
+ docs.add(d.name)
43
+ answer = docs.query(
44
+ f"Based on the CV/Resume data who is the best person to hire for {designation}. Provide a list with the candidate name.")
45
+ print(answer.formatted_answer)
46
+ print(type(answer))
47
+ return answer.answer
48
+
49
+
50
+ with gr.Blocks(css=css_style) as demo:
51
+ docs = gr.State(None)
52
+ data = gr.State([])
53
+
54
+ gr.Markdown(f"""
55
+ # HR-GPT - Filter & Find The Best Candidate for the Job using AI
56
+
57
+ *By Amin Memon ([@AminMemon](https://twitter.com/AminMemon))*
58
+
59
+ This tool will enable asking questions of your uploaded text, PDF documents,.
60
+ It uses OpenAI's ChatGPT model & OpenAI Embeddings and thus you must enter your API key below.
61
+
62
+ This tool is under active development and currently uses many tokens - up to 10,000
63
+ for a single query. That is $0.10-0.20 per query, so please be careful!
64
+ Porting it to Llama.cpp soon for saved cost.
65
+
66
+ 1. Enter API Key ([What is that?](https://platform.openai.com/account/api-keys))
67
+ 2. Upload your Resumes (Try a few resumes/cv to try < 5)
68
+ 3. Provide Designation for which you are hiring
69
+ """)
70
+
71
+ openaikey = gr.Text(
72
+ label='Your OpenAI Api Key', value="")
73
+ position = gr.Text(
74
+ label='Position/Designation for which you are hiring for', value="")
75
+
76
+ with gr.Tab('File Upload'):
77
+ uploaded_files = gr.File(
78
+ label="Resume Upload - ONLY PDF. (Doc File Support Coming Soon)", file_count="multiple", show_progress=True)
79
+
80
+ uploaded_files.change(
81
+ fn=run, inputs=[uploaded_files], outputs=[uploaded_files])
82
+ ask = gr.Button("Find Top Candidate")
83
+ answer = gr.Markdown(label="Result", elem_classes='answerText')
84
+ ask.click(fn=createAnswer, inputs=[
85
+ uploaded_files, position, openaikey], outputs=[answer])
86
+
87
+ demo.queue(concurrency_count=20)
88
+ demo.launch(show_error=True)
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.31.0
2
+ langchain==0.0.171
3
+ openai==0.27.4
4
+ paper_qa==1.4.0