Update app.py
Browse files
app.py
CHANGED
@@ -17,28 +17,6 @@ from langchain_anthropic import ChatAnthropic
|
|
17 |
from langchain_community.tools import ShellTool
|
18 |
from langgraph.prebuilt import create_react_agent
|
19 |
|
20 |
-
if "use_sonnet" not in st.session_state:
|
21 |
-
st.session_state.use_sonnet = False
|
22 |
-
|
23 |
-
col1, col2 = st.columns(2)
|
24 |
-
|
25 |
-
# Initialize show_system_prompt in session state
|
26 |
-
if "show_system_prompt" not in st.session_state:
|
27 |
-
st.session_state.show_system_prompt = False
|
28 |
-
|
29 |
-
with col1:
|
30 |
-
if st.button("Show System Prompt" if not st.session_state.show_system_prompt else "Hide System Prompt"):
|
31 |
-
st.session_state.show_system_prompt = not st.session_state.show_system_prompt
|
32 |
-
|
33 |
-
with col2:
|
34 |
-
if st.button("Use Sonnet 3.5"):
|
35 |
-
st.session_state.use_sonnet = True
|
36 |
-
|
37 |
-
if st.session_state.use_sonnet:
|
38 |
-
sonnet_api_key = st.text_input("Input Anthropic API Key for Sonnet 3.5", type="password")
|
39 |
-
if sonnet_api_key:
|
40 |
-
os.environ["ANTHROPIC_API_KEY"] = sonnet_api_key
|
41 |
-
|
42 |
|
43 |
# Show title and description.
|
44 |
st.title("Coder for NextJS Templates")
|
@@ -65,12 +43,34 @@ github_token = st.text_input("Enter your Github Token", type="password")
|
|
65 |
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
|
66 |
|
67 |
if not (github_repo_url and github_token and anthropic_api_key):
|
68 |
-
st.info("Please add your Github Repo URL
|
69 |
else:
|
70 |
# Set environment variables
|
71 |
os.environ["ANTHROPIC_API_KEY"] = anthropic_api_key
|
72 |
os.environ["GITHUB_TOKEN"] = github_token
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
# Parse the repository URL to extract user_name and REPO_NAME
|
75 |
parsed_url = urlparse(github_repo_url)
|
76 |
path_parts = parsed_url.path.strip('/').split('/')
|
@@ -367,7 +367,7 @@ else:
|
|
367 |
|
368 |
# Create a chat input field to allow the user to enter a message. This will display
|
369 |
# automatically at the bottom of the page.
|
370 |
-
if prompt := st.chat_input("
|
371 |
|
372 |
# Store and display the current prompt.
|
373 |
st.session_state.messages.append({"role": "user", "content": prompt})
|
|
|
17 |
from langchain_community.tools import ShellTool
|
18 |
from langgraph.prebuilt import create_react_agent
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# Show title and description.
|
22 |
st.title("Coder for NextJS Templates")
|
|
|
43 |
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY")
|
44 |
|
45 |
if not (github_repo_url and github_token and anthropic_api_key):
|
46 |
+
st.info("Please add your Github Repo URL and Github Personal Token to continue.", icon="🗝️")
|
47 |
else:
|
48 |
# Set environment variables
|
49 |
os.environ["ANTHROPIC_API_KEY"] = anthropic_api_key
|
50 |
os.environ["GITHUB_TOKEN"] = github_token
|
51 |
|
52 |
+
# Add the buttons after the inputs are provided
|
53 |
+
if "use_sonnet" not in st.session_state:
|
54 |
+
st.session_state.use_sonnet = False
|
55 |
+
|
56 |
+
if "show_system_prompt" not in st.session_state:
|
57 |
+
st.session_state.show_system_prompt = False
|
58 |
+
|
59 |
+
col1, col2 = st.columns(2)
|
60 |
+
|
61 |
+
with col1:
|
62 |
+
if st.button("Show System Prompt" if not st.session_state.show_system_prompt else "Hide System Prompt"):
|
63 |
+
st.session_state.show_system_prompt = not st.session_state.show_system_prompt
|
64 |
+
|
65 |
+
with col2:
|
66 |
+
if st.button("Use Sonnet 3.5"):
|
67 |
+
st.session_state.use_sonnet = True
|
68 |
+
|
69 |
+
if st.session_state.use_sonnet:
|
70 |
+
sonnet_api_key = st.text_input("Input Anthropic API Key for Sonnet 3.5", type="password")
|
71 |
+
if sonnet_api_key:
|
72 |
+
os.environ["ANTHROPIC_API_KEY"] = sonnet_api_key
|
73 |
+
|
74 |
# Parse the repository URL to extract user_name and REPO_NAME
|
75 |
parsed_url = urlparse(github_repo_url)
|
76 |
path_parts = parsed_url.path.strip('/').split('/')
|
|
|
367 |
|
368 |
# Create a chat input field to allow the user to enter a message. This will display
|
369 |
# automatically at the bottom of the page.
|
370 |
+
if prompt := st.chat_input("Give me a Task!"):
|
371 |
|
372 |
# Store and display the current prompt.
|
373 |
st.session_state.messages.append({"role": "user", "content": prompt})
|