fluent api (#27093)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -15,19 +15,19 @@ from models.model import App
|
||||
from services.annotation_service import AppAnnotationService
|
||||
|
||||
# Define parsers for annotation API
|
||||
annotation_create_parser = reqparse.RequestParser()
|
||||
annotation_create_parser.add_argument("question", required=True, type=str, location="json", help="Annotation question")
|
||||
annotation_create_parser.add_argument("answer", required=True, type=str, location="json", help="Annotation answer")
|
||||
annotation_create_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("question", required=True, type=str, location="json", help="Annotation question")
|
||||
.add_argument("answer", required=True, type=str, location="json", help="Annotation answer")
|
||||
)
|
||||
|
||||
annotation_reply_action_parser = reqparse.RequestParser()
|
||||
annotation_reply_action_parser.add_argument(
|
||||
"score_threshold", required=True, type=float, location="json", help="Score threshold for annotation matching"
|
||||
)
|
||||
annotation_reply_action_parser.add_argument(
|
||||
"embedding_provider_name", required=True, type=str, location="json", help="Embedding provider name"
|
||||
)
|
||||
annotation_reply_action_parser.add_argument(
|
||||
"embedding_model_name", required=True, type=str, location="json", help="Embedding model name"
|
||||
annotation_reply_action_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument(
|
||||
"score_threshold", required=True, type=float, location="json", help="Score threshold for annotation matching"
|
||||
)
|
||||
.add_argument("embedding_provider_name", required=True, type=str, location="json", help="Embedding provider name")
|
||||
.add_argument("embedding_model_name", required=True, type=str, location="json", help="Embedding model name")
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -85,11 +85,13 @@ class AudioApi(Resource):
|
||||
|
||||
|
||||
# Define parser for text-to-audio API
|
||||
text_to_audio_parser = reqparse.RequestParser()
|
||||
text_to_audio_parser.add_argument("message_id", type=str, required=False, location="json", help="Message ID")
|
||||
text_to_audio_parser.add_argument("voice", type=str, location="json", help="Voice to use for TTS")
|
||||
text_to_audio_parser.add_argument("text", type=str, location="json", help="Text to convert to audio")
|
||||
text_to_audio_parser.add_argument("streaming", type=bool, location="json", help="Enable streaming response")
|
||||
text_to_audio_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("message_id", type=str, required=False, location="json", help="Message ID")
|
||||
.add_argument("voice", type=str, location="json", help="Voice to use for TTS")
|
||||
.add_argument("text", type=str, location="json", help="Text to convert to audio")
|
||||
.add_argument("streaming", type=bool, location="json", help="Enable streaming response")
|
||||
)
|
||||
|
||||
|
||||
@service_api_ns.route("/text-to-audio")
|
||||
|
||||
@@ -37,40 +37,34 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Define parser for completion API
|
||||
completion_parser = reqparse.RequestParser()
|
||||
completion_parser.add_argument(
|
||||
"inputs", type=dict, required=True, location="json", help="Input parameters for completion"
|
||||
)
|
||||
completion_parser.add_argument("query", type=str, location="json", default="", help="The query string")
|
||||
completion_parser.add_argument("files", type=list, required=False, location="json", help="List of file attachments")
|
||||
completion_parser.add_argument(
|
||||
"response_mode", type=str, choices=["blocking", "streaming"], location="json", help="Response mode"
|
||||
)
|
||||
completion_parser.add_argument(
|
||||
"retriever_from", type=str, required=False, default="dev", location="json", help="Retriever source"
|
||||
completion_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("inputs", type=dict, required=True, location="json", help="Input parameters for completion")
|
||||
.add_argument("query", type=str, location="json", default="", help="The query string")
|
||||
.add_argument("files", type=list, required=False, location="json", help="List of file attachments")
|
||||
.add_argument("response_mode", type=str, choices=["blocking", "streaming"], location="json", help="Response mode")
|
||||
.add_argument("retriever_from", type=str, required=False, default="dev", location="json", help="Retriever source")
|
||||
)
|
||||
|
||||
# Define parser for chat API
|
||||
chat_parser = reqparse.RequestParser()
|
||||
chat_parser.add_argument("inputs", type=dict, required=True, location="json", help="Input parameters for chat")
|
||||
chat_parser.add_argument("query", type=str, required=True, location="json", help="The chat query")
|
||||
chat_parser.add_argument("files", type=list, required=False, location="json", help="List of file attachments")
|
||||
chat_parser.add_argument(
|
||||
"response_mode", type=str, choices=["blocking", "streaming"], location="json", help="Response mode"
|
||||
chat_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("inputs", type=dict, required=True, location="json", help="Input parameters for chat")
|
||||
.add_argument("query", type=str, required=True, location="json", help="The chat query")
|
||||
.add_argument("files", type=list, required=False, location="json", help="List of file attachments")
|
||||
.add_argument("response_mode", type=str, choices=["blocking", "streaming"], location="json", help="Response mode")
|
||||
.add_argument("conversation_id", type=uuid_value, location="json", help="Existing conversation ID")
|
||||
.add_argument("retriever_from", type=str, required=False, default="dev", location="json", help="Retriever source")
|
||||
.add_argument(
|
||||
"auto_generate_name",
|
||||
type=bool,
|
||||
required=False,
|
||||
default=True,
|
||||
location="json",
|
||||
help="Auto generate conversation name",
|
||||
)
|
||||
.add_argument("workflow_id", type=str, required=False, location="json", help="Workflow ID for advanced chat")
|
||||
)
|
||||
chat_parser.add_argument("conversation_id", type=uuid_value, location="json", help="Existing conversation ID")
|
||||
chat_parser.add_argument(
|
||||
"retriever_from", type=str, required=False, default="dev", location="json", help="Retriever source"
|
||||
)
|
||||
chat_parser.add_argument(
|
||||
"auto_generate_name",
|
||||
type=bool,
|
||||
required=False,
|
||||
default=True,
|
||||
location="json",
|
||||
help="Auto generate conversation name",
|
||||
)
|
||||
chat_parser.add_argument("workflow_id", type=str, required=False, location="json", help="Workflow ID for advanced chat")
|
||||
|
||||
|
||||
@service_api_ns.route("/completion-messages")
|
||||
|
||||
@@ -24,48 +24,63 @@ from models.model import App, AppMode, EndUser
|
||||
from services.conversation_service import ConversationService
|
||||
|
||||
# Define parsers for conversation APIs
|
||||
conversation_list_parser = reqparse.RequestParser()
|
||||
conversation_list_parser.add_argument(
|
||||
"last_id", type=uuid_value, location="args", help="Last conversation ID for pagination"
|
||||
)
|
||||
conversation_list_parser.add_argument(
|
||||
"limit",
|
||||
type=int_range(1, 100),
|
||||
required=False,
|
||||
default=20,
|
||||
location="args",
|
||||
help="Number of conversations to return",
|
||||
)
|
||||
conversation_list_parser.add_argument(
|
||||
"sort_by",
|
||||
type=str,
|
||||
choices=["created_at", "-created_at", "updated_at", "-updated_at"],
|
||||
required=False,
|
||||
default="-updated_at",
|
||||
location="args",
|
||||
help="Sort order for conversations",
|
||||
conversation_list_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("last_id", type=uuid_value, location="args", help="Last conversation ID for pagination")
|
||||
.add_argument(
|
||||
"limit",
|
||||
type=int_range(1, 100),
|
||||
required=False,
|
||||
default=20,
|
||||
location="args",
|
||||
help="Number of conversations to return",
|
||||
)
|
||||
.add_argument(
|
||||
"sort_by",
|
||||
type=str,
|
||||
choices=["created_at", "-created_at", "updated_at", "-updated_at"],
|
||||
required=False,
|
||||
default="-updated_at",
|
||||
location="args",
|
||||
help="Sort order for conversations",
|
||||
)
|
||||
)
|
||||
|
||||
conversation_rename_parser = reqparse.RequestParser()
|
||||
conversation_rename_parser.add_argument("name", type=str, required=False, location="json", help="New conversation name")
|
||||
conversation_rename_parser.add_argument(
|
||||
"auto_generate", type=bool, required=False, default=False, location="json", help="Auto-generate conversation name"
|
||||
conversation_rename_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("name", type=str, required=False, location="json", help="New conversation name")
|
||||
.add_argument(
|
||||
"auto_generate",
|
||||
type=bool,
|
||||
required=False,
|
||||
default=False,
|
||||
location="json",
|
||||
help="Auto-generate conversation name",
|
||||
)
|
||||
)
|
||||
|
||||
conversation_variables_parser = reqparse.RequestParser()
|
||||
conversation_variables_parser.add_argument(
|
||||
"last_id", type=uuid_value, location="args", help="Last variable ID for pagination"
|
||||
)
|
||||
conversation_variables_parser.add_argument(
|
||||
"limit", type=int_range(1, 100), required=False, default=20, location="args", help="Number of variables to return"
|
||||
conversation_variables_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("last_id", type=uuid_value, location="args", help="Last variable ID for pagination")
|
||||
.add_argument(
|
||||
"limit",
|
||||
type=int_range(1, 100),
|
||||
required=False,
|
||||
default=20,
|
||||
location="args",
|
||||
help="Number of variables to return",
|
||||
)
|
||||
)
|
||||
|
||||
conversation_variable_update_parser = reqparse.RequestParser()
|
||||
# using lambda is for passing the already-typed value without modification
|
||||
# if no lambda, it will be converted to string
|
||||
# the string cannot be converted using json.loads
|
||||
conversation_variable_update_parser.add_argument(
|
||||
"value", required=True, location="json", type=lambda x: x, help="New value for the conversation variable"
|
||||
conversation_variable_update_parser = reqparse.RequestParser().add_argument(
|
||||
# using lambda is for passing the already-typed value without modification
|
||||
# if no lambda, it will be converted to string
|
||||
# the string cannot be converted using json.loads
|
||||
"value",
|
||||
required=True,
|
||||
location="json",
|
||||
type=lambda x: x,
|
||||
help="New value for the conversation variable",
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -18,8 +18,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Define parser for file preview API
|
||||
file_preview_parser = reqparse.RequestParser()
|
||||
file_preview_parser.add_argument(
|
||||
file_preview_parser = reqparse.RequestParser().add_argument(
|
||||
"as_attachment", type=bool, required=False, default=False, location="args", help="Download as attachment"
|
||||
)
|
||||
|
||||
|
||||
@@ -26,25 +26,37 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Define parsers for message APIs
|
||||
message_list_parser = reqparse.RequestParser()
|
||||
message_list_parser.add_argument(
|
||||
"conversation_id", required=True, type=uuid_value, location="args", help="Conversation ID"
|
||||
)
|
||||
message_list_parser.add_argument("first_id", type=uuid_value, location="args", help="First message ID for pagination")
|
||||
message_list_parser.add_argument(
|
||||
"limit", type=int_range(1, 100), required=False, default=20, location="args", help="Number of messages to return"
|
||||
message_list_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("conversation_id", required=True, type=uuid_value, location="args", help="Conversation ID")
|
||||
.add_argument("first_id", type=uuid_value, location="args", help="First message ID for pagination")
|
||||
.add_argument(
|
||||
"limit",
|
||||
type=int_range(1, 100),
|
||||
required=False,
|
||||
default=20,
|
||||
location="args",
|
||||
help="Number of messages to return",
|
||||
)
|
||||
)
|
||||
|
||||
message_feedback_parser = reqparse.RequestParser()
|
||||
message_feedback_parser.add_argument(
|
||||
"rating", type=str, choices=["like", "dislike", None], location="json", help="Feedback rating"
|
||||
message_feedback_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("rating", type=str, choices=["like", "dislike", None], location="json", help="Feedback rating")
|
||||
.add_argument("content", type=str, location="json", help="Feedback content")
|
||||
)
|
||||
message_feedback_parser.add_argument("content", type=str, location="json", help="Feedback content")
|
||||
|
||||
feedback_list_parser = reqparse.RequestParser()
|
||||
feedback_list_parser.add_argument("page", type=int, default=1, location="args", help="Page number")
|
||||
feedback_list_parser.add_argument(
|
||||
"limit", type=int_range(1, 101), required=False, default=20, location="args", help="Number of feedbacks per page"
|
||||
feedback_list_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("page", type=int, default=1, location="args", help="Page number")
|
||||
.add_argument(
|
||||
"limit",
|
||||
type=int_range(1, 101),
|
||||
required=False,
|
||||
default=20,
|
||||
location="args",
|
||||
help="Number of feedbacks per page",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -42,32 +42,36 @@ from services.workflow_app_service import WorkflowAppService
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Define parsers for workflow APIs
|
||||
workflow_run_parser = reqparse.RequestParser()
|
||||
workflow_run_parser.add_argument("inputs", type=dict, required=True, nullable=False, location="json")
|
||||
workflow_run_parser.add_argument("files", type=list, required=False, location="json")
|
||||
workflow_run_parser.add_argument("response_mode", type=str, choices=["blocking", "streaming"], location="json")
|
||||
workflow_run_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("inputs", type=dict, required=True, nullable=False, location="json")
|
||||
.add_argument("files", type=list, required=False, location="json")
|
||||
.add_argument("response_mode", type=str, choices=["blocking", "streaming"], location="json")
|
||||
)
|
||||
|
||||
workflow_log_parser = reqparse.RequestParser()
|
||||
workflow_log_parser.add_argument("keyword", type=str, location="args")
|
||||
workflow_log_parser.add_argument("status", type=str, choices=["succeeded", "failed", "stopped"], location="args")
|
||||
workflow_log_parser.add_argument("created_at__before", type=str, location="args")
|
||||
workflow_log_parser.add_argument("created_at__after", type=str, location="args")
|
||||
workflow_log_parser.add_argument(
|
||||
"created_by_end_user_session_id",
|
||||
type=str,
|
||||
location="args",
|
||||
required=False,
|
||||
default=None,
|
||||
workflow_log_parser = (
|
||||
reqparse.RequestParser()
|
||||
.add_argument("keyword", type=str, location="args")
|
||||
.add_argument("status", type=str, choices=["succeeded", "failed", "stopped"], location="args")
|
||||
.add_argument("created_at__before", type=str, location="args")
|
||||
.add_argument("created_at__after", type=str, location="args")
|
||||
.add_argument(
|
||||
"created_by_end_user_session_id",
|
||||
type=str,
|
||||
location="args",
|
||||
required=False,
|
||||
default=None,
|
||||
)
|
||||
.add_argument(
|
||||
"created_by_account",
|
||||
type=str,
|
||||
location="args",
|
||||
required=False,
|
||||
default=None,
|
||||
)
|
||||
.add_argument("page", type=int_range(1, 99999), default=1, location="args")
|
||||
.add_argument("limit", type=int_range(1, 100), default=20, location="args")
|
||||
)
|
||||
workflow_log_parser.add_argument(
|
||||
"created_by_account",
|
||||
type=str,
|
||||
location="args",
|
||||
required=False,
|
||||
default=None,
|
||||
)
|
||||
workflow_log_parser.add_argument("page", type=int_range(1, 99999), default=1, location="args")
|
||||
workflow_log_parser.add_argument("limit", type=int_range(1, 100), default=20, location="args")
|
||||
|
||||
workflow_run_fields = {
|
||||
"id": fields.String,
|
||||
|
||||
Reference in New Issue
Block a user