nickmuchi commited on
Commit
9cadbe9
1 Parent(s): f17d3de

Update variables.py

Browse files
Files changed (1) hide show
  1. variables.py +11 -3
variables.py CHANGED
@@ -72,8 +72,8 @@ def process_tweets(df,df_users):
72
  return df_tweets
73
 
74
  @st.experimental_singleton(suppress_st_warning=True)
75
- def embed_tweets(file,model,query,_prompt):
76
- '''Process file with latest tweets'''
77
 
78
  # Split tweets int chunks
79
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50)
@@ -90,6 +90,14 @@ def embed_tweets(file,model,query,_prompt):
90
 
91
  docsearch = FAISS.from_texts(texts, emb)
92
 
 
 
 
 
 
 
 
 
93
  chain_type_kwargs = {"prompt": _prompt}
94
  chain = VectorDBQA.from_chain_type(
95
  ChatOpenAI(temperature=0),
@@ -97,7 +105,7 @@ def embed_tweets(file,model,query,_prompt):
97
  vectorstore=docsearch,
98
  chain_type_kwargs=chain_type_kwargs,
99
  return_source_documents=True,
100
- k=5
101
  )
102
 
103
  result = chain({"query": query})
 
72
  return df_tweets
73
 
74
  @st.experimental_singleton(suppress_st_warning=True)
75
+ def create_vectorstore(file,model):
76
+ '''Create FAISS vectorstore'''
77
 
78
  # Split tweets int chunks
79
  text_splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50)
 
90
 
91
  docsearch = FAISS.from_texts(texts, emb)
92
 
93
+ return docsearch
94
+
95
+
96
+ @st.experimental_singleton(suppress_st_warning=True)
97
+ def embed_tweets(query,_prompt):
98
+ '''Process file with latest tweets'''
99
+
100
+
101
  chain_type_kwargs = {"prompt": _prompt}
102
  chain = VectorDBQA.from_chain_type(
103
  ChatOpenAI(temperature=0),
 
105
  vectorstore=docsearch,
106
  chain_type_kwargs=chain_type_kwargs,
107
  return_source_documents=True,
108
+ k=3
109
  )
110
 
111
  result = chain({"query": query})