start of ANOTHER ONE langgraph
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Annotated
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from fastapi import Body, Depends, FastAPI, HTTPException, Path, Query
|
||||
|
||||
@@ -12,10 +12,13 @@ ShellApp = App() # global, scary
|
||||
|
||||
@app.get("/shells")
|
||||
def list_shells():
|
||||
return ShellApp.list_shells()
|
||||
shells = ShellApp.list_shells()
|
||||
if not shells:
|
||||
raise HTTPException(status_code=404, detail="No shells found")
|
||||
return shells
|
||||
|
||||
|
||||
@app.post("/shells/new")
|
||||
@app.post("/shells/new", status_code=201)
|
||||
def create_shell():
|
||||
return ShellApp.create_shell()
|
||||
|
||||
@@ -29,7 +32,12 @@ def get_last_shell():
|
||||
|
||||
|
||||
@app.get("/shells/{shell_name}")
|
||||
def get_shell(shell_name: str):
|
||||
def get_shell(
|
||||
shell_name: Annotated[
|
||||
str,
|
||||
Path(..., description="The shell to query for metadata"),
|
||||
],
|
||||
):
|
||||
try:
|
||||
return ShellApp.get_shell(shell_name)
|
||||
except KeyError as error:
|
||||
@@ -38,7 +46,10 @@ def get_shell(shell_name: str):
|
||||
|
||||
@app.post("/shells/{shell_name}/run")
|
||||
def run_code(
|
||||
shell_name: Annotated[str, Path(..., description="The shell to run code in")],
|
||||
shell_name: Annotated[
|
||||
Literal["last", "new"] | str,
|
||||
Path(..., description="The shell to run code in"),
|
||||
],
|
||||
code: Annotated[
|
||||
str, Body(..., description="The code to execute", media_type="text/plain")
|
||||
],
|
||||
@@ -53,7 +64,10 @@ def run_code_2(
|
||||
str, Body(..., description="The code to execute", media_type="text/plain")
|
||||
],
|
||||
options: Annotated[CallOptions, Depends()],
|
||||
shell_name: Annotated[str, Query(description="The shell to run code in")] = "last",
|
||||
shell_name: Annotated[
|
||||
Literal["last", "new"] | str,
|
||||
Query("last", description="The shell to run code in"),
|
||||
] = "last",
|
||||
):
|
||||
return ShellApp.run_code(code, shell_name, options=options)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user