Spaces:
Runtime error
Runtime error
Download chatbot.py from atef123/Resume-ChatBot: direct link, hf CLI and curl.
- Browser
- Download file 876 Bytes
-
https://huggingface.co/spaces/atef123/Resume-ChatBot/resolve/main/chatbot.py
- Command line
-
hf download hf://spaces/atef123/Resume-ChatBot/chatbot.py
-
curl -L -o chatbot.py https://huggingface.co/spaces/atef123/Resume-ChatBot/resolve/main/chatbot.py
876 Bytes
| from transformers import pipeline | |
| import time | |
| import os | |
| class Bot: | |
| def __init__(self): | |
| self.task = "question-answering" | |
| # self.model = "deepset/roberta-base-squad2" | |
| self.model = "meta-llama/Meta-Llama-3.1-70B-Instruct" | |
| self.hf_token = os.environ["HF_Token"] | |
| self.reader = pipeline(task=self.task , model=self.model, token=self.hf_token) | |
| # Read the resume text from a file | |
| with open("My CV - Text.txt", "r") as file: | |
| # with open("MY CV QA.txt", "r") as file: | |
| self.content = file.read() | |
| def answer_question(self, question): | |
| outputs = self.reader(question=question, context=self.content) | |
| return outputs['answer'] | |
| def stream_data(self, data): | |
| for word in data.split(" "): | |
| yield word + " " | |
| time.sleep(0.02) |