Spaces:
Runtime error
Runtime error
Update app.py
Browse files9 unmodified lines101112131415161718192021222324252627282930313233343541 unmodified lines7778798081828384858687888990913 unmodified lines95969798991001011021031041051061071081091101111121131141154 unmodified lines1201211221231241251269 unmodified linesfrom huggingface_hub import hf_hub_downloadfrom llama_cpp import Llamamodel_name = "Meta-Llama-3-70B-Instruct-Q3_K_M.gguf"# hf_hub_download(# repo_id="QuantFactory/Meta-Llama-3-8B-Instruct-GGUF",# filename="Meta-Llama-3-8B-Instruct.Q8_0.gguf",# local_dir = "./models"# )hf_hub_download(repo_id="bartowski/Meta-Llama-3-70B-Instruct-GGUF",filename=model_name,local_dir = "./models")# hf_hub_download(# repo_id="leafspark/Meta-Llama-3.1-405B-Instruct-GGUF",# filename="Llama-3.1-405B-Instruct.Q2_K.gguf",# local_dir = "./models"# )def process_document(pdf_path):extracted_pages = extract_pages(pdf_path)page2content = {}41 unmodified lineshtml_content += "</body></html>"return html_contentdef craft_cv(llm, cv_text, prompt, maxtokens, temperature, top_probability):task = 'Please modify the CV text according the following job description: 'output = llm.create_chat_completion(messages=[{"role": "assistant", "content": task + prompt},{"role": "user","content": cv_text}],max_tokens=maxtokens,temperature=temperature3 unmodified linesreturn cv_text, output@spaces.GPU(duration=150)def pdf_to_text(cv_file, prompt, maxtokens=2048, temperature=0, top_probability=0.95):page2content = process_document(cv_file)cv_text = ""for page_id in page2content:cv_text += page2content[page_id] + ' '# llm = Llama(# model_path="models/" + model_name,# flash_attn=True,# n_gpu_layers=81,# n_batch=1024,# n_ctx=8192,# )# cv_text, crafted_cv = craft_cv(llm, cv_text, prompt, maxtokens, temperature, top_probability)crafted_cv = ''return cv_text, crafted_cvtemp_slider = gr.Slider(minimum=0, maximum=2, value=0.9, label="Temperature Value")prob_slider = gr.Slider(minimum=0, maximum=1, value=0.95, label="Max Probability Value")4 unmodified linesiface = gr.Interface(fn=pdf_to_text,inputs=[cv_file, prompt_text],outputs=['text', 'text'],title='Craft CV',description="This application assists to customize CV based on input job description",theme=gr.themes.Soft(),9 unmodified lines1011121314151617181920212223242541 unmodified lines67686970717273747576773 unmodified lines818283848586878889909192939495969798991004 unmodified lines1051061071081091101119 unmodified linesfrom huggingface_hub import hf_hub_downloadfrom llama_cpp import Llamarepo_id = "srijaydeshpande/CVCRaft"model_id = "cvcraft.gguf"hf_hub_download(repo_id=repo_id,filename=model_id,local_dir = "./models")def process_document(pdf_path):extracted_pages = extract_pages(pdf_path)page2content = {}41 unmodified lineshtml_content += "</body></html>"return html_contentdef craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability):instruction = "Given input CV and job description. Please revise the CV according to the given job description and output the revised CV."output = llm.create_chat_completion(messages=[{"from": "user", "value": instruction + ' Input CV: ' + cv_text + ' , Job Description: ' + job_description},],max_tokens=maxtokens,temperature=temperature3 unmodified linesreturn cv_text, output@spaces.GPU(duration=150)def pdf_to_text(cv_file, job_description, maxtokens=2048, temperature=0, top_probability=0.95):page2content = process_document(cv_file)cv_text = ""for page_id in page2content:cv_text += page2content[page_id] + ' 'llm = Llama(model_path="models/" + model_id,flash_attn=True,n_gpu_layers=81,n_batch=1024,n_ctx=8192,)cv_text, crafted_cv = craft_cv(llm, cv_text, job_description, maxtokens, temperature, top_probability)return crafted_cvtemp_slider = gr.Slider(minimum=0, maximum=2, value=0.9, label="Temperature Value")prob_slider = gr.Slider(minimum=0, maximum=1, value=0.95, label="Max Probability Value")4 unmodified linesiface = gr.Interface(fn=pdf_to_text,inputs=[cv_file, prompt_text],outputs=['text'],title='Craft CV',description="This application assists to customize CV based on input job description",theme=gr.themes.Soft(),
app.py+18-33