Spaces:
Runtime error
Runtime error
gkrthk
commited on
Commit
·
6acc7d5
1
Parent(s):
14a65ab
fix error
Browse files- app.py +2 -2
- confluence_qa.py +9 -4
app.py
CHANGED
@@ -19,8 +19,8 @@ if "confluence_qa" not in st.session_state:
|
|
19 |
|
20 |
@st.cache_resource
|
21 |
def load_confluence(config):
|
22 |
-
|
23 |
-
confluence_qa = ConfluenceQA(config
|
24 |
confluence_qa.init_embeddings()
|
25 |
confluence_qa.define_model()
|
26 |
confluence_qa.store_in_vector_db()
|
|
|
19 |
|
20 |
@st.cache_resource
|
21 |
def load_confluence(config):
|
22 |
+
st.write("loading the confluence page")
|
23 |
+
confluence_qa = ConfluenceQA(config)
|
24 |
confluence_qa.init_embeddings()
|
25 |
confluence_qa.define_model()
|
26 |
confluence_qa.store_in_vector_db()
|
confluence_qa.py
CHANGED
@@ -18,11 +18,16 @@ class ConfluenceQA:
|
|
18 |
self.llm = HuggingFacePipeline(pipeline = pipe,model_kwargs={"temperature": 0, "max_length": 1024},)
|
19 |
|
20 |
def store_in_vector_db(self) -> None:
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
loader = ConfluenceLoader(
|
23 |
-
url=
|
24 |
)
|
25 |
-
documents = loader.load(include_attachments=
|
26 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=150)
|
27 |
documents = text_splitter.split_documents(documents)
|
28 |
# text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=10) # This the encoding for text-embedding-ada-002
|
@@ -40,7 +45,7 @@ class ConfluenceQA:
|
|
40 |
chain_type_kwargs = {"prompt": QA_CHAIN_PROMPT}
|
41 |
self.qa = RetrievalQA.from_chain_type(llm=self.llm, chain_type="stuff", retriever=self.db.as_retriever(), chain_type_kwargs=chain_type_kwargs)
|
42 |
|
43 |
-
def __init__(self,config) -> None:
|
44 |
self.db=None
|
45 |
self.embeddings=None
|
46 |
self.llm=None
|
|
|
18 |
self.llm = HuggingFacePipeline(pipeline = pipe,model_kwargs={"temperature": 0, "max_length": 1024},)
|
19 |
|
20 |
def store_in_vector_db(self) -> None:
|
21 |
+
persist_directory = self.config.get("persist_directory",None)
|
22 |
+
confluence_url = self.config.get("confluence_url",None)
|
23 |
+
username = self.config.get("username",None)
|
24 |
+
api_key = self.config.get("api_key",None)
|
25 |
+
space_key = self.config.get("space_key",None)
|
26 |
+
include_attachment = self.config.get("include_attachment", False)
|
27 |
loader = ConfluenceLoader(
|
28 |
+
url=confluence_url, username=username, api_key=api_key
|
29 |
)
|
30 |
+
documents = loader.load(include_attachments=include_attachment, limit=50, space_key=space_key)
|
31 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=150)
|
32 |
documents = text_splitter.split_documents(documents)
|
33 |
# text_splitter = TokenTextSplitter(chunk_size=1000, chunk_overlap=10) # This the encoding for text-embedding-ada-002
|
|
|
45 |
chain_type_kwargs = {"prompt": QA_CHAIN_PROMPT}
|
46 |
self.qa = RetrievalQA.from_chain_type(llm=self.llm, chain_type="stuff", retriever=self.db.as_retriever(), chain_type_kwargs=chain_type_kwargs)
|
47 |
|
48 |
+
def __init__(self,config:dict = {}) -> None:
|
49 |
self.db=None
|
50 |
self.embeddings=None
|
51 |
self.llm=None
|