Update app.py
Browse files
app.py
CHANGED
@@ -2,25 +2,25 @@ import openai
|
|
2 |
import os
|
3 |
from paperqa import Docs
|
4 |
import gradio as gr
|
5 |
-
from
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
css_style = """
|
14 |
.gradio-container {
|
15 |
font-family: "IBM Plex Mono";
|
16 |
}
|
17 |
-
|
18 |
.answerText p {
|
19 |
font-size: 24px !important;
|
20 |
color: #8dbcfe !important;
|
21 |
}
|
22 |
"""
|
23 |
|
|
|
24 |
def run(uploaded_files):
|
25 |
all_files = []
|
26 |
if uploaded_files is None:
|
@@ -31,53 +31,48 @@ def run(uploaded_files):
|
|
31 |
print(all_files)
|
32 |
return all_files
|
33 |
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
45 |
|
46 |
with gr.Blocks(css=css_style) as demo:
|
47 |
gr.Markdown(f"""
|
48 |
# HR-GPT - Filter & Find The Best Candidate for the Job using AI
|
49 |
-
|
50 |
*By Amin Memon ([@AminMemon](https://twitter.com/AminMemon))*
|
51 |
-
|
52 |
This tool will enable asking questions of your uploaded text, PDF documents,.
|
53 |
It uses OpenAI's ChatGPT model & OpenAI Embeddings and thus you must enter your API key below.
|
54 |
-
|
55 |
This tool is under active development and currently uses many tokens - up to 10,000
|
56 |
for a single query. That is $0.10-0.20 per query, so please be careful!
|
57 |
Porting it to Llama.cpp soon for saved cost.
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
""")
|
62 |
|
63 |
-
|
|
|
|
|
|
|
64 |
|
65 |
with gr.Tab('File Upload'):
|
66 |
-
uploaded_files = gr.File(
|
|
|
67 |
|
68 |
-
uploaded_files.change(
|
|
|
69 |
ask = gr.Button("Find Top Candidate")
|
70 |
-
answer = gr.Markdown(label="Result",
|
71 |
-
|
72 |
-
|
73 |
-
def on_ask_click():
|
74 |
-
loading_indicator.update(visible=True, value="Processing...")
|
75 |
-
|
76 |
-
ask.click(fn=on_ask_click, inputs=[], outputs=[loading_indicator]).then(
|
77 |
-
fn=createAnswer, inputs=[uploaded_files, position], outputs=[answer]
|
78 |
-
).then(
|
79 |
-
fn=lambda: gr.Markdown.update(visible=False), inputs=[], outputs=[loading_indicator]
|
80 |
-
)
|
81 |
|
82 |
demo.queue(concurrency_count=20)
|
83 |
-
demo.launch(show_error=True)
|
|
|
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 |
.gradio-container {
|
15 |
font-family: "IBM Plex Mono";
|
16 |
}
|
|
|
17 |
.answerText p {
|
18 |
font-size: 24px !important;
|
19 |
color: #8dbcfe !important;
|
20 |
}
|
21 |
"""
|
22 |
|
23 |
+
|
24 |
def run(uploaded_files):
|
25 |
all_files = []
|
26 |
if uploaded_files is None:
|
|
|
31 |
print(all_files)
|
32 |
return all_files
|
33 |
|
34 |
+
|
35 |
+
def createAnswer(files, designation, openaikey):
|
36 |
+
os.environ['OPENAI_API_KEY'] = openaikey.strip()
|
37 |
+
docs = Docs(llm='gpt-3.5-turbo')
|
38 |
+
for d in files:
|
39 |
+
docs.add(d.name)
|
40 |
+
answer = docs.query(
|
41 |
+
f"Who is the best canidate to hire for {designation}. Provide a list with the candidate name. If you don't know, simply say None of the canidates are suited for the Job role.")
|
42 |
+
print(answer.formatted_answer)
|
43 |
+
print(type(answer))
|
44 |
+
return answer.answer
|
45 |
+
|
46 |
|
47 |
with gr.Blocks(css=css_style) as demo:
|
48 |
gr.Markdown(f"""
|
49 |
# HR-GPT - Filter & Find The Best Candidate for the Job using AI
|
|
|
50 |
*By Amin Memon ([@AminMemon](https://twitter.com/AminMemon))*
|
|
|
51 |
This tool will enable asking questions of your uploaded text, PDF documents,.
|
52 |
It uses OpenAI's ChatGPT model & OpenAI Embeddings and thus you must enter your API key below.
|
|
|
53 |
This tool is under active development and currently uses many tokens - up to 10,000
|
54 |
for a single query. That is $0.10-0.20 per query, so please be careful!
|
55 |
Porting it to Llama.cpp soon for saved cost.
|
56 |
+
1. Enter API Key ([What is that?](https://platform.openai.com/account/api-keys))
|
57 |
+
2. Upload your Resumes (Try a few resumes/cv to try < 5)
|
58 |
+
3. Provide Designation for which you are hiring
|
59 |
""")
|
60 |
|
61 |
+
openaikey = gr.Text(
|
62 |
+
label='Your OpenAI Api Key', value="")
|
63 |
+
position = gr.Text(
|
64 |
+
label='Position/Designation for which you are hiring for', value="")
|
65 |
|
66 |
with gr.Tab('File Upload'):
|
67 |
+
uploaded_files = gr.File(
|
68 |
+
label="Resume Upload - ONLY PDF. (Doc File Support Coming Soon)", file_count="multiple", show_progress=True)
|
69 |
|
70 |
+
uploaded_files.change(
|
71 |
+
fn=run, inputs=[uploaded_files], outputs=[uploaded_files])
|
72 |
ask = gr.Button("Find Top Candidate")
|
73 |
+
answer = gr.Markdown(label="Result", elem_classes='answerText')
|
74 |
+
ask.click(fn=createAnswer, inputs=[
|
75 |
+
uploaded_files, position, openaikey], outputs=[answer])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
demo.queue(concurrency_count=20)
|
78 |
+
demo.launch(show_error=True)
|