Spaces:
Running on Zero
Running on Zero
Commit ·
8eddfe0
1
Parent(s): ba381db
update readme
Browse files
README.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.3.0
|
| 8 |
python_version: "3.12"
|
| 9 |
app_file: app.py
|
|
|
|
| 10 |
pinned: false
|
| 11 |
-
hf_oauth: true
|
| 12 |
-
hf_oauth_scopes:
|
| 13 |
-
- inference-api
|
| 14 |
---
|
| 15 |
|
|
|
|
| 1 |
---
|
| 2 |
+
title: CV Chatbot
|
| 3 |
+
emoji: 📝
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: indigo
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 6.3.0
|
| 8 |
python_version: "3.12"
|
| 9 |
app_file: app.py
|
| 10 |
+
short_description: "RAG Chatbot with knowledge of your CV"
|
| 11 |
pinned: false
|
| 12 |
+
# hf_oauth: true
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import argparse
|
| 2 |
import logging
|
| 3 |
import gradio as gr
|
|
@@ -7,9 +8,13 @@ import spaces
|
|
| 7 |
|
| 8 |
parser = argparse.ArgumentParser("cvchatbot")
|
| 9 |
parser.add_argument("--debug", help="Enable debug logging", action='store_true')
|
|
|
|
| 10 |
parser.add_argument("--generate", dest="generate_cache", help="Generate new cache", action='store_true')
|
| 11 |
parser.add_argument("--download-cv-data", dest="download_cv_data", help="Download CV data from Cloud Storage", action='store_true')
|
| 12 |
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
|
| 15 |
|
|
@@ -54,8 +59,8 @@ def respond(
|
|
| 54 |
|
| 55 |
with gr.Blocks() as demo:
|
| 56 |
# login button
|
| 57 |
-
with gr.Sidebar():
|
| 58 |
-
|
| 59 |
|
| 60 |
# chat context
|
| 61 |
context_state = gr.State(ChatContext())
|
|
|
|
| 1 |
+
import os
|
| 2 |
import argparse
|
| 3 |
import logging
|
| 4 |
import gradio as gr
|
|
|
|
| 8 |
|
| 9 |
parser = argparse.ArgumentParser("cvchatbot")
|
| 10 |
parser.add_argument("--debug", help="Enable debug logging", action='store_true')
|
| 11 |
+
parser.add_argument("--prod", help="Use production environment", action='store_true')
|
| 12 |
parser.add_argument("--generate", dest="generate_cache", help="Generate new cache", action='store_true')
|
| 13 |
parser.add_argument("--download-cv-data", dest="download_cv_data", help="Download CV data from Cloud Storage", action='store_true')
|
| 14 |
args = parser.parse_args()
|
| 15 |
+
if args.prod:
|
| 16 |
+
os.environ["ENV"] = "PROD"
|
| 17 |
+
|
| 18 |
logger = logging.getLogger(__name__)
|
| 19 |
logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
|
| 20 |
|
|
|
|
| 59 |
|
| 60 |
with gr.Blocks() as demo:
|
| 61 |
# login button
|
| 62 |
+
# with gr.Sidebar():
|
| 63 |
+
# gr.LoginButton()
|
| 64 |
|
| 65 |
# chat context
|
| 66 |
context_state = gr.State(ChatContext())
|
config.py
CHANGED
|
@@ -3,11 +3,20 @@ from string import Template
|
|
| 3 |
|
| 4 |
|
| 5 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
EMBEDDING_MODEL_ID = "google/embeddinggemma-300M"
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# cv document data files
|
| 13 |
CV_DATA_GCS_BUCKET = "wlee-jsons"
|
|
@@ -17,7 +26,12 @@ CV_DATA_FILE_JOBS = "jobs.json"
|
|
| 17 |
CV_DATA_FILE_PAPERS = "papers.json"
|
| 18 |
CV_DATA_FILE_SKILLS = "skills.json"
|
| 19 |
RESET_QUERY = "restart chat"
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
"To start, tell me which one of the following domains you would like to focus on:\n"
|
| 22 |
"$domains\n"
|
| 23 |
f"At any point in chat, say \'{RESET_QUERY}\' to reset chat and return to current state.")
|
|
@@ -26,29 +40,10 @@ EDUCATION_DESCRIPTION = "Academic degrees and relevant coursework"
|
|
| 26 |
JOBS_DESCRIPTION = "Work experience"
|
| 27 |
PAPERS_DESCRIPTION = "Papers and publications"
|
| 28 |
SKILLS_DESCRIPTION = "Technical skills, such as programming language, framework, and tools"
|
| 29 |
-
|
| 30 |
-
# cache files
|
| 31 |
-
KNOWLEDGE_CACHE_FILE = "knowledge.pkl"
|
| 32 |
-
|
| 33 |
-
# embedding parameters
|
| 34 |
-
DOMAIN_SELECTION_THRESHOLD = 0.5
|
| 35 |
-
DOCUMENT_SELECTION_THRESHOLD = 0.2
|
| 36 |
-
DOCUMENT_FOLLOWUP_THRESHOLD = 0.5
|
| 37 |
-
|
| 38 |
-
# generation parameters
|
| 39 |
-
RESPONSE_MAX_NEW_TOKENS = 512
|
| 40 |
-
RESPONSE_SAMPLING_TOP_P = 0.95
|
| 41 |
-
RESPONSE_SAMPLING_TEMPERATURE = 0.7
|
| 42 |
-
|
| 43 |
-
# helper configs
|
| 44 |
-
SKILL_COMPETENCY_LEVELS = {
|
| 45 |
-
5: "Expert",
|
| 46 |
-
4: "Proficient",
|
| 47 |
-
3: "Competent",
|
| 48 |
-
2: "Advanced Beginner",
|
| 49 |
-
1: "Novice",
|
| 50 |
-
}
|
| 51 |
JOB_TYPES = [
|
| 52 |
"Software Engineer",
|
| 53 |
"Research Intern",
|
| 54 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
|
| 5 |
HF_TOKEN = os.getenv('HF_TOKEN')
|
| 6 |
+
|
| 7 |
+
# model configs
|
| 8 |
+
LLM_ID = "google/gemma-3-4b-it" if os.getenv("ENV") == "PROD" else "google/gemma-3-1b-it"
|
| 9 |
EMBEDDING_MODEL_ID = "google/embeddinggemma-300M"
|
| 10 |
+
|
| 11 |
+
# embedding parameters
|
| 12 |
+
DOMAIN_SELECTION_THRESHOLD = 0.5
|
| 13 |
+
DOCUMENT_SELECTION_THRESHOLD = 0.2
|
| 14 |
+
DOCUMENT_FOLLOWUP_THRESHOLD = 0.5
|
| 15 |
+
|
| 16 |
+
# generation parameters
|
| 17 |
+
RESPONSE_MAX_NEW_TOKENS = 512
|
| 18 |
+
RESPONSE_SAMPLING_TOP_P = 0.95
|
| 19 |
+
RESPONSE_SAMPLING_TEMPERATURE = 0.7
|
| 20 |
|
| 21 |
# cv document data files
|
| 22 |
CV_DATA_GCS_BUCKET = "wlee-jsons"
|
|
|
|
| 26 |
CV_DATA_FILE_PAPERS = "papers.json"
|
| 27 |
CV_DATA_FILE_SKILLS = "skills.json"
|
| 28 |
RESET_QUERY = "restart chat"
|
| 29 |
+
|
| 30 |
+
# text configs
|
| 31 |
+
PERSON_NAME = "William"
|
| 32 |
+
PERSON_PRONOUN = "he"
|
| 33 |
+
PERSON_PRONOUN_POSSESSIVE = "his"
|
| 34 |
+
WELCOME_MESSAGE_TEMPLATE = Template(f"Hi! I'm {PERSON_NAME}'s Career Assistant. I can answer questions you might have regarding {PERSON_PRONOUN_POSSESSIVE} resume. "
|
| 35 |
"To start, tell me which one of the following domains you would like to focus on:\n"
|
| 36 |
"$domains\n"
|
| 37 |
f"At any point in chat, say \'{RESET_QUERY}\' to reset chat and return to current state.")
|
|
|
|
| 40 |
JOBS_DESCRIPTION = "Work experience"
|
| 41 |
PAPERS_DESCRIPTION = "Papers and publications"
|
| 42 |
SKILLS_DESCRIPTION = "Technical skills, such as programming language, framework, and tools"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
JOB_TYPES = [
|
| 44 |
"Software Engineer",
|
| 45 |
"Research Intern",
|
| 46 |
+
]
|
| 47 |
+
|
| 48 |
+
# cache files
|
| 49 |
+
KNOWLEDGE_CACHE_FILE = "knowledge.pkl"
|
helpers.py
CHANGED
|
@@ -4,8 +4,7 @@ import json
|
|
| 4 |
from typing import Tuple
|
| 5 |
from google.cloud.storage import Client, transfer_manager
|
| 6 |
|
| 7 |
-
from config import JOB_TYPES, PERSON_NAME, PERSON_PRONOUN, RESET_QUERY,
|
| 8 |
-
CV_DATA_DIRNAME, CV_DATA_GCS_BUCKET
|
| 9 |
|
| 10 |
|
| 11 |
def download_cv_data() -> None:
|
|
|
|
| 4 |
from typing import Tuple
|
| 5 |
from google.cloud.storage import Client, transfer_manager
|
| 6 |
|
| 7 |
+
from config import JOB_TYPES, PERSON_NAME, PERSON_PRONOUN, RESET_QUERY, CV_DATA_DIRNAME, CV_DATA_GCS_BUCKET
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def download_cv_data() -> None:
|