|
8 | 8 | import click |
9 | 9 |
|
10 | 10 | TEMPLATES: dict[str, dict[str, str]] = { |
| 11 | + "Deep Agent": { |
| 12 | + "description": "An opinionated deployment template for a Deep Agent.", |
| 13 | + "python": "https://github.com/langchain-ai/deep-agent-template/archive/refs/heads/main.zip", |
| 14 | + "js": "https://github.com/langchain-ai/deep-agent-template-js/archive/refs/heads/main.zip", |
| 15 | + }, |
| 16 | + "Agent": { |
| 17 | + "description": "A simple agent that can be flexibly extended to many tools.", |
| 18 | + "python": "https://github.com/langchain-ai/simple-agent-template/archive/refs/heads/main.zip", |
| 19 | + }, |
11 | 20 | "New LangGraph Project": { |
12 | 21 | "description": "A simple, minimal chatbot with memory.", |
13 | 22 | "python": "https://github.com/langchain-ai/new-langgraph-project/archive/refs/heads/main.zip", |
14 | 23 | "js": "https://github.com/langchain-ai/new-langgraphjs-project/archive/refs/heads/main.zip", |
15 | 24 | }, |
16 | | - "ReAct Agent": { |
17 | | - "description": "A simple agent that can be flexibly extended to many tools.", |
18 | | - "python": "https://github.com/langchain-ai/react-agent/archive/refs/heads/main.zip", |
19 | | - "js": "https://github.com/langchain-ai/react-agent-js/archive/refs/heads/main.zip", |
20 | | - }, |
21 | | - "Memory Agent": { |
22 | | - "description": "A ReAct-style agent with an additional tool to store memories for use across conversational threads.", |
23 | | - "python": "https://github.com/langchain-ai/memory-agent/archive/refs/heads/main.zip", |
24 | | - "js": "https://github.com/langchain-ai/memory-agent-js/archive/refs/heads/main.zip", |
25 | | - }, |
26 | | - "Retrieval Agent": { |
27 | | - "description": "An agent that includes a retrieval-based question-answering system.", |
28 | | - "python": "https://github.com/langchain-ai/retrieval-agent-template/archive/refs/heads/main.zip", |
29 | | - "js": "https://github.com/langchain-ai/retrieval-agent-template-js/archive/refs/heads/main.zip", |
30 | | - }, |
31 | | - "Data-enrichment Agent": { |
32 | | - "description": "An agent that performs web searches and organizes its findings into a structured format.", |
33 | | - "python": "https://github.com/langchain-ai/data-enrichment/archive/refs/heads/main.zip", |
34 | | - "js": "https://github.com/langchain-ai/data-enrichment-js/archive/refs/heads/main.zip", |
35 | | - }, |
36 | | - "Basic Deep Agent": { |
37 | | - "description": "An opinionated deployment template for a Deep Agent built with createDeepAgent.", |
38 | | - "python": "https://github.com/langchain-ai/deep-agent-template/archive/refs/heads/main.zip", |
39 | | - "js": "https://github.com/langchain-ai/deep-agent-template-js/archive/refs/heads/main.zip", |
40 | | - }, |
41 | 25 | } |
42 | 26 |
|
43 | 27 | # Generate TEMPLATE_IDS programmatically |
@@ -83,19 +67,25 @@ def _choose_template() -> str: |
83 | 67 | click.secho("❌ Invalid choice. Please try again.", fg="red") |
84 | 68 | return _choose_template() |
85 | 69 |
|
86 | | - # Prompt the user to choose between Python or JS/TS version |
| 70 | + template_info = TEMPLATES[selected_template] |
| 71 | + available_langs = [lang for lang in ("python", "js") if lang in template_info] |
| 72 | + |
87 | 73 | click.secho( |
88 | | - f"\nYou selected: {selected_template} - {TEMPLATES[selected_template]['description']}", |
| 74 | + f"\nYou selected: {selected_template} - {template_info['description']}", |
89 | 75 | fg="green", |
90 | 76 | ) |
| 77 | + |
| 78 | + if len(available_langs) == 1: |
| 79 | + return template_info[available_langs[0]] |
| 80 | + |
91 | 81 | version_choice: int = click.prompt( |
92 | 82 | "Choose language (1 for Python 🐍, 2 for JS/TS 🌐)", type=int |
93 | 83 | ) |
94 | 84 |
|
95 | 85 | if version_choice == 1: |
96 | | - return TEMPLATES[selected_template]["python"] |
| 86 | + return template_info["python"] |
97 | 87 | elif version_choice == 2: |
98 | | - return TEMPLATES[selected_template]["js"] |
| 88 | + return template_info["js"] |
99 | 89 | else: |
100 | 90 | click.secho("❌ Invalid choice. Please try again.", fg="red") |
101 | 91 | return _choose_template() |
@@ -135,37 +125,6 @@ def _download_repo_with_requests(repo_url: str, path: str) -> None: |
135 | 125 | sys.exit(1) |
136 | 126 |
|
137 | 127 |
|
138 | | -def _get_template_url(template_name: str) -> str | None: |
139 | | - """ |
140 | | - Retrieves the template URL based on the provided template name. |
141 | | -
|
142 | | - Args: |
143 | | - template_name: The name of the template. |
144 | | -
|
145 | | - Returns: |
146 | | - Optional[str]: The URL of the template if found, else None. |
147 | | - """ |
148 | | - if template_name in TEMPLATES: |
149 | | - click.secho(f"Template selected: {template_name}", fg="green") |
150 | | - version_choice: int = click.prompt( |
151 | | - "Choose version (1 for Python 🐍, 2 for JS/TS 🌐)", type=int |
152 | | - ) |
153 | | - |
154 | | - if version_choice == 1: |
155 | | - return TEMPLATES[template_name]["python"] |
156 | | - elif version_choice == 2: |
157 | | - return TEMPLATES[template_name]["js"] |
158 | | - else: |
159 | | - click.secho("❌ Invalid choice. Please try again.", fg="red") |
160 | | - return None |
161 | | - else: |
162 | | - click.secho( |
163 | | - f"Template '{template_name}' not found. Please select from the available options.", |
164 | | - fg="red", |
165 | | - ) |
166 | | - return None |
167 | | - |
168 | | - |
169 | 128 | def create_new(path: str | None, template: str | None) -> None: |
170 | 129 | """Create a new LangGraph project at the specified PATH using the chosen TEMPLATE. |
171 | 130 |
|
|
0 commit comments