Skip to content

Commit 4cb5760

Browse files
committed
add key in ChatOpenAI
1 parent c3e807e commit 4cb5760

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

__pycache__/chain.cpython-311.pyc

27 Bytes
Binary file not shown.

bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def load_chain(openai_api_key, pinecone_api_key, pinecone_env_key):
1919

2020
db = Pinecone.from_existing_index(index_name, embeddings)
2121

22-
return get_conversation_chain(db)
22+
return get_conversation_chain(db, openai_api_key)
2323

2424
def execute_chain(query, openai_api_key, pinecone_api_key, pinecone_env_key):
2525
chain = load_chain(openai_api_key, pinecone_api_key, pinecone_env_key)
@@ -88,7 +88,7 @@ def main():
8888
with st.spinner("Processing"):
8989
vector_store = create_vector_db()
9090

91-
st.session_state.conversation = get_conversation_chain(vector_store)
91+
st.session_state.conversation = get_conversation_chain(vector_store, st.session_state["OPENAI_API_KEY"])
9292
st.write("Processing Done")
9393

9494
st.title("PDF Bot")

chain.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from langchain.chains import ConversationalRetrievalChain
44
from langchain.prompts.prompt import PromptTemplate
55

6-
def get_conversation_chain(vector_store):
6+
def get_conversation_chain(vector_store, openai_api_key):
77
llm = ChatOpenAI(
8+
openai_api_key=openai_api_key,
89
model="gpt-3.5-turbo",
910
temperature=0.7
1011
)

0 commit comments

Comments
 (0)