0
# Application Management
1
2
Create, manage, and serve LangServe applications with template integration, dependency management, and local development server functionality. This namespace provides complete lifecycle management for LangChain applications.
3
4
## Capabilities
5
6
### Create New Application
7
8
Creates a new LangServe application with optional template seeding and pip installation.
9
10
```bash { .api }
11
langchain app new [name] [options]
12
13
Options:
14
--package TEXT Packages to seed the project with (can be repeated)
15
--pip/--no-pip Pip install templates as editable dependencies
16
--non-interactive Don't prompt for input
17
--interactive Prompt for input (default)
18
```
19
20
**Usage Examples:**
21
22
```bash
23
# Create new app interactively
24
langchain app new my-app
25
26
# Create app with specific templates
27
langchain app new my-app --package extraction-openai-functions --package rag-conversation
28
29
# Create app non-interactively with pip install
30
langchain app new my-app --package my-template --pip --non-interactive
31
32
# Create app in current directory
33
langchain app new .
34
```
35
36
### Add Templates
37
38
Add templates to an existing LangServe application with dependency resolution and automatic configuration.
39
40
```bash { .api }
41
langchain app add [dependencies] [options]
42
43
Options:
44
--api-path TEXT API paths to add (can be repeated)
45
--project-dir PATH The project directory
46
--repo TEXT Install from specific github repo (can be repeated)
47
--branch TEXT Install from specific branch (can be repeated)
48
--pip/--no-pip Pip install templates as editable dependencies
49
```
50
51
**Usage Examples:**
52
53
```bash
54
# Add template from default repository
55
langchain app add extraction-openai-functions --pip
56
57
# Add template from git repository
58
langchain app add git+ssh://git@github.com/user/template.git --pip
59
60
# Add multiple templates with specific branches
61
langchain app add template1 template2 --branch v0.2 --pip
62
63
# Add with custom API path
64
langchain app add my-template --api-path /custom/path --pip
65
```
66
67
**Dependency String Formats:**
68
69
The CLI supports multiple dependency specification formats:
70
71
- Simple name: `template-name` (uses default repository)
72
- Git URL: `git+https://github.com/user/repo.git`
73
- Git URL with branch: `git+https://github.com/user/repo.git@branch`
74
- Git URL with subdirectory: `git+https://github.com/user/repo.git#subdirectory=path/to/template`
75
76
### Remove Templates
77
78
Remove templates from a LangServe application, cleaning up dependencies and configurations.
79
80
```bash { .api }
81
langchain app remove [api_paths] [options]
82
83
Options:
84
--project-dir PATH The project directory
85
86
Arguments:
87
api_paths The API paths to remove (required, can be multiple)
88
```
89
90
**Usage Examples:**
91
92
```bash
93
# Remove single template
94
langchain app remove extraction-openai-functions
95
96
# Remove multiple templates
97
langchain app remove template1 template2
98
99
# Remove from specific project directory
100
langchain app remove my-template --project-dir /path/to/project
101
```
102
103
### Serve Application
104
105
Start a local development server for LangServe applications with hot reload support.
106
107
```bash { .api }
108
langchain app serve [options]
109
110
Options:
111
--port INTEGER The port to run the server on (default: 8000)
112
--host TEXT The host to run the server on (default: 127.0.0.1)
113
--app TEXT The app to run, e.g. `app.server:app`
114
```
115
116
**Usage Examples:**
117
118
```bash
119
# Serve on default port and host
120
langchain app serve
121
122
# Serve on specific port and host
123
langchain app serve --port 8080 --host 0.0.0.0
124
125
# Serve specific app module
126
langchain app serve --app myapp.server:application
127
```
128
129
## Programmatic API
130
131
### Application Namespace Functions
132
133
```python { .api }
134
def new(
135
name: Optional[str] = None,
136
*,
137
package: Optional[list[str]] = None,
138
pip: Optional[bool] = None,
139
noninteractive: bool = False,
140
) -> None:
141
"""Create a new LangServe application."""
142
143
def add(
144
dependencies: Optional[list[str]] = None,
145
*,
146
api_path: Optional[list[str]] = None,
147
project_dir: Optional[Path] = None,
148
repo: Optional[list[str]] = None,
149
branch: Optional[list[str]] = None,
150
pip: bool,
151
) -> None:
152
"""Add the specified template to the current LangServe app."""
153
154
def remove(
155
api_paths: list[str],
156
*,
157
project_dir: Optional[Path] = None,
158
) -> None:
159
"""Remove the specified package from the current LangServe app."""
160
161
def serve(
162
*,
163
port: Optional[int] = None,
164
host: Optional[str] = None,
165
app: Optional[str] = None,
166
) -> None:
167
"""Start the LangServe app."""
168
```
169
170
### Configuration
171
172
The application management system uses several configuration patterns:
173
174
- **Project Structure**: Apps are created with standard LangServe structure including `app/server.py`, `pyproject.toml`, and `packages/` directory
175
- **Template Integration**: Templates are copied to `packages/` directory and added as editable dependencies
176
- **Dependency Management**: Automatic `pyproject.toml` updates with local path dependencies
177
- **Server Configuration**: Uses Uvicorn with hot reload for development
178
179
## Error Handling
180
181
Common error scenarios and their handling:
182
183
- **Missing pyproject.toml**: Commands that require project context will fail with clear error messages
184
- **Template Not Found**: Invalid template names or git URLs will be reported during add operations
185
- **Dependency Conflicts**: Version conflicts in pyproject.toml are handled gracefully
186
- **Network Issues**: Git operations include retry logic and clear error reporting
187
- **Permission Issues**: File system operations include appropriate error handling and user feedback