moriire commited on
Commit
befa051
1 Parent(s): 97da889

Update app/llm.py

Browse files
Files changed (1) hide show
  1. app/llm.py +17 -9
app/llm.py CHANGED
@@ -17,15 +17,23 @@ from langchain_chroma import Chroma
17
  from langchain_community.embeddings import GPT4AllEmbeddings
18
 
19
 
20
- def agent():
21
- loader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")
22
- data = loader.load()
23
- text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
24
- all_splits = text_splitter.split_documents(data)
25
-
26
-
27
- def download_embedding():
28
- vectorstore =Chroma.from_documents(documents=all_splits, embedding=GPT4AllEmbeddings())
 
 
 
 
 
 
 
 
29
 
30
 
31
 
 
17
  from langchain_community.embeddings import GPT4AllEmbeddings
18
 
19
 
20
+ class RagChat:
21
+ def agent(self):
22
+ loader = WebBaseLoader("https://lilianweng.github.io/posts/2023-06-23-agent/")
23
+ data = loader.load()
24
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=0)
25
+ all_splits = text_splitter.split_documents(data)
26
+ return all_splits
27
+
28
+ def download_embedding(self):
29
+ vectorstore = Chroma.from_documents(documents=self.agent, embedding=GPT4AllEmbeddings())
30
+ return vectorstore
31
+
32
+ def search(self, question):
33
+ docs = vectorstore.similarity_search(question)
34
+ return len(docs)
35
+
36
+
37
 
38
 
39