Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…. Chroma to FAISS
  • Loading branch information
Lin-jun-xiang committed Aug 23, 2023
1 parent 709163c commit d47cb9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import langchain
import streamlit as st
from langchain.cache import InMemoryCache
from streamlit import logger
from streamlit_chat import message

from agent import AgentHelper
Expand All @@ -22,11 +23,11 @@

st.session_state.openai_api_key = None
st.session_state.serpapi_api_key = None
app_logger = logger.get_logger(__name__)


def theme():
st.set_page_config(page_title="DocGPT")

icon, title = st.columns([3, 20])
with icon:
st.image('./img/chatbot.png')
Expand All @@ -39,7 +40,6 @@ def theme():

def load_api_key() -> None:
with st.sidebar:

if st.session_state.openai_api_key:
OPENAI_API_KEY = st.session_state.openai_api_key
st.sidebar.success('API key loaded form previous input')
Expand Down Expand Up @@ -101,12 +101,12 @@ def load_api_key() -> None:
llm_tool = agent_.create_llm_chain()

except Exception as e:
print(e)
app_logger.info(e)

try:
search_tool = agent_.get_searp_chain
except Exception as e:
print(e)
app_logger.info(e)

try:
tools = [
Expand All @@ -117,7 +117,7 @@ def load_api_key() -> None:
]
agent_.initialize(tools)
except Exception as e:
pass
app_logger.info(e)


if not st.session_state['openai_api_key']:
Expand All @@ -142,7 +142,7 @@ def get_response(query: str):
response = agent_.query(query)
return response
except Exception as e:
print(e)
app_logger.info(e)

query = st.text_input(
"#### Question:",
Expand Down
4 changes: 2 additions & 2 deletions docGPT/docGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.memory import ConversationBufferMemory
from langchain.prompts import PromptTemplate
from langchain.vectorstores import Chroma
from langchain.vectorstores import FAISS

openai.api_key = os.getenv('OPENAI_API_KEY')

Expand Down Expand Up @@ -116,7 +116,7 @@ def _helper_prompt(self, chain_type: str) -> None:
def _embeddings(self):
embeddings = OpenAIEmbeddings()

db = Chroma.from_documents(
db = FAISS.from_documents(
documents=self.docs,
embedding= embeddings
)
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
langchain==0.0.228
langchain==0.0.218
openai==0.27.8
streamlit==1.24.1
streamlit==1.22.0
streamlit_chat==0.1.1
pymupdf==1.22.5
chromadb==0.3.26
faiss-cpu==1.7.4
tiktoken==0.4.0
google-search-results==2.4.2

0 comments on commit d47cb9b

Please sign in to comment.