Joshua Sundance Bailey
commited on
Commit
·
88b1e9f
1
Parent(s):
53abb59
sidebar order
Browse files- langchain-streamlit-demo/app.py +17 -16
langchain-streamlit-demo/app.py
CHANGED
@@ -35,9 +35,25 @@ st.sidebar.markdown(
|
|
35 |
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
|
36 |
st.session_state.openai_api_key = openai_api_key
|
37 |
|
38 |
-
langsmith_api_key = st.sidebar.text_input(
|
|
|
|
|
|
|
39 |
st.session_state.langsmith_api_key = langsmith_api_key
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
|
|
|
|
|
|
|
|
41 |
|
42 |
if st.session_state.openai_api_key.startswith("sk-"):
|
43 |
system_prompt = (
|
@@ -63,21 +79,6 @@ if st.session_state.openai_api_key.startswith("sk-"):
|
|
63 |
|
64 |
chain = get_llm_chain(memory, system_prompt, temperature)
|
65 |
|
66 |
-
if st.session_state.langsmith_api_key.startswith("ls__"):
|
67 |
-
langsmith_project = st.sidebar.text_input(
|
68 |
-
"LangSmith Project Name",
|
69 |
-
value="langchain-streamlit-demo",
|
70 |
-
)
|
71 |
-
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
|
72 |
-
os.environ["LANGCHAIN_API_KEY"] = st.session_state.langsmith_api_key
|
73 |
-
os.environ["LANGCHAIN_TRACING_V2"] = "true"
|
74 |
-
os.environ["LANGCHAIN_PROJECT"] = langsmith_project
|
75 |
-
|
76 |
-
client = get_langsmith_client()
|
77 |
-
else:
|
78 |
-
langsmith_project = None
|
79 |
-
client = None
|
80 |
-
|
81 |
run_collector = RunCollectorCallbackHandler()
|
82 |
|
83 |
if st.sidebar.button("Clear message history"):
|
|
|
35 |
openai_api_key = st.sidebar.text_input("OpenAI API Key", type="password")
|
36 |
st.session_state.openai_api_key = openai_api_key
|
37 |
|
38 |
+
langsmith_api_key = st.sidebar.text_input(
|
39 |
+
"LangSmith API Key (optional)",
|
40 |
+
type="password",
|
41 |
+
)
|
42 |
st.session_state.langsmith_api_key = langsmith_api_key
|
43 |
+
if st.session_state.langsmith_api_key.startswith("ls__"):
|
44 |
+
langsmith_project = st.sidebar.text_input(
|
45 |
+
"LangSmith Project Name",
|
46 |
+
value="langchain-streamlit-demo",
|
47 |
+
)
|
48 |
+
os.environ["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com"
|
49 |
+
os.environ["LANGCHAIN_API_KEY"] = st.session_state.langsmith_api_key
|
50 |
+
os.environ["LANGCHAIN_TRACING_V2"] = "true"
|
51 |
+
os.environ["LANGCHAIN_PROJECT"] = langsmith_project
|
52 |
|
53 |
+
client = get_langsmith_client()
|
54 |
+
else:
|
55 |
+
langsmith_project = None
|
56 |
+
client = None
|
57 |
|
58 |
if st.session_state.openai_api_key.startswith("sk-"):
|
59 |
system_prompt = (
|
|
|
79 |
|
80 |
chain = get_llm_chain(memory, system_prompt, temperature)
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
run_collector = RunCollectorCallbackHandler()
|
83 |
|
84 |
if st.sidebar.button("Clear message history"):
|