mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
refactor(user/routes): simplify parsing of isPromptable
We can use the `inputs.boolean` from flask-restx [1] to parse boolean for us. [1]: https://flask-restx.readthedocs.io/en/latest/api.html?highlight=boolean#flask_restx.inputs.boolean Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from bson.binary import Binary, UuidRepresentation
|
||||
from bson.dbref import DBRef
|
||||
from bson.objectid import ObjectId
|
||||
from flask import Blueprint, jsonify, make_response, request
|
||||
from flask_restx import fields, Namespace, Resource
|
||||
from flask_restx import inputs, fields, Namespace, Resource
|
||||
from pymongo import MongoClient
|
||||
from werkzeug.utils import secure_filename
|
||||
|
||||
@@ -802,7 +802,7 @@ class ShareConversation(Resource):
|
||||
if missing_fields:
|
||||
return missing_fields
|
||||
|
||||
is_promptable = request.args.get("isPromptable")
|
||||
is_promptable = request.args.get("isPromptable", type=inputs.boolean)
|
||||
if is_promptable is None:
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": "isPromptable is required"}), 400
|
||||
@@ -831,7 +831,7 @@ class ShareConversation(Resource):
|
||||
uuid.uuid4(), UuidRepresentation.STANDARD
|
||||
)
|
||||
|
||||
if is_promptable.lower() == "true":
|
||||
if is_promptable:
|
||||
prompt_id = data.get("prompt_id", "default")
|
||||
chunks = data.get("chunks", "2")
|
||||
|
||||
@@ -859,7 +859,7 @@ class ShareConversation(Resource):
|
||||
"conversation_id": DBRef(
|
||||
"conversations", ObjectId(conversation_id)
|
||||
),
|
||||
"isPromptable": is_promptable.lower() == "true",
|
||||
"isPromptable": is_promptable,
|
||||
"first_n_queries": current_n_queries,
|
||||
"user": user,
|
||||
"api_key": api_uuid,
|
||||
@@ -883,7 +883,7 @@ class ShareConversation(Resource):
|
||||
"$ref": "conversations",
|
||||
"$id": ObjectId(conversation_id),
|
||||
},
|
||||
"isPromptable": is_promptable.lower() == "true",
|
||||
"isPromptable": is_promptable,
|
||||
"first_n_queries": current_n_queries,
|
||||
"user": user,
|
||||
"api_key": api_uuid,
|
||||
@@ -918,7 +918,7 @@ class ShareConversation(Resource):
|
||||
"$ref": "conversations",
|
||||
"$id": ObjectId(conversation_id),
|
||||
},
|
||||
"isPromptable": is_promptable.lower() == "true",
|
||||
"isPromptable": is_promptable,
|
||||
"first_n_queries": current_n_queries,
|
||||
"user": user,
|
||||
"api_key": api_uuid,
|
||||
@@ -939,7 +939,7 @@ class ShareConversation(Resource):
|
||||
"conversation_id": DBRef(
|
||||
"conversations", ObjectId(conversation_id)
|
||||
),
|
||||
"isPromptable": is_promptable.lower() == "false",
|
||||
"isPromptable": not is_promptable,
|
||||
"first_n_queries": current_n_queries,
|
||||
"user": user,
|
||||
}
|
||||
@@ -962,7 +962,7 @@ class ShareConversation(Resource):
|
||||
"$ref": "conversations",
|
||||
"$id": ObjectId(conversation_id),
|
||||
},
|
||||
"isPromptable": is_promptable.lower() == "false",
|
||||
"isPromptable": not is_promptable,
|
||||
"first_n_queries": current_n_queries,
|
||||
"user": user,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user