Joshua Sundance Bailey
commited on
Commit
·
1ea3b53
1
Parent(s):
5825ff9
wikipedia
Browse files
langchain-streamlit-demo/app.py
CHANGED
@@ -13,7 +13,9 @@ from langchain.memory import ConversationBufferMemory, StreamlitChatMessageHisto
|
|
13 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
14 |
from langchain.schema.document import Document
|
15 |
from langchain.schema.retriever import BaseRetriever
|
|
|
16 |
from langchain.tools import Tool
|
|
|
17 |
from langsmith.client import Client
|
18 |
from streamlit_feedback import streamlit_feedback
|
19 |
|
@@ -440,6 +442,10 @@ if st.session_state.llm:
|
|
440 |
# callbacks.append(stream_handler)
|
441 |
message_placeholder = st.empty()
|
442 |
|
|
|
|
|
|
|
|
|
443 |
if st.session_state.provider in ("Azure OpenAI", "OpenAI"):
|
444 |
st_callback = StreamlitCallbackHandler(st.container())
|
445 |
callbacks.append(st_callback)
|
@@ -449,10 +455,10 @@ if st.session_state.llm:
|
|
449 |
config=get_config(callbacks),
|
450 |
),
|
451 |
name="web-research-assistant",
|
452 |
-
description="this assistant returns a report based on web research",
|
453 |
)
|
454 |
|
455 |
-
TOOLS = [research_assistant_tool]
|
456 |
if use_document_chat:
|
457 |
st.session_state.doc_chain = get_runnable(
|
458 |
use_document_chat,
|
@@ -471,7 +477,7 @@ if st.session_state.llm:
|
|
471 |
name="user-document-chat",
|
472 |
description="this assistant returns a response based on the user's custom context. if the user's meaning is unclear, perhaps the answer is here. generally speaking, try this tool before conducting web research.",
|
473 |
)
|
474 |
-
TOOLS = [doc_chain_tool, research_assistant_tool]
|
475 |
|
476 |
st.session_state.chain = get_agent(
|
477 |
TOOLS,
|
|
|
13 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
14 |
from langchain.schema.document import Document
|
15 |
from langchain.schema.retriever import BaseRetriever
|
16 |
+
from langchain.tools import DuckDuckGoSearchRun, WikipediaQueryRun
|
17 |
from langchain.tools import Tool
|
18 |
+
from langchain.utilities import WikipediaAPIWrapper
|
19 |
from langsmith.client import Client
|
20 |
from streamlit_feedback import streamlit_feedback
|
21 |
|
|
|
442 |
# callbacks.append(stream_handler)
|
443 |
message_placeholder = st.empty()
|
444 |
|
445 |
+
default_tools = [
|
446 |
+
DuckDuckGoSearchRun(),
|
447 |
+
WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper()),
|
448 |
+
]
|
449 |
if st.session_state.provider in ("Azure OpenAI", "OpenAI"):
|
450 |
st_callback = StreamlitCallbackHandler(st.container())
|
451 |
callbacks.append(st_callback)
|
|
|
455 |
config=get_config(callbacks),
|
456 |
),
|
457 |
name="web-research-assistant",
|
458 |
+
description="this assistant returns a comprehensive report based on web research. for quick facts, use duckduckgo instead.",
|
459 |
)
|
460 |
|
461 |
+
TOOLS = [research_assistant_tool] + default_tools
|
462 |
if use_document_chat:
|
463 |
st.session_state.doc_chain = get_runnable(
|
464 |
use_document_chat,
|
|
|
477 |
name="user-document-chat",
|
478 |
description="this assistant returns a response based on the user's custom context. if the user's meaning is unclear, perhaps the answer is here. generally speaking, try this tool before conducting web research.",
|
479 |
)
|
480 |
+
TOOLS = [doc_chain_tool, research_assistant_tool] + default_tools
|
481 |
|
482 |
st.session_state.chain = get_agent(
|
483 |
TOOLS,
|
langchain-streamlit-demo/defaults.py
CHANGED
@@ -25,7 +25,7 @@ DEFAULT_MODEL = os.environ.get("DEFAULT_MODEL", "gpt-3.5-turbo")
|
|
25 |
|
26 |
DEFAULT_SYSTEM_PROMPT = os.environ.get(
|
27 |
"DEFAULT_SYSTEM_PROMPT",
|
28 |
-
"You are a helpful chatbot.",
|
29 |
)
|
30 |
|
31 |
MIN_TEMP = float(os.environ.get("MIN_TEMPERATURE", 0.0))
|
|
|
25 |
|
26 |
DEFAULT_SYSTEM_PROMPT = os.environ.get(
|
27 |
"DEFAULT_SYSTEM_PROMPT",
|
28 |
+
"You are a helpful chatbot. Do not rush. Always plan, think, and act in a step-by-step manner.",
|
29 |
)
|
30 |
|
31 |
MIN_TEMP = float(os.environ.get("MIN_TEMPERATURE", 0.0))
|
requirements.txt
CHANGED
@@ -14,3 +14,4 @@ streamlit-feedback==0.1.3
|
|
14 |
tiktoken==0.5.2
|
15 |
tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability
|
16 |
validators>=0.21.0 # not directly required, pinned by Snyk to avoid a vulnerability
|
|
|
|
14 |
tiktoken==0.5.2
|
15 |
tornado>=6.3.3 # not directly required, pinned by Snyk to avoid a vulnerability
|
16 |
validators>=0.21.0 # not directly required, pinned by Snyk to avoid a vulnerability
|
17 |
+
wikipedia==1.4.0
|