Spaces:
Sleeping
Sleeping
improvements to sync strat
Browse files
app.py
CHANGED
@@ -10,7 +10,7 @@ import arxiv
|
|
10 |
import pinecone
|
11 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
12 |
from langchain.embeddings import CacheBackedEmbeddings
|
13 |
-
from langchain.storage import LocalFileStore
|
14 |
from utils.store import index_documents, search_and_index
|
15 |
from utils.chain import create_chain
|
16 |
from langchain.vectorstores import Pinecone
|
@@ -46,7 +46,7 @@ async def start_chat():
|
|
46 |
).send()
|
47 |
|
48 |
# create an embedder through a cache interface (locally) (on start)
|
49 |
-
store =
|
50 |
|
51 |
core_embeddings_model = OpenAIEmbeddings(
|
52 |
api_key=os.environ['OPENAI_API_KEY']
|
@@ -85,6 +85,7 @@ async def start_chat():
|
|
85 |
langchain.llm_cache = InMemoryCache()
|
86 |
|
87 |
# log data in WaB (on start)
|
|
|
88 |
os.environ["LANGCHAIN_WANDB_TRACING"] = "true"
|
89 |
|
90 |
# setup memory
|
@@ -101,7 +102,7 @@ async def start_chat():
|
|
101 |
cl.user_session.set("settings", settings)
|
102 |
cl.user_session.set("first_run", False)
|
103 |
|
104 |
-
|
105 |
@cl.on_message # marks a function that should be run each time the chatbot receives a message from a user
|
106 |
async def main(message: cl.Message):
|
107 |
settings = cl.user_session.get("settings")
|
|
|
10 |
import pinecone
|
11 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
12 |
from langchain.embeddings import CacheBackedEmbeddings
|
13 |
+
from langchain.storage import LocalFileStore, InMemoryStore
|
14 |
from utils.store import index_documents, search_and_index
|
15 |
from utils.chain import create_chain
|
16 |
from langchain.vectorstores import Pinecone
|
|
|
46 |
).send()
|
47 |
|
48 |
# create an embedder through a cache interface (locally) (on start)
|
49 |
+
store = InMemoryStore()
|
50 |
|
51 |
core_embeddings_model = OpenAIEmbeddings(
|
52 |
api_key=os.environ['OPENAI_API_KEY']
|
|
|
85 |
langchain.llm_cache = InMemoryCache()
|
86 |
|
87 |
# log data in WaB (on start)
|
88 |
+
os.environ["WANDB_MODE"] = "disabled"
|
89 |
os.environ["LANGCHAIN_WANDB_TRACING"] = "true"
|
90 |
|
91 |
# setup memory
|
|
|
102 |
cl.user_session.set("settings", settings)
|
103 |
cl.user_session.set("first_run", False)
|
104 |
|
105 |
+
@cl.on_settings_update
|
106 |
@cl.on_message # marks a function that should be run each time the chatbot receives a message from a user
|
107 |
async def main(message: cl.Message):
|
108 |
settings = cl.user_session.get("settings")
|