Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +3 -3
src/streamlit_app.py
CHANGED
|
@@ -10,7 +10,7 @@ import os
|
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
load_dotenv()
|
| 12 |
|
| 13 |
-
|
| 14 |
|
| 15 |
api_wiki=WikipediaAPIWrapper(top_k_results=3,doc_content_chars_max=250)
|
| 16 |
wiki=WikipediaQueryRun(api_wrapper=api_wiki)
|
|
@@ -23,7 +23,7 @@ search=DuckDuckGoSearchRun(name="Search")
|
|
| 23 |
|
| 24 |
st.title("🔎 LangChain - Chat with search")
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
if "messages" not in st.session_state:
|
| 29 |
st.session_state["messages"]=[
|
|
@@ -37,7 +37,7 @@ if prompt:=st.chat_input(placeholder="What is machine learning?"):
|
|
| 37 |
st.session_state.messages.append({"role":"user","content":prompt})
|
| 38 |
st.chat_message("user").write(prompt)
|
| 39 |
|
| 40 |
-
llm=ChatOpenAI(model="gpt-4o",streaming=True)
|
| 41 |
tools=[search,arxiv,wiki]
|
| 42 |
|
| 43 |
search_agent=initialize_agent(tools,llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,handling_parsing_errors=True)
|
|
|
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
load_dotenv()
|
| 12 |
|
| 13 |
+
|
| 14 |
|
| 15 |
api_wiki=WikipediaAPIWrapper(top_k_results=3,doc_content_chars_max=250)
|
| 16 |
wiki=WikipediaQueryRun(api_wrapper=api_wiki)
|
|
|
|
| 23 |
|
| 24 |
st.title("🔎 LangChain - Chat with search")
|
| 25 |
|
| 26 |
+
api_key = st.text_input("Enter your Open AI API key:", type="password")
|
| 27 |
|
| 28 |
if "messages" not in st.session_state:
|
| 29 |
st.session_state["messages"]=[
|
|
|
|
| 37 |
st.session_state.messages.append({"role":"user","content":prompt})
|
| 38 |
st.chat_message("user").write(prompt)
|
| 39 |
|
| 40 |
+
llm=ChatOpenAI(api_key=api_key, model="gpt-4o",streaming=True)
|
| 41 |
tools=[search,arxiv,wiki]
|
| 42 |
|
| 43 |
search_agent=initialize_agent(tools,llm,agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,handling_parsing_errors=True)
|