Spaces:
Sleeping
Sleeping
from langchain_community.document_loaders import UnstructuredURLLoader | |
class Data: | |
def __init__(self, url): | |
self.url = url | |
def get_context(self): | |
urls = [ | |
self.url, | |
] | |
loader = UnstructuredURLLoader(urls=urls) | |
data = loader.load() | |
context = data[0].page_content # will come from 'url' | |
return context | |
def build_prompt(self, question): | |
prompt = f""" | |
Use the following piece of context to answer the question asked. | |
Please try to provide the answer only based on the context | |
{self.get_context()} | |
Question:{question} | |
Helpful Answers: | |
""" | |
return prompt | |