Resume-ChatBot / chatbot.py
atef123's picture
Update chatbot.py
a0668db verified
Raw History Blame Contribute Delete
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)