aridepai17 commited on
Commit
bf29456
Β·
verified Β·
1 Parent(s): eb83ff3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -17
app.py CHANGED
@@ -6,7 +6,6 @@ from llama_index.core import VectorStoreIndex
6
  from llama_index.embeddings.openai import OpenAIEmbedding
7
  from llama_index.llms.openai import OpenAI
8
 
9
- # Load OpenAI API Key
10
  openai.api_key = os.environ.get("OPENAI_API_KEY")
11
 
12
  def process_pdf(file, question):
@@ -26,27 +25,27 @@ def process_pdf(file, question):
26
  except Exception as e:
27
  return f"❌ Error: {e}"
28
 
29
- # Launch dark-themed UI with Gradio Blocks
30
- with gr.Blocks(theme=gr.themes.Soft(primary_hue="gray", secondary_hue="purple"), css="footer {display:none !important;}") as demo:
31
- gr.HTML("""
32
- <div style="text-align: center; padding: 2rem;">
33
- <h1 style="font-size: 2.4rem; color: #ffffff;">🧠 Resume Insight AI</h1>
34
- <p style="color: #cccccc;">Upload your resume and get instant AI insights powered by OpenAI + LlamaIndex</p>
35
- </div>
36
  """)
37
 
38
- with gr.Box():
39
- with gr.Row():
40
- pdf_file = gr.File(label="πŸ“Ž Upload PDF Resume", file_types=[".pdf"], type="file")
41
- question = gr.Textbox(label="πŸ’¬ Ask a Question", placeholder="e.g., What are my key skills?", lines=1)
42
 
43
- with gr.Row():
44
- submit_btn = gr.Button("πŸ” Analyze Resume", size="lg")
45
 
46
- output = gr.Textbox(label="πŸ“˜ AI Response", lines=10, interactive=False)
47
 
48
- submit_btn.click(fn=process_pdf, inputs=[pdf_file, question], outputs=output)
 
49
 
50
- # Start the app
 
 
51
  if __name__ == "__main__":
52
  demo.launch()
 
6
  from llama_index.embeddings.openai import OpenAIEmbedding
7
  from llama_index.llms.openai import OpenAI
8
 
 
9
  openai.api_key = os.environ.get("OPENAI_API_KEY")
10
 
11
  def process_pdf(file, question):
 
25
  except Exception as e:
26
  return f"❌ Error: {e}"
27
 
28
+ # Gradio Blocks UI
29
+ with gr.Blocks(title="Resume Analyzer by Advaith") as demo:
30
+ gr.Markdown("""
31
+ # πŸ“„ Resume Analyzer
32
+ Upload a resume and ask any question about the candidate!
33
+ Powered by **LlamaIndex** + **OpenAI**
 
34
  """)
35
 
36
+ with gr.Row():
37
+ pdf_file = gr.File(label="πŸ“ Upload your resume (PDF)", file_types=[".pdf"])
38
+ question = gr.Textbox(lines=2, label="πŸ’¬ Ask something", placeholder="e.g., What are the candidate's technical strengths?")
 
39
 
40
+ analyze_button = gr.Button("πŸ” Analyze")
 
41
 
42
+ result = gr.Textbox(label="🧠 Answer", lines=10)
43
 
44
+ def run_analysis(file, question):
45
+ return process_pdf(file, question)
46
 
47
+ analyze_button.click(run_analysis, inputs=[pdf_file, question], outputs=result)
48
+
49
+ # Launch app
50
  if __name__ == "__main__":
51
  demo.launch()