File size: 700 Bytes
6d38d15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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