Spaces:
Runtime error
Runtime error
File size: 876 Bytes
e1eb124 076a4b4 e1eb124 969b885 a0668db f49731d e1eb124 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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) |