You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System Information:
System: Darwin
Release: 24.1.0
Machine: arm64
Processor: arm
Python: 3.12.7 (main, Oct 1 2024, 02:05:46) [Clang 16.0.0 (clang-1600.0.26.3)]
encord-agents version: v0.1.2
Describe the bug
I am working on integrating a custom editor agent and started with a minimal example along the lines of your documentation. However it is not working as expected. I get "POST / HTTP/1.1" 422 Unprocessable Entity. It seems as if the payload is not in the expected format.
Chrome tells me that the content-type is:
content-type: text/plain
However for pydantic it needs to be json.
importjsonfromtypingimportAnnotatedfromencord.objects.ontology_labels_implimportLabelRowV2fromencord_agentsimportFrameDatafromencord_agents.fastapiimportdep_label_rowfromfastapiimportDepends, FastAPI, Form, Requestfromfastapi.middleware.corsimportCORSMiddlewareapp=FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*", "https://app.encord.com"],
allow_methods=["POST"], # I had to add this line
)
# This does not work, from: https://agents-docs.encord.com/editor_agents/fastapi/@app.post("/")defmy_agent(
frame_data: Annotated[FrameData, Form()],
label_row: Annotated[LabelRowV2, Depends(dep_label_row)],
):
# ... Do your edits to the labelslabel_row.save()
# This works, mind to uncomment the previous function to see this function at work@app.post("/")asyncdefmy_agent(
request: Request,
):
# ... Do your edits to the labelsbody=awaitrequest.body()
data=json.loads(body)
frame_data=FrameData(**data)
returnframe_data
To reproduce
pip install encord==0.1.152 "fastapi[standard]==0.115.6" encord-agents==0.1.2 && fastapi dev main.py
Additional information
No response
The text was updated successfully, but these errors were encountered:
If you find it not working after updating to encord-agents >= 0.1.4 plus using the above template, please check the network tab in your browser to see if triggering your agent sends data with the text/plain content type. If that's the case, it is because we (at Encord) registered that you were using editor agents prior to making the change to application/json content type. As a consequence, we have done our best to keep your existing agents from breaking. Please reach out and we'll upgrade your organisation to application/json.
Provide environment information
System Information:
System: Darwin
Release: 24.1.0
Machine: arm64
Processor: arm
Python: 3.12.7 (main, Oct 1 2024, 02:05:46) [Clang 16.0.0 (clang-1600.0.26.3)]
encord-agents version: v0.1.2
Describe the bug
I am working on integrating a custom editor agent and started with a minimal example along the lines of your documentation. However it is not working as expected. I get
"POST / HTTP/1.1" 422 Unprocessable Entity
. It seems as if the payload is not in the expected format.Chrome tells me that the content-type is:
However for pydantic it needs to be json.
To reproduce
pip install encord==0.1.152 "fastapi[standard]==0.115.6" encord-agents==0.1.2 && fastapi dev main.py
Additional information
No response
The text was updated successfully, but these errors were encountered: