[email protected]
commited on
Commit
·
43dc934
1
Parent(s):
fc8b475
feat: add user ID handling from query parameters and include in metadata for chain input
Browse files
app.py
CHANGED
@@ -22,6 +22,10 @@ def init_app():
|
|
22 |
pinecone_connector = PineconeConnector()
|
23 |
vs_manager = VectoreStoreManager(pinecone_connector)
|
24 |
|
|
|
|
|
|
|
|
|
25 |
st.session_state["messages"] = []
|
26 |
st.session_state["assistant"] = Rag(vectore_store=vs_manager)
|
27 |
st.session_state["data_dict"] = config['variables']
|
|
|
22 |
pinecone_connector = PineconeConnector()
|
23 |
vs_manager = VectoreStoreManager(pinecone_connector)
|
24 |
|
25 |
+
query_params = st.query_params
|
26 |
+
if "user" in query_params:
|
27 |
+
st.session_state["id_user"] = query_params["user"]
|
28 |
+
|
29 |
st.session_state["messages"] = []
|
30 |
st.session_state["assistant"] = Rag(vectore_store=vs_manager)
|
31 |
st.session_state["data_dict"] = config['variables']
|
rag.py
CHANGED
@@ -11,6 +11,7 @@ from langchain.schema.runnable import RunnablePassthrough
|
|
11 |
from langchain.prompts import PromptTemplate
|
12 |
from langchain_community.vectorstores.utils import filter_complex_metadata
|
13 |
from langchain_community.document_loaders.csv_loader import CSVLoader
|
|
|
14 |
|
15 |
from util import getYamlConfig
|
16 |
|
@@ -110,7 +111,12 @@ class Rag:
|
|
110 |
chain_input.update(extra_vars)
|
111 |
|
112 |
|
113 |
-
return self.chain.stream(chain_input
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
def clear(self):
|
116 |
self.document_vector_store = None
|
|
|
11 |
from langchain.prompts import PromptTemplate
|
12 |
from langchain_community.vectorstores.utils import filter_complex_metadata
|
13 |
from langchain_community.document_loaders.csv_loader import CSVLoader
|
14 |
+
import streamlit as st
|
15 |
|
16 |
from util import getYamlConfig
|
17 |
|
|
|
111 |
chain_input.update(extra_vars)
|
112 |
|
113 |
|
114 |
+
return self.chain.stream(chain_input, config={
|
115 |
+
"metadata" : {
|
116 |
+
"id_user": st.session_state.get("id_user", None),
|
117 |
+
"use_case": st.session_state.get("use_case", None)
|
118 |
+
}
|
119 |
+
})
|
120 |
|
121 |
def clear(self):
|
122 |
self.document_vector_store = None
|