How to change the value of request body? #2552
Replies: 1 comment
-
@app.post(f"/{APP_USER_NAME}/invoke", include_in_schema=True)
async def invoke(request: Request) -> Response:
request_json = await request.json()
input = request_json["input"]["input"]
rag_message = retriever.rag(input=input, k=2, score_threshold=0.9, verbose=verbose)
if verbose is True:
print("\033[0;33m" + f"my prompt is: {rag_message}" + "\033[0m")
async def receive_func() -> Message:
m: dict[str, Any] = {"input": {"input": rag_message}}
s = json.dumps(m, ensure_ascii=False)
result: Message = {
"type": "http.request",
"body": s.encode("utf-8")
}
return result
r = Request(scope=request.scope, receive=receive_func)
return await api_handler.invoke(r) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to change the request body value of simple_invoke,would you give me a demo? I can't change request body value.
Based on my experience with Java and C #, I believe this can be solved, but I am not very familiar with FastAPI . Can you help me?
Thanks!
Important
Beta Was this translation helpful? Give feedback.
All reactions