Spaces:
Runtime error
Runtime error
semantic chunker
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@ from aimakerspace.vectordatabase import VectorDatabase
|
|
| 12 |
from aimakerspace.openai_utils.chatmodel import ChatOpenAI
|
| 13 |
import chainlit as cl
|
| 14 |
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
|
|
|
|
|
|
| 15 |
|
| 16 |
system_template = """\
|
| 17 |
Use the following context to answer a users question. If you cannot find the answer in the context, say you don't know the answer."""
|
|
@@ -47,8 +49,8 @@ class RetrievalAugmentedQAPipeline:
|
|
| 47 |
|
| 48 |
return {"response": generate_response(), "context": context_list}
|
| 49 |
|
| 50 |
-
text_splitter = RecursiveCharacterTextSplitter()
|
| 51 |
-
|
| 52 |
|
| 53 |
def process_text_file(file: AskFileResponse):
|
| 54 |
import tempfile
|
|
|
|
| 12 |
from aimakerspace.openai_utils.chatmodel import ChatOpenAI
|
| 13 |
import chainlit as cl
|
| 14 |
from langchain_text_splitters import RecursiveCharacterTextSplitter
|
| 15 |
+
from langchain_experimental.text_splitter import SemanticChunker
|
| 16 |
+
from langchain_openai.embeddings import OpenAIEmbeddings
|
| 17 |
|
| 18 |
system_template = """\
|
| 19 |
Use the following context to answer a users question. If you cannot find the answer in the context, say you don't know the answer."""
|
|
|
|
| 49 |
|
| 50 |
return {"response": generate_response(), "context": context_list}
|
| 51 |
|
| 52 |
+
# text_splitter = RecursiveCharacterTextSplitter()
|
| 53 |
+
text_splitter = SemanticChunker(OpenAIEmbeddings(), breakpoint_threshold_type="standard_deviation")
|
| 54 |
|
| 55 |
def process_text_file(file: AskFileResponse):
|
| 56 |
import tempfile
|