Johnny commited on
Commit
30b3b49
·
1 Parent(s): c3f85c5

added app.py, gitignore

Browse files
Files changed (2) hide show
  1. .gitignore +22 -0
  2. app.py +33 -0
.gitignore ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignore all .log files
2
+ *.log
3
+
4
+ # Ignore the node_modules directory
5
+ node_modules/
6
+
7
+ # Ignore specific file
8
+ config/secrets.yml
9
+
10
+ # Ignore all `.env` files
11
+ .env
12
+ myenv/
13
+ venv/
14
+
15
+ # Ignore all `.txt` files in any directory
16
+ **/*.txt
17
+
18
+ # Ignore all files in a specific folder
19
+ build/
20
+
21
+ # Do not ignore a specific file inside an ignored directory
22
+ !build/keep-me.txt
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import redis
4
+ import psycopg2
5
+
6
+ # Redis Connection
7
+ redis_client = redis.Redis(host='redis-19703.c289.us-west-1-2.ec2.redns.redis-cloud.com', port=19703, db=0, decode_responses=True)
8
+
9
+ # PostgreSQL Connection
10
+ conn = psycopg2.connect(database="screening_db", user="user", password="password", host="localhost", port="5432")
11
+ cursor = conn.cursor()
12
+
13
+ HF_API_URL = "https://api-inference.huggingface.co/models/your-hf-model-id"
14
+
15
+ st.title("AI Candidate Screening")
16
+
17
+ resume_text = st.text_area("Paste Candidate Resume")
18
+
19
+ if st.button("Analyze Resume"):
20
+ cache_key = f"resume:{resume_text[:20]}" # Hash first 20 chars
21
+ cached_response = redis_client.get(cache_key)
22
+
23
+ if cached_response:
24
+ st.write("Cached Response:", cached_response)
25
+ else:
26
+ response = requests.post(HF_API_URL, json={"inputs": resume_text}).json()
27
+ redis_client.set(cache_key, response, ex=3600) # Cache for 1 hour
28
+
29
+ # Store result in PostgreSQL
30
+ cursor.execute("INSERT INTO screenings (resume_text, result) VALUES (%s, %s)", (resume_text, response))
31
+ conn.commit()
32
+
33
+ st.write("AI Response:", response)