Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -179,7 +179,7 @@ langchain_document_loader()
|
|
179 |
|
180 |
text_splitter = RecursiveCharacterTextSplitter(
|
181 |
separators = ["\n\n", "\n", " ", ""],
|
182 |
-
chunk_size = 1500,
|
183 |
chunk_overlap= 200
|
184 |
)
|
185 |
chunks = text_splitter.split_documents(documents=documents)
|
@@ -470,7 +470,7 @@ def instantiate_LLM(LLM_provider,api_key,temperature=0.8,top_p=0.95,model_name=N
|
|
470 |
|
471 |
|
472 |
|
473 |
-
# This creates history (memory) of prior questions. I am using Gemini for this but I left the code if I decide to go to GPT later on.
|
474 |
|
475 |
def create_memory(model_name='gemini-pro',memory_max_token=None):
|
476 |
#def create_memory(model_name='gpt-3.5-turbo',memory_max_token=None):
|
@@ -497,7 +497,7 @@ def create_memory(model_name='gemini-pro',memory_max_token=None):
|
|
497 |
)
|
498 |
return memory
|
499 |
|
500 |
-
#
|
501 |
|
502 |
memory = create_memory(model_name='gemini-pro',memory_max_token=None)
|
503 |
#memory = create_memory(model_name='gpt-3.5-turbo',memory_max_token=20)
|
|
|
179 |
|
180 |
text_splitter = RecursiveCharacterTextSplitter(
|
181 |
separators = ["\n\n", "\n", " ", ""],
|
182 |
+
chunk_size = 1500, # You could also use recursive, semantic, or document specific chunking techniques -- see https://medium.com/the-ai-forum/semantic-chunking-for-rag-f4733025d5f5
|
183 |
chunk_overlap= 200
|
184 |
)
|
185 |
chunks = text_splitter.split_documents(documents=documents)
|
|
|
470 |
|
471 |
|
472 |
|
473 |
+
# This creates history (memory) of prior questions. The Website UI does this for you, but with API you have to do this on your own. I am using Gemini for this but I left the code if I decide to go to GPT later on.
|
474 |
|
475 |
def create_memory(model_name='gemini-pro',memory_max_token=None):
|
476 |
#def create_memory(model_name='gpt-3.5-turbo',memory_max_token=None):
|
|
|
497 |
)
|
498 |
return memory
|
499 |
|
500 |
+
# You can set a small memory_max_token, just to show how older messages are summarized if max_token_limit is exceeded.
|
501 |
|
502 |
memory = create_memory(model_name='gemini-pro',memory_max_token=None)
|
503 |
#memory = create_memory(model_name='gpt-3.5-turbo',memory_max_token=20)
|