Skip to content

Commit

Permalink
Merge pull request #1321 from Juneezee/refactor/share-conversation-is…
Browse files Browse the repository at this point in the history
…Promptable-parse

refactor(user/routes): simplify parsing of isPromptable
  • Loading branch information
dartpain authored Oct 16, 2024
2 parents 20bd7ca + 047afee commit 3f1bae3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions application/api/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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

Expand Down Expand Up @@ -802,7 +802,7 @@ def post(self):
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
Expand Down Expand Up @@ -831,7 +831,7 @@ def post(self):
uuid.uuid4(), UuidRepresentation.STANDARD
)

if is_promptable.lower() == "true":
if is_promptable:
prompt_id = data.get("prompt_id", "default")
chunks = data.get("chunks", "2")

Expand Down Expand Up @@ -859,7 +859,7 @@ def post(self):
"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,
Expand All @@ -883,7 +883,7 @@ def post(self):
"$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,
Expand Down Expand Up @@ -918,7 +918,7 @@ def post(self):
"$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,
Expand All @@ -939,7 +939,7 @@ def post(self):
"conversation_id": DBRef(
"conversations", ObjectId(conversation_id)
),
"isPromptable": is_promptable.lower() == "false",
"isPromptable": not is_promptable,
"first_n_queries": current_n_queries,
"user": user,
}
Expand All @@ -962,7 +962,7 @@ def post(self):
"$ref": "conversations",
"$id": ObjectId(conversation_id),
},
"isPromptable": is_promptable.lower() == "false",
"isPromptable": not is_promptable,
"first_n_queries": current_n_queries,
"user": user,
}
Expand Down

0 comments on commit 3f1bae3

Please sign in to comment.