from langchain_community.vectorstores import Pinecone from langchain_openai import ChatOpenAI from pinecone import Pinecone as PineconeClient import streamlit as st st.set_page_config(layout="wide", page_title="LegisQA") CONGRESS_GOV_TYPE_MAP = { "hconres": "house-concurrent-resolution", "hjres": "house-joint-resolution", "hr": "house-bill", "hres": "house-resolution", "s": "senate-bill", "sconres": "senate-concurrent-resolution", "sjres": "senate-joint-resolution", "sres": "senate-resolution", } OPENAI_CHAT_MODELS = [ "gpt-3.5-turbo-0125", "gpt-4-0125-preview", ] def load_pinecone_vectorstore(): model_name = "BAAI/bge-small-en-v1.5" model_kwargs = {"device": "cpu"} encode_kwargs = {"normalize_embeddings": True} emb_fn = HuggingFaceBgeEmbeddings( model_name=model_name, model_kwargs=model_kwargs, encode_kwargs=encode_kwargs, query_instruction="Represent this question for searching relevant passages: ", ) pinecone = PineconeClient(api_key=st.secrets["pinecone_api_key"]) vectorstore = Pinecone.from_existing_index( index_name=st.secrets["pinecone_index_name"], embedding=emb_fn, ) return vectorstore docs = vectorstore.similarity_search_with_score("artificial intelligence") st.write(docs)