Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
c5c38267
authored
Aug 28, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: vector over range error
parent
42fec3a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
client/src/pages/api/openapi/plugin/vector.ts
+3
-2
No files found.
client/src/pages/api/openapi/plugin/vector.ts
View file @
c5c38267
...
@@ -66,14 +66,14 @@ export async function getVector({
...
@@ -66,14 +66,14 @@ export async function getVector({
...
axiosConfig
()
...
axiosConfig
()
}
}
)
)
.
then
((
res
)
=>
{
.
then
(
async
(
res
)
=>
{
if
(
!
res
.
data
?.
data
?.[
0
]?.
embedding
)
{
if
(
!
res
.
data
?.
data
?.[
0
]?.
embedding
)
{
// @ts-ignore
// @ts-ignore
return
Promise
.
reject
(
res
.
data
?.
error
?.
message
||
'Embedding Error'
);
return
Promise
.
reject
(
res
.
data
?.
error
?.
message
||
'Embedding Error'
);
}
}
return
{
return
{
tokenLen
:
res
.
data
.
usage
.
total_tokens
||
0
,
tokenLen
:
res
.
data
.
usage
.
total_tokens
||
0
,
vectors
:
res
.
data
.
data
.
map
((
item
)
=>
unityDimensional
(
item
.
embedding
))
vectors
:
await
Promise
.
all
(
res
.
data
.
data
.
map
((
item
)
=>
unityDimensional
(
item
.
embedding
)
))
};
};
});
});
...
@@ -88,6 +88,7 @@ export async function getVector({
...
@@ -88,6 +88,7 @@ export async function getVector({
}
}
function
unityDimensional
(
vector
:
number
[])
{
function
unityDimensional
(
vector
:
number
[])
{
if
(
vector
.
length
>
1536
)
return
Promise
.
reject
(
'向量维度不能超过 1536'
);
let
resultVector
=
vector
;
let
resultVector
=
vector
;
const
vectorLen
=
vector
.
length
;
const
vectorLen
=
vector
.
length
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment