gabrielaltay commited on
Commit
23a84f2
1 Parent(s): 52cb861

pinecone test

Browse files
Files changed (2) hide show
  1. app.py +41 -15
  2. requirements.txt +14 -0
app.py CHANGED
@@ -1,21 +1,47 @@
 
1
  from langchain_openai import ChatOpenAI
2
- from langchain_core.messages import HumanMessage, SystemMessage
3
-
4
  import streamlit as st
5
 
6
  st.set_page_config(layout="wide", page_title="LegisQA")
7
 
8
- st.write("hello")
9
- llm = ChatOpenAI(
10
- openai_api_key=st.secrets["openai_api_key"]
11
- )
12
-
13
- messages = [
14
- SystemMessage(
15
- content="You are a helpful assistant that translates English to French."
16
- ),
17
- HumanMessage(
18
- content="Translate this sentence from English to French. I love programming."
19
- ),
 
 
 
20
  ]
21
- st.write(llm.invoke(messages))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.vectorstores import Pinecone
2
  from langchain_openai import ChatOpenAI
3
+ from pinecone import Pinecone as PineconeClient
 
4
  import streamlit as st
5
 
6
  st.set_page_config(layout="wide", page_title="LegisQA")
7
 
8
+
9
+ CONGRESS_GOV_TYPE_MAP = {
10
+ "hconres": "house-concurrent-resolution",
11
+ "hjres": "house-joint-resolution",
12
+ "hr": "house-bill",
13
+ "hres": "house-resolution",
14
+ "s": "senate-bill",
15
+ "sconres": "senate-concurrent-resolution",
16
+ "sjres": "senate-joint-resolution",
17
+ "sres": "senate-resolution",
18
+ }
19
+
20
+ OPENAI_CHAT_MODELS = [
21
+ "gpt-3.5-turbo-0125",
22
+ "gpt-4-0125-preview",
23
  ]
24
+
25
+
26
+ def load_pinecone_vectorstore():
27
+ model_name = "BAAI/bge-small-en-v1.5"
28
+ model_kwargs = {"device": "cpu"}
29
+ encode_kwargs = {"normalize_embeddings": True}
30
+ emb_fn = HuggingFaceBgeEmbeddings(
31
+ model_name=model_name,
32
+ model_kwargs=model_kwargs,
33
+ encode_kwargs=encode_kwargs,
34
+ query_instruction="Represent this question for searching relevant passages: ",
35
+ )
36
+ pinecone = PineconeClient(api_key=st.secrets["pinecone_api_key"])
37
+ vectorstore = Pinecone.from_existing_index(
38
+ index_name=st.secrets["pinecone_index_name"],
39
+ embedding=emb_fn,
40
+ )
41
+ return vectorstore
42
+
43
+
44
+
45
+
46
+ docs = vectorstore.similarity_search_with_score("artificial intelligence")
47
+ st.write(docs)
requirements.txt CHANGED
@@ -1,30 +1,44 @@
 
 
1
  annotated-types==0.6.0
2
  anyio==4.3.0
 
 
3
  certifi==2024.2.2
4
  charset-normalizer==3.3.2
 
5
  distro==1.9.0
6
  exceptiongroup==1.2.0
 
7
  h11==0.14.0
8
  httpcore==1.0.4
9
  httpx==0.27.0
10
  idna==3.6
11
  jsonpatch==1.33
12
  jsonpointer==2.4
 
13
  langchain-core==0.1.26
14
  langchain-openai==0.0.7
15
  langsmith==0.1.7
 
 
 
16
  numpy==1.26.4
17
  openai==1.12.0
18
  orjson==3.9.15
19
  packaging==23.2
 
20
  pydantic==2.6.2
21
  pydantic_core==2.16.3
22
  PyYAML==6.0.1
23
  regex==2023.12.25
24
  requests==2.31.0
25
  sniffio==1.3.0
 
26
  tenacity==8.2.3
27
  tiktoken==0.6.0
28
  tqdm==4.66.2
 
29
  typing_extensions==4.9.0
30
  urllib3==2.2.1
 
 
1
+ aiohttp==3.9.3
2
+ aiosignal==1.3.1
3
  annotated-types==0.6.0
4
  anyio==4.3.0
5
+ async-timeout==4.0.3
6
+ attrs==23.2.0
7
  certifi==2024.2.2
8
  charset-normalizer==3.3.2
9
+ dataclasses-json==0.6.4
10
  distro==1.9.0
11
  exceptiongroup==1.2.0
12
+ frozenlist==1.4.1
13
  h11==0.14.0
14
  httpcore==1.0.4
15
  httpx==0.27.0
16
  idna==3.6
17
  jsonpatch==1.33
18
  jsonpointer==2.4
19
+ langchain-community==0.0.24
20
  langchain-core==0.1.26
21
  langchain-openai==0.0.7
22
  langsmith==0.1.7
23
+ marshmallow==3.20.2
24
+ multidict==6.0.5
25
+ mypy-extensions==1.0.0
26
  numpy==1.26.4
27
  openai==1.12.0
28
  orjson==3.9.15
29
  packaging==23.2
30
+ pinecone-client==3.1.0
31
  pydantic==2.6.2
32
  pydantic_core==2.16.3
33
  PyYAML==6.0.1
34
  regex==2023.12.25
35
  requests==2.31.0
36
  sniffio==1.3.0
37
+ SQLAlchemy==2.0.27
38
  tenacity==8.2.3
39
  tiktoken==0.6.0
40
  tqdm==4.66.2
41
+ typing-inspect==0.9.0
42
  typing_extensions==4.9.0
43
  urllib3==2.2.1
44
+ yarl==1.9.4