Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
oceanbase
提交
a8d240cf
O
oceanbase
项目概览
oceanbase
/
oceanbase
2 年多 前同步成功
通知
262
Star
6084
Fork
1301
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
a8d240cf
编写于
11月 11, 2025
作者:
O
obdev
提交者:
ob-robot
11月 11, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix error code for ai function
上级
e6ebfb49
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
116 addition
and
67 deletion
+116
-67
src/sql/engine/expr/ob_expr_ai/ob_ai_func.cpp
src/sql/engine/expr/ob_expr_ai/ob_ai_func.cpp
+1
-1
src/sql/engine/expr/ob_expr_ai/ob_ai_func_client.cpp
src/sql/engine/expr/ob_expr_ai/ob_ai_func_client.cpp
+16
-7
src/sql/engine/expr/ob_expr_ai/ob_ai_func_utils.cpp
src/sql/engine/expr/ob_expr_ai/ob_ai_func_utils.cpp
+79
-39
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_complete.cpp
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_complete.cpp
+5
-5
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_embed.cpp
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_embed.cpp
+7
-7
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_prompt.cpp
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_prompt.cpp
+2
-2
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_rerank.cpp
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_rerank.cpp
+4
-4
unittest/sql/engine/expr/test_ob_openai_utils.cpp
unittest/sql/engine/expr/test_ob_openai_utils.cpp
+2
-2
未找到文件。
src/sql/engine/expr/ob_expr_ai/ob_ai_func.cpp
浏览文件 @
a8d240cf
...
...
@@ -53,7 +53,7 @@ int ObAIFuncExprInfo::init(ObIAllocator &allocator, const ObString &model_id, sh
}
else
if
(
OB_ISNULL
(
ai_model_schema
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"ai model schema is null"
,
KR
(
ret
),
K
(
MTL_ID
()),
K
(
model_id
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"ai model not found, please check if the model exists"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"ai
_function, ai
model not found, please check if the model exists"
);
}
else
{
OZ
(
ob_write_string
(
allocator
,
ai_model_schema
->
get_name
(),
name_
));
OZ
(
ob_write_string
(
allocator
,
ai_model_schema
->
get_model_name
(),
model_
));
...
...
src/sql/engine/expr/ob_expr_ai/ob_ai_func_client.cpp
浏览文件 @
a8d240cf
...
...
@@ -85,6 +85,7 @@ int ObAIFuncClient::init(common::ObIAllocator &allocator, const common::ObString
LOG_WARN
(
"failed to convert url to cstring"
,
K
(
ret
));
}
else
{
url_
=
url_str
.
ptr
();
LOG_DEBUG
(
"ai_function, url_"
,
K
(
url_str
));
}
timeout_sec_
=
std
::
min
(
std
::
max
(
1L
,
remain_timeout_us
/
1000000
),
CURL_MAX_TIMEOUT_SEC
);
abs_timeout_ts_
=
remain_timeout_us
+
ObTimeUtility
::
current_time
();
...
...
@@ -97,6 +98,8 @@ int ObAIFuncClient::init(common::ObIAllocator &allocator, const common::ObString
}
else
if
(
OB_ISNULL
(
header_list_
=
curl_slist_append
(
header_list_
,
header_c_str
.
ptr
())))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"failed to append header"
,
K
(
ret
),
K
(
i
));
}
else
{
LOG_DEBUG
(
"ai_function, header:"
,
K
(
headers
.
at
(
i
)));
}
}
}
...
...
@@ -117,7 +120,10 @@ int ObAIFuncClient::error_handle(CURLcode res)
}
default:
{
ret
=
OB_CURL_ERROR
;
LOG_WARN
(
"curl error"
,
K
(
res
));
LOG_WARN
(
"curl error, error code is "
,
K
(
res
));
char
http_code_str
[
1024
]
=
"curl error, curl error code is "
;
snprintf
(
http_code_str
,
sizeof
(
http_code_str
),
"curl error, curlerror code is %d"
,
res
);
FORWARD_USER_ERROR
(
ret
,
http_code_str
);
break
;
}
}
...
...
@@ -145,7 +151,7 @@ int ObAIFuncClient::send_post(ObJsonObject *data, ObJsonObject *&response)
LOG_WARN
(
"fail to init easy handle"
,
K
(
ret
));
}
// retry if need
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
max_retry_times_
;
++
i
)
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
=
max_retry_times_
;
++
i
)
{
http_code
=
0
;
if
(
CURLE_OK
!=
(
res
=
curl_easy_perform
(
curl_
)))
{
LOG_WARN
(
"perform curl failed"
,
K
(
res
));
...
...
@@ -431,12 +437,13 @@ int ObAIFuncClient::init_easy_handle(CURL *curl, ObJsonObject *body, ObStringBuf
LOG_WARN
(
"fail to init curl"
,
K
(
ret
));
}
ObString
body_str
=
j_buf
.
string
();
LOG_DEBUG
(
"ai_function, body_str"
,
K
(
body_str
));
CURLcode
res
;
const
int64_t
no_delay
=
1
;
const
int64_t
no_signal
=
1
;
if
(
OB_SUCC
(
ret
))
{
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
url_
)))
{
LOG_WARN
(
"set url failed"
,
K
(
res
));
LOG_WARN
(
"set url failed"
,
K
(
res
)
,
K
(
url_
)
);
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_WRITEFUNCTION
,
ObAIFuncClient
::
write_callback
)))
{
LOG_WARN
(
"set write function failed"
,
K
(
res
));
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_WRITEDATA
,
&
response_buf
)))
{
...
...
@@ -448,19 +455,19 @@ int ObAIFuncClient::init_easy_handle(CURL *curl, ObJsonObject *body, ObStringBuf
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_CONNECTTIMEOUT_MS
,
10000
)))
{
LOG_WARN
(
"set connection timeout ms failed"
,
K
(
res
));
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_TIMEOUT
,
timeout_sec_
)))
{
LOG_WARN
(
"set timeout failed"
,
K
(
res
));
LOG_WARN
(
"set timeout failed"
,
K
(
res
)
,
K
(
timeout_sec_
)
);
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_HTTPHEADER
,
header_list_
)))
{
LOG_WARN
(
"set headers failed"
,
K
(
res
));
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
body_str
.
ptr
())))
{
LOG_WARN
(
"set post failed"
,
K
(
res
));
LOG_WARN
(
"set post failed"
,
K
(
res
)
,
K
(
body_str
.
ptr
())
);
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
body_str
.
length
())))
{
LOG_WARN
(
"set post failed"
,
K
(
res
));
LOG_WARN
(
"set post failed"
,
K
(
res
)
,
K
(
body_str
.
length
())
);
}
else
if
(
CURLE_OK
!=
(
res
=
curl_easy_setopt
(
curl
,
CURLOPT_POST
,
1
)))
{
LOG_WARN
(
"set post method failed"
,
K
(
res
));
}
if
(
CURLE_OK
!=
res
)
{
ret
=
OB_CURL_ERROR
;
LOG_WARN
(
"fail to set curl options"
,
K
(
re
s
),
K
(
res
));
LOG_WARN
(
"fail to set curl options"
,
K
(
re
t
),
K
(
res
),
K
(
body_str
.
ptr
()),
K
(
timeout_sec_
));
}
}
return
ret
;
...
...
@@ -500,6 +507,8 @@ size_t ObAIFuncClient::write_callback(void *contents, size_t size, size_t nmemb,
result
.
reserve
(
total_size
);
if
(
OB_FAIL
(
result
.
append
(
static_cast
<
const
char
*>
(
contents
),
total_size
,
0
)))
{
LOG_WARN
(
"failed to append to result"
,
K
(
ret
));
}
else
{
LOG_DEBUG
(
"ai_function, http response"
,
K
(
result
.
string
()));
}
}
return
OB_SUCC
(
ret
)
?
total_size
:
0
;
...
...
src/sql/engine/expr/ob_expr_ai/ob_ai_func_utils.cpp
浏览文件 @
a8d240cf
...
...
@@ -199,8 +199,8 @@ int ObOpenAIUtils::ObOpenAIComplete::parse_output(common::ObIAllocator &allocato
}
else
if
(
OB_FAIL
(
j_tree
->
seek
(
j_path
,
j_path
.
path_node_cnt
(),
false
,
false
,
hit
)))
{
LOG_WARN
(
"json seek failed"
,
K
(
ret
));
}
else
if
(
hit
.
size
()
==
0
)
{
ret
=
OB_
ERR_UNEXPECTED
;
LOG_WARN
(
"h
it is empty
"
,
K
(
ret
));
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"h
ttp response format is not as expected, failed to get content
"
,
K
(
ret
));
}
else
{
result
=
hit
[
0
];
}
...
...
@@ -266,23 +266,23 @@ int ObOpenAIUtils::ObOpenAIEmbed::parse_output(common::ObIAllocator &allocator,
if
(
OB_FAIL
(
ObAIFuncJsonUtils
::
get_json_array
(
allocator
,
result_array
)))
{
LOG_WARN
(
"Failed to get json array"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
data_node
=
http_response
->
get_value
(
"data"
)))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"Failed to get data"
,
K
(
ret
));
}
else
{
ObJsonArray
*
data_array
=
static_cast
<
ObJsonArray
*>
(
data_node
);
ObJsonNode
*
embedding_node
=
nullptr
;
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
data_array
->
element_count
();
i
++
)
{
if
(
OB_ISNULL
(
embedding_node
=
data_array
->
get_value
(
i
)))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"Failed to get embedding"
,
K
(
ret
));
}
else
if
(
embedding_node
->
json_type
()
!=
ObJsonNodeType
::
J_OBJECT
)
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"Failed to get embedding node"
,
K
(
ret
));
}
else
{
ObJsonObject
*
embedding_obj
=
static_cast
<
ObJsonObject
*>
(
embedding_node
);
ObJsonNode
*
embedding
=
embedding_obj
->
get_value
(
"embedding"
);
if
(
OB_ISNULL
(
embedding
))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"Failed to get embedding"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
result_array
->
append
(
embedding
)))
{
LOG_WARN
(
"Failed to append embedding"
,
K
(
ret
));
...
...
@@ -605,19 +605,19 @@ int ObDashscopeUtils::ObDashscopeComplete::parse_output(ObIAllocator &allocator,
ObJsonString
*
content_str
=
nullptr
;
ObString
response_str
;
if
(
OB_ISNULL
(
output_obj
=
static_cast
<
ObJsonObject
*>
(
http_response
->
get_value
(
"output"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"output_obj is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
choices_array
=
static_cast
<
ObJsonArray
*>
(
output_obj
->
get_value
(
"choices"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"choices_array is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
choice_obj
=
static_cast
<
ObJsonObject
*>
(
choices_array
->
get_value
(
0
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"choice_obj is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
message_obj
=
static_cast
<
ObJsonObject
*>
(
choice_obj
->
get_value
(
"message"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"message_obj is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
content_str
=
static_cast
<
ObJsonString
*>
(
message_obj
->
get_value
(
"content"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"content_str is null"
,
K
(
ret
));
}
else
{
result
=
content_str
;
...
...
@@ -701,18 +701,18 @@ int ObDashscopeUtils::ObDashscopeEmbed::parse_output(common::ObIAllocator &alloc
if
(
OB_FAIL
(
ObAIFuncJsonUtils
::
get_json_array
(
allocator
,
result_array
)))
{
LOG_WARN
(
"Failed to get json array"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
output_obj
=
static_cast
<
ObJsonObject
*>
(
http_response
->
get_value
(
"output"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"output_obj is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
embeddings_array
=
static_cast
<
ObJsonArray
*>
(
output_obj
->
get_value
(
"embeddings"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"embeddings_array is null"
,
K
(
ret
));
}
else
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
embeddings_array
->
element_count
();
++
i
)
{
if
(
OB_ISNULL
(
embedding_obj
=
static_cast
<
ObJsonObject
*>
(
embeddings_array
->
get_value
(
i
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"embedding_obj is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
embedding_array
=
static_cast
<
ObJsonArray
*>
(
embedding_obj
->
get_value
(
"embedding"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"embedding_array is null"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
result_array
->
append
(
embedding_array
)))
{
LOG_WARN
(
"Failed to append embedding array"
,
K
(
ret
));
...
...
@@ -812,10 +812,10 @@ int ObDashscopeUtils::ObDashscopeRerank::parse_output(common::ObIAllocator &allo
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"http_response is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
output_obj
=
static_cast
<
ObJsonObject
*>
(
http_response
->
get_value
(
"output"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"output_obj is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
results_array
=
static_cast
<
ObJsonArray
*>
(
output_obj
->
get_value
(
"results"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"results_array is null"
,
K
(
ret
));
}
else
{
result
=
results_array
;
...
...
@@ -891,7 +891,7 @@ int ObSiliconflowUtils::ObSiliconflowRerank::parse_output(common::ObIAllocator &
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"http_response is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
results_array
=
static_cast
<
ObJsonArray
*>
(
http_response
->
get_value
(
"results"
))))
{
ret
=
OB_
ERR_UNEXPECTED
;
ret
=
OB_
INVALID_DATA
;
LOG_WARN
(
"results_array is null"
,
K
(
ret
));
}
else
{
result
=
results_array
;
...
...
@@ -1232,7 +1232,7 @@ int ObAIFuncUtils::get_complete_provider(ObIAllocator &allocator, const ObString
if
(
provider
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"provider is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"provider is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_function,
provider is empty"
);
}
else
if
(
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
OPENAI
)
||
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
ALIYUN
)
||
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
DEEPSEEK
)
...
...
@@ -1244,7 +1244,7 @@ int ObAIFuncUtils::get_complete_provider(ObIAllocator &allocator, const ObString
}
else
{
ret
=
OB_NOT_SUPPORTED
;
LOG_WARN
(
"this provider current not support"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"this provider current
not support
"
);
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"this provider current
is
"
);
}
if
(
OB_SUCC
(
ret
)
&&
OB_ISNULL
(
complete_provider
))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
...
...
@@ -1259,7 +1259,7 @@ int ObAIFuncUtils::get_embed_provider(ObIAllocator &allocator, const ObString &p
if
(
provider
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"provider is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"provider is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_function,
provider is empty"
);
}
else
if
(
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
OPENAI
)
||
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
ALIYUN
)
||
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
HUNYUAN
)
...
...
@@ -1270,7 +1270,7 @@ int ObAIFuncUtils::get_embed_provider(ObIAllocator &allocator, const ObString &p
}
else
{
ret
=
OB_NOT_SUPPORTED
;
LOG_WARN
(
"this provider current not support"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"this provider current
not support
"
);
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"this provider current
is
"
);
}
if
(
OB_SUCC
(
ret
)
&&
OB_ISNULL
(
embed_provider
))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
...
...
@@ -1285,7 +1285,7 @@ int ObAIFuncUtils::get_rerank_provider(ObIAllocator &allocator, const ObString &
if
(
provider
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"provider is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"provider is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_function,
provider is empty"
);
}
else
if
(
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
SILICONFLOW
))
{
rerank_provider
=
OB_NEWx
(
ObSiliconflowUtils
::
ObSiliconflowRerank
,
&
allocator
);
}
else
if
(
ob_provider_check
(
provider
,
ObAIFuncProviderUtils
::
DASHSCOPE
))
{
...
...
@@ -1293,7 +1293,7 @@ int ObAIFuncUtils::get_rerank_provider(ObIAllocator &allocator, const ObString &
}
else
{
ret
=
OB_NOT_SUPPORTED
;
LOG_WARN
(
"this provider current not support"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"
this provider current not support
"
);
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"
rerank support siliconflow and ailiyun-dashscope, this provider current is
"
);
}
if
(
OB_SUCC
(
ret
)
&&
OB_ISNULL
(
rerank_provider
))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
...
...
@@ -1308,11 +1308,11 @@ int ObAIFuncUtils::check_info_type_completion(const ObAIFuncExprInfo *info)
if
(
OB_ISNULL
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info is null"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info is null"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
info is null"
);
}
else
if
(
!
is_completion_type
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not completion"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not completion"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
info type is not completion"
);
}
return
ret
;
}
...
...
@@ -1323,11 +1323,11 @@ int ObAIFuncUtils::check_info_type_dense_embedding(const ObAIFuncExprInfo *info)
if
(
OB_ISNULL
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info is null"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info is null"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
info is null"
);
}
else
if
(
!
is_dense_embedding_type
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not dense embedding"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not dense embedding"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
info type is not dense embedding"
);
}
return
ret
;
}
...
...
@@ -1338,11 +1338,11 @@ int ObAIFuncUtils::check_info_type_rerank(const ObAIFuncExprInfo *info)
if
(
OB_ISNULL
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info is null"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info is null"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
info is null"
);
}
else
if
(
!
is_rerank_type
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not rerank"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not rerank"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
info type is not rerank"
);
}
return
ret
;
}
...
...
@@ -1370,7 +1370,7 @@ int ObAIFuncUtils::get_ai_func_info(ObIAllocator &allocator, const ObString &mod
if
(
model_id
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"model_id is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model_id is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_function,
model_id is empty"
);
}
else
{
ObAIFuncExprInfo
*
info_obj
=
OB_NEWx
(
ObAIFuncExprInfo
,
(
&
allocator
),
allocator
,
T_FUN_SYS_AI_COMPLETE
);
if
(
OB_ISNULL
(
info_obj
))
{
...
...
@@ -1506,7 +1506,7 @@ int ObAIFuncModel::call_completion(ObString &prompt, ObJsonObject *config, ObStr
if
(
!
is_completion_type
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not completion"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not completion"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
info type is not completion"
);
}
else
if
(
OB_FAIL
(
ObAIFuncUtils
::
get_complete_provider
(
*
allocator_
,
endpoint_info_
.
get_provider
(),
complete_provider
)))
{
LOG_WARN
(
"Failed to get complete provider"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
endpoint_info_
.
get_unencrypted_access_key
(
*
allocator_
,
unencrypted_access_key
)))
{
...
...
@@ -1524,6 +1524,19 @@ int ObAIFuncModel::call_completion(ObString &prompt, ObJsonObject *config, ObStr
}
else
{
result
=
result_str
;
}
if
(
ret
==
OB_INVALID_DATA
)
{
ObString
response_str
;
if
(
OB_SUCCESS
==
ObAIFuncJsonUtils
::
print_json_to_str
(
*
allocator_
,
response
,
response_str
))
{
char
http_message_str
[
1024
];
snprintf
(
http_message_str
,
sizeof
(
http_message_str
),
"unexpected http message: %s"
,
response_str
.
ptr
());
ObString
ob_http_message_str
(
http_message_str
);
LOG_WARN
(
"unexpected http message"
,
K
(
ret
),
K
(
ob_http_message_str
));
FORWARD_USER_ERROR
(
ret
,
ob_http_message_str
.
ptr
());
}
else
{
LOG_WARN
(
"unexpected http message"
,
K
(
ret
));
FORWARD_USER_ERROR
(
ret
,
"unexpected http message"
);
}
}
return
ret
;
}
...
...
@@ -1544,7 +1557,7 @@ int ObAIFuncModel::call_completion_vector(ObArray<ObString> &prompts, ObJsonObje
if
(
!
is_completion_type
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not completion"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not completion"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
info type is not completion"
);
}
else
if
(
OB_FAIL
(
ObAIFuncUtils
::
get_complete_provider
(
*
allocator_
,
endpoint_info_
.
get_provider
(),
complete_provider
)))
{
LOG_WARN
(
"Failed to get complete provider"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
endpoint_info_
.
get_unencrypted_access_key
(
*
allocator_
,
unencrypted_access_key
)))
{
...
...
@@ -1589,11 +1602,11 @@ int ObAIFuncModel::call_dense_embedding(ObString &content, ObJsonObject *config,
if
(
content
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"content is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"input is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
input is empty"
);
}
else
if
(
!
is_dense_embedding_type
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not dense embedding"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not dense embedding"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
info type is not dense embedding"
);
}
else
if
(
OB_FAIL
(
contents
.
push_back
(
content
)))
{
LOG_WARN
(
"Failed to push back content"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
call_dense_embedding_vector_v2
(
contents
,
config
,
results
)))
{
...
...
@@ -1622,7 +1635,7 @@ int ObAIFuncModel::call_dense_embedding_vector(ObArray<ObString> &contents, ObJs
if
(
!
is_dense_embedding_type
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not dense embedding"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not dense embedding"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
info type is not dense embedding"
);
}
else
if
(
OB_FAIL
(
ObAIFuncUtils
::
get_embed_provider
(
*
allocator_
,
endpoint_info_
.
get_provider
(),
embed_provider
)))
{
LOG_WARN
(
"Failed to get embed provider"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
endpoint_info_
.
get_unencrypted_access_key
(
*
allocator_
,
unencrypted_access_key
)))
{
...
...
@@ -1691,7 +1704,7 @@ int ObAIFuncModel::call_dense_embedding_vector_v2(ObArray<ObString> &content, Ob
if
(
!
is_dense_embedding_type
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not dense embedding"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not dense embedding"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
info type is not dense embedding"
);
}
else
if
(
OB_FAIL
(
ObAIFuncUtils
::
get_embed_provider
(
*
allocator_
,
endpoint_info_
.
get_provider
(),
embed_provider
)))
{
LOG_WARN
(
"Failed to get embed provider"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
endpoint_info_
.
get_unencrypted_access_key
(
*
allocator_
,
unencrypted_access_key
)))
{
...
...
@@ -1719,7 +1732,7 @@ int ObAIFuncModel::call_dense_embedding_vector_v2(ObArray<ObString> &content, Ob
}
else
if
(
dimension
>
0
&&
static_cast
<
ObJsonArray
*>
(
j_base
)
->
element_count
()
!=
dimension
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"result array is not equal to dimension"
,
K
(
ret
),
K
(
dimension
),
K
(
static_cast
<
ObJsonArray
*>
(
j_base
)
->
element_count
()));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"result dimension is not equal to dimension"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
result dimension is not equal to dimension"
);
}
else
if
(
OB_FAIL
(
ObAIFuncJsonUtils
::
print_json_to_str
(
*
allocator_
,
j_base
,
result_str
)))
{
LOG_WARN
(
"Failed to print json to string"
,
K
(
ret
));
}
else
{
...
...
@@ -1728,6 +1741,19 @@ int ObAIFuncModel::call_dense_embedding_vector_v2(ObArray<ObString> &content, Ob
}
}
}
if
(
ret
==
OB_INVALID_DATA
)
{
ObString
response_str
;
if
(
OB_SUCCESS
==
ObAIFuncJsonUtils
::
print_json_to_str
(
*
allocator_
,
response
,
response_str
))
{
char
http_message_str
[
1024
];
snprintf
(
http_message_str
,
sizeof
(
http_message_str
),
"unexpected http message: %s"
,
response_str
.
ptr
());
ObString
ob_http_message_str
(
http_message_str
);
LOG_WARN
(
"unexpected http message"
,
K
(
ret
),
K
(
ob_http_message_str
));
FORWARD_USER_ERROR
(
ret
,
ob_http_message_str
.
ptr
());
}
else
{
LOG_WARN
(
"unexpected http message"
,
K
(
ret
));
FORWARD_USER_ERROR
(
ret
,
"unexpected http message"
);
}
}
return
ret
;
}
...
...
@@ -1745,7 +1771,7 @@ int ObAIFuncModel::call_rerank(ObString &query, ObJsonArray *contents, ObJsonArr
if
(
!
is_rerank_type
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"info type is not rerank"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"info type is not rerank"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
info type is not rerank"
);
}
else
if
(
OB_FAIL
(
ObAIFuncUtils
::
get_rerank_provider
(
*
allocator_
,
endpoint_info_
.
get_provider
(),
rerank_provider
)))
{
LOG_WARN
(
"Failed to get rerank provider"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
endpoint_info_
.
get_unencrypted_access_key
(
*
allocator_
,
unencrypted_access_key
)))
{
...
...
@@ -1761,6 +1787,20 @@ int ObAIFuncModel::call_rerank(ObString &query, ObJsonArray *contents, ObJsonArr
}
else
{
results
=
static_cast
<
ObJsonArray
*>
(
result_base
);
}
if
(
ret
==
OB_INVALID_DATA
)
{
ObString
response_str
;
if
(
OB_SUCCESS
==
ObAIFuncJsonUtils
::
print_json_to_str
(
*
allocator_
,
response
,
response_str
))
{
char
http_message_str
[
1024
];
snprintf
(
http_message_str
,
sizeof
(
http_message_str
),
"unexpected http message: %s"
,
response_str
.
ptr
());
ObString
ob_http_message_str
(
http_message_str
);
LOG_WARN
(
"unexpected http message"
,
K
(
ret
),
K
(
ob_http_message_str
));
FORWARD_USER_ERROR
(
ret
,
ob_http_message_str
.
ptr
());
}
else
{
LOG_WARN
(
"unexpected http message"
,
K
(
ret
));
FORWARD_USER_ERROR
(
ret
,
"unexpected http message"
);
}
}
return
ret
;
}
...
...
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_complete.cpp
浏览文件 @
a8d240cf
...
...
@@ -93,7 +93,7 @@ int ObExprAIComplete::eval_ai_complete(const ObExpr &expr,
}
else
if
(
arg_model_id
->
is_null
()
||
arg_prompt
->
is_null
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"parameters is null"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"parameters is null"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
parameters is null"
);
res
.
set_null
();
}
else
{
ObEvalCtx
::
TempAllocGuard
tmp_alloc_g
(
ctx
);
...
...
@@ -125,12 +125,12 @@ int ObExprAIComplete::eval_ai_complete(const ObExpr &expr,
}
else
if
(
!
ObAIFuncPromptObjectUtils
::
is_valid_prompt_object
(
prompt_object
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"prompt is not valid"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"prompt is not valid"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
prompt is not valid"
);
res
.
set_null
();
}
else
if
(
!
ObAIFuncJsonUtils
::
ob_is_json_array_all_str
(
static_cast
<
ObJsonArray
*>
(
prompt_object
->
get_value
(
ObAIFuncPromptObjectUtils
::
prompt_args_key
))))
{
ret
=
OB_NOT_SUPPORTED
;
LOG_WARN
(
"prompt object is not support"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"prompt object
is not support
"
);
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"prompt object
current is
"
);
}
else
if
(
OB_FAIL
(
ObAIFuncPromptObjectUtils
::
replace_all_str_args_in_template
(
temp_allocator
,
prompt_object
,
prompt
)))
{
LOG_WARN
(
"fail to replace all str args in template"
,
K
(
ret
));
}
...
...
@@ -151,7 +151,7 @@ int ObExprAIComplete::eval_ai_complete(const ObExpr &expr,
}
else
if
(
model_id
.
empty
()
||
prompt
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"model id or input is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model id or input is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
model id or input is empty"
);
res
.
set_null
();
}
...
...
@@ -291,7 +291,7 @@ int ObExprAIComplete::get_vector_params(const ObExpr &expr,
}
else
if
(
prompt
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"input is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"input is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_complete,
input is empty"
);
res_vec
->
set_null
(
idx
);
}
else
if
(
OB_FAIL
(
prompts
.
push_back
(
prompt
)))
{
LOG_WARN
(
"fail to push back prompt"
,
K
(
ret
),
K
(
idx
));
...
...
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_embed.cpp
浏览文件 @
a8d240cf
...
...
@@ -61,7 +61,7 @@ int ObExprAIEmbed::calc_result_typeN(ObExprResType &type,
}
else
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"dimension parameter must be an integer, not a decimal or float"
,
K
(
ret
),
K
(
types_stack
[
DIM_IDX
].
get_type
()));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"dimension parameter must be an integer, not a decimal or float"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
dimension parameter must be an integer, not a decimal or float"
);
}
}
type
.
set_varchar
();
...
...
@@ -83,7 +83,7 @@ int ObExprAIEmbed::eval_ai_embed(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &re
}
else
if
(
arg_model_id
->
is_null
()
||
arg_content
->
is_null
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"model id or content is null"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model id or content is null"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
model id or content is null"
);
res
.
set_null
();
}
else
{
ObEvalCtx
::
TempAllocGuard
tmp_alloc_g
(
ctx
);
...
...
@@ -99,7 +99,7 @@ int ObExprAIEmbed::eval_ai_embed(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &re
if
(
model_id
.
empty
()
||
content
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"model id or input is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model id or input is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
model id or input is empty"
);
res
.
set_null
();
}
int64_t
dim
=
0
;
...
...
@@ -111,7 +111,7 @@ int ObExprAIEmbed::eval_ai_embed(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &re
if
(
dim
<=
0
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"dimension parameter must be a positive integer"
,
K
(
ret
),
K
(
dim
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"dimension parameter must be a positive integer"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
dimension parameter must be a positive integer"
);
res
.
set_null
();
}
else
if
(
OB_FAIL
(
ObAIFuncJsonUtils
::
get_json_object
(
temp_allocator
,
config
)))
{
LOG_WARN
(
"fail to get json object"
,
K
(
ret
));
...
...
@@ -185,7 +185,7 @@ int ObExprAIEmbed::get_vector_params(const ObExpr &expr,
if
(
dim
<=
0
)
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"dimension parameter must be a positive integer"
,
K
(
ret
),
K
(
dim
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"dimension parameter must be a positive integer"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
dimension parameter must be a positive integer"
);
}
}
if
(
OB_SUCC
(
ret
))
{
...
...
@@ -206,7 +206,7 @@ int ObExprAIEmbed::get_vector_params(const ObExpr &expr,
}
else
if
(
content
.
empty
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"input is empty"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"input is empty"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
input is empty"
);
}
else
if
(
OB_FAIL
(
contents
.
push_back
(
content
)))
{
LOG_WARN
(
"fail to push back content"
,
K
(
ret
),
K
(
idx
));
}
...
...
@@ -330,7 +330,7 @@ int ObExprAIEmbed::eval_ai_embed_vector(const ObExpr &expr, ObEvalCtx &ctx,
}
else
if
(
!
ObAIFuncUtils
::
is_dense_embedding_type
(
info
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"model type must be DENSE_EMBEDDING"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model type must be DENSE_EMBEDDING"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_embed,
model type must be DENSE_EMBEDDING"
);
}
else
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
contents
.
count
();
++
i
)
{
ObArray
<
ObString
>
contents_array
;
...
...
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_prompt.cpp
浏览文件 @
a8d240cf
...
...
@@ -64,7 +64,7 @@ int ObExprAIPrompt::calc_result_typeN(ObExprResType &type,
}
else
if
(
ob_is_json
(
types_stack
[
i
].
get_type
()))
{
ret
=
OB_NOT_SUPPORTED
;
LOG_WARN
(
"json type is not supported"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"json type
is not supported
"
);
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"json type
current is
"
);
}
else
{
ret
=
OB_ERR_INVALID_TYPE_FOR_OP
;
LOG_WARN
(
"invalid data type"
,
K
(
ret
),
K
(
types_stack
[
i
].
get_type
()));
...
...
@@ -121,7 +121,7 @@ int ObExprAIPrompt::eval_ai_prompt(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &
}
else
if
(
ob_is_json
(
arg
->
datum_meta_
.
type_
))
{
ret
=
OB_NOT_SUPPORTED
;
LOG_WARN
(
"json type is not supported"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"json type
is not supported
"
);
LOG_USER_ERROR
(
OB_NOT_SUPPORTED
,
"json type
current is
"
);
}
else
if
(
datum
->
is_null
())
{
ret
=
OB_ERR_INVALID_TYPE_FOR_OP
;
LOG_WARN
(
"invalid data type"
,
K
(
ret
),
K
(
arg
->
datum_meta_
.
type_
));
...
...
src/sql/engine/expr/ob_expr_ai/ob_expr_ai_rerank.cpp
浏览文件 @
a8d240cf
...
...
@@ -54,11 +54,11 @@ int ObExprAIRerank::calc_result_typeN(ObExprResType &type,
if
(
!
ob_is_string_tc
(
types_stack
[
MODEL_IDX
].
get_type
()))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid param type"
,
K
(
ret
),
K
(
types_stack
[
MODEL_IDX
]));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model key must be string type"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
model key must be string type"
);
}
else
if
(
!
ob_is_string_tc
(
types_stack
[
QUERY_IDX
].
get_type
()))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid param type"
,
K
(
ret
),
K
(
types_stack
[
QUERY_IDX
]));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"query must be string type"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
query must be string type"
);
}
else
{
types_stack
[
MODEL_IDX
].
set_calc_collation_type
(
CS_TYPE_UTF8MB4_BIN
);
types_stack
[
QUERY_IDX
].
set_calc_collation_type
(
CS_TYPE_UTF8MB4_BIN
);
...
...
@@ -82,7 +82,7 @@ int ObExprAIRerank::calc_result_typeN(ObExprResType &type,
}
else
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid param type"
,
K
(
ret
),
K
(
types_stack
[
DOC_KEY_IDX
]));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"doc key must be string type"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
doc key must be string type"
);
}
}
...
...
@@ -106,7 +106,7 @@ int ObExprAIRerank::eval_ai_rerank(const ObExpr &expr, ObEvalCtx &ctx, ObDatum &
}
else
if
(
arg_model_id
->
is_null
()
||
arg_query
->
is_null
()
||
arg_documents
->
is_null
())
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"model id or query or documents is null"
,
K
(
ret
));
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"model id or query or documents is null"
);
LOG_USER_ERROR
(
OB_INVALID_ARGUMENT
,
"
ai_rerank,
model id or query or documents is null"
);
res
.
set_null
();
}
else
{
ObEvalCtx
::
TempAllocGuard
tmp_alloc_g
(
ctx
);
...
...
unittest/sql/engine/expr/test_ob_openai_utils.cpp
浏览文件 @
a8d240cf
...
...
@@ -177,7 +177,7 @@ TEST_F(ObOpenAIUtilsTest, test_complete_parse_output_empty)
ASSERT_EQ
(
OB_SUCCESS
,
ObJsonBaseFactory
::
get_json_base
(
&
allocator
,
response
,
ObJsonInType
::
JSON_TREE
,
ObJsonInType
::
JSON_TREE
,
j_base
));
ObJsonObject
*
http_response
=
static_cast
<
ObJsonObject
*>
(
j_base
);
ObIJsonBase
*
result
=
nullptr
;
ASSERT_EQ
(
OB_
ERR_UNEXPECTED
,
completion
.
parse_output
(
allocator
,
http_response
,
result
));
ASSERT_EQ
(
OB_
INVALID_DATA
,
completion
.
parse_output
(
allocator
,
http_response
,
result
));
}
TEST_F
(
ObOpenAIUtilsTest
,
test_embedding_get_header
)
...
...
@@ -279,7 +279,7 @@ TEST_F(ObOpenAIUtilsTest, test_embedding_parse_output_empty)
ASSERT_EQ
(
OB_SUCCESS
,
ObJsonBaseFactory
::
get_json_base
(
&
allocator
,
response
,
ObJsonInType
::
JSON_TREE
,
ObJsonInType
::
JSON_TREE
,
j_base
));
ObJsonObject
*
http_response
=
static_cast
<
ObJsonObject
*>
(
j_base
);
ObIJsonBase
*
result
=
nullptr
;
ASSERT_EQ
(
OB_
ERR_UNEXPECTED
,
embedding
.
parse_output
(
allocator
,
http_response
,
result
));
ASSERT_EQ
(
OB_
INVALID_DATA
,
embedding
.
parse_output
(
allocator
,
http_response
,
result
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录