Python SDK#
client
#
AsyncLlamaDeployClient #
Source code in llama_deploy/client/async_client.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
create_session
async
#
create_session(poll_interval: float = DEFAULT_POLL_INTERVAL) -> AsyncSessionClient
Create a new session and return a AsyncSessionClient for it.
Returns:
Name | Type | Description |
---|---|---|
AsyncSessionClient |
AsyncSessionClient
|
A client for the newly created session. |
Source code in llama_deploy/client/async_client.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
list_sessions
async
#
list_sessions() -> List[SessionDefinition]
List all sessions registered with the control plane.
Returns:
Type | Description |
---|---|
List[SessionDefinition]
|
List[SessionDefinition]: A list of session definitions. |
Source code in llama_deploy/client/async_client.py
205 206 207 208 209 210 211 212 213 214 215 |
|
get_session_definition
async
#
get_session_definition(session_id: str) -> SessionDefinition
Get the definition of a session by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
SessionDefinition |
SessionDefinition
|
The definition of the session. |
Source code in llama_deploy/client/async_client.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
get_session
async
#
get_session(session_id: str, poll_interval: float = DEFAULT_POLL_INTERVAL) -> AsyncSessionClient
Get an existing session by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
AsyncSessionClient |
AsyncSessionClient
|
A client for the specified session. |
Raises:
Type | Description |
---|---|
ValueError
|
If the session does not exist. |
Source code in llama_deploy/client/async_client.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
get_or_create_session
async
#
get_or_create_session(session_id: str, poll_interval: float = DEFAULT_POLL_INTERVAL) -> AsyncSessionClient
Get an existing session by ID, or create a new one if it doesn't exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
AsyncSessionClient |
AsyncSessionClient
|
A client for the specified session. |
Source code in llama_deploy/client/async_client.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
get_service
async
#
get_service(service_name: str) -> ServiceDefinition
Get the definition of a service by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name
|
str
|
The name of the service to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
ServiceDefinition |
ServiceDefinition
|
The definition of the service. |
Source code in llama_deploy/client/async_client.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
|
delete_session
async
#
delete_session(session_id: str) -> None
Delete a session by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to delete. |
required |
Source code in llama_deploy/client/async_client.py
294 295 296 297 298 299 300 301 |
|
list_services
async
#
list_services() -> List[ServiceDefinition]
List all services registered with the control plane.
Returns:
Type | Description |
---|---|
List[ServiceDefinition]
|
List[ServiceDefinition]: A list of service definitions. |
Source code in llama_deploy/client/async_client.py
303 304 305 306 307 308 309 310 311 312 313 |
|
register_service
async
#
register_service(service_def: ServiceDefinition) -> None
Register a service with the control plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_def
|
ServiceDefinition
|
The service definition to register. |
required |
Source code in llama_deploy/client/async_client.py
315 316 317 318 319 320 321 322 323 324 325 |
|
deregister_service
async
#
deregister_service(service_name: str) -> None
Deregister a service from the control plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name
|
str
|
The name of the service to deregister. |
required |
Source code in llama_deploy/client/async_client.py
327 328 329 330 331 332 333 334 335 336 337 |
|
LlamaDeployClient #
Source code in llama_deploy/client/sync_client.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
|
create_session #
create_session(poll_interval: float = DEFAULT_POLL_INTERVAL) -> SessionClient
Create a new session and return a SessionClient for it.
Returns:
Name | Type | Description |
---|---|---|
SessionClient |
SessionClient
|
A client for the newly created session. |
Source code in llama_deploy/client/sync_client.py
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
|
list_sessions #
list_sessions() -> List[SessionDefinition]
List all sessions registered with the control plane.
Returns:
Type | Description |
---|---|
List[SessionDefinition]
|
List[SessionDefinition]: A list of session definitions. |
Source code in llama_deploy/client/sync_client.py
208 209 210 211 212 213 214 215 216 217 218 |
|
get_session_definition #
get_session_definition(session_id: str) -> SessionDefinition
Get the definition of a session by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
SessionDefinition |
SessionDefinition
|
The definition of the session. |
Source code in llama_deploy/client/sync_client.py
220 221 222 223 224 225 226 227 228 229 230 231 |
|
get_session #
get_session(session_id: str, poll_interval: float = DEFAULT_POLL_INTERVAL) -> SessionClient
Get an existing session by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
SessionClient |
SessionClient
|
A client for the specified session. |
Raises:
Type | Description |
---|---|
ValueError
|
If the session does not exist. |
Source code in llama_deploy/client/sync_client.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
get_or_create_session #
get_or_create_session(session_id: str, poll_interval: float = DEFAULT_POLL_INTERVAL) -> SessionClient
Get an existing session by ID, or create a new one if it doesn't exist.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
SessionClient |
SessionClient
|
A client for the specified session. |
Source code in llama_deploy/client/sync_client.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
get_service #
get_service(service_name: str) -> ServiceDefinition
Get the definition of a service by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name
|
str
|
The name of the service to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
ServiceDefinition |
ServiceDefinition
|
The definition of the service. |
Source code in llama_deploy/client/sync_client.py
278 279 280 281 282 283 284 285 286 287 288 289 |
|
delete_session #
delete_session(session_id: str) -> None
Delete a session by ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id
|
str
|
The ID of the session to delete. |
required |
Source code in llama_deploy/client/sync_client.py
291 292 293 294 295 296 297 298 |
|
list_services #
list_services() -> List[ServiceDefinition]
List all services registered with the control plane.
Returns:
Type | Description |
---|---|
List[ServiceDefinition]
|
List[ServiceDefinition]: A list of service definitions. |
Source code in llama_deploy/client/sync_client.py
300 301 302 303 304 305 306 307 308 309 310 |
|
register_service #
register_service(service_def: ServiceDefinition) -> None
Register a service with the control plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_def
|
ServiceDefinition
|
The service definition to register. |
required |
Source code in llama_deploy/client/sync_client.py
312 313 314 315 316 317 318 319 320 321 322 |
|
deregister_service #
deregister_service(service_name: str) -> None
Deregister a service from the control plane.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name
|
str
|
The name of the service to deregister. |
required |
Source code in llama_deploy/client/sync_client.py
324 325 326 327 328 329 330 331 332 333 334 |
|
Client #
Bases: _BaseClient
The Llama Deploy Python client.
The client is gives access to both the asyncio and non-asyncio APIs. To access the sync
API just use methods of client.sync
.
Example usage:
from llama_deploy.client import Client
# Use the same client instance
c = Client()
async def an_async_function():
status = await client.apiserver.status()
def normal_function():
status = client.sync.apiserver.status()
Source code in llama_deploy/client/client.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|