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
89ab17ea
authored
Apr 26, 2024
by
Archer
Committed by
GitHub
Apr 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: tool value type and complections body size (#1291)
parent
c608f861
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
6 deletions
+47
-6
packages/service/core/workflow/dispatch/agent/runTool/functionCall.ts
+14
-2
packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts
+30
-3
packages/service/core/workflow/dispatch/tools/http468.ts
+2
-1
projects/app/src/pages/api/common/file/uploadImage.ts
+1
-0
No files found.
packages/service/core/workflow/dispatch/agent/runTool/functionCall.ts
View file @
89ab17ea
...
@@ -56,7 +56,7 @@ export const runToolWithFunctionCall = async (
...
@@ -56,7 +56,7 @@ export const runToolWithFunctionCall = async (
>
=
{};
>
=
{};
item
.
toolParams
.
forEach
((
item
)
=>
{
item
.
toolParams
.
forEach
((
item
)
=>
{
properties
[
item
.
key
]
=
{
properties
[
item
.
key
]
=
{
type
:
'string'
,
type
:
item
.
valueType
||
'string'
,
description
:
item
.
toolDescription
||
''
description
:
item
.
toolDescription
||
''
};
};
});
});
...
@@ -76,6 +76,18 @@ export const runToolWithFunctionCall = async (
...
@@ -76,6 +76,18 @@ export const runToolWithFunctionCall = async (
messages
,
messages
,
maxTokens
:
toolModel
.
maxContext
-
500
// filter token. not response maxToken
maxTokens
:
toolModel
.
maxContext
-
500
// filter token. not response maxToken
});
});
const
formativeMessages
=
filterMessages
.
map
((
item
)
=>
{
if
(
item
.
role
===
ChatCompletionRequestMessageRoleEnum
.
Assistant
&&
item
.
function_call
)
{
return
{
...
item
,
function_call
:
{
name
:
item
.
function_call
?.
name
,
arguments
:
item
.
function_call
?.
arguments
}
};
}
return
item
;
});
/* Run llm */
/* Run llm */
const
ai
=
getAIApi
({
const
ai
=
getAIApi
({
...
@@ -87,7 +99,7 @@ export const runToolWithFunctionCall = async (
...
@@ -87,7 +99,7 @@ export const runToolWithFunctionCall = async (
model
:
toolModel
.
model
,
model
:
toolModel
.
model
,
temperature
:
0
,
temperature
:
0
,
stream
,
stream
,
messages
:
f
ilter
Messages
,
messages
:
f
ormative
Messages
,
functions
,
functions
,
function_call
:
'auto'
function_call
:
'auto'
},
},
...
...
packages/service/core/workflow/dispatch/agent/runTool/toolChoice.ts
View file @
89ab17ea
...
@@ -63,7 +63,7 @@ export const runToolWithToolChoice = async (
...
@@ -63,7 +63,7 @@ export const runToolWithToolChoice = async (
>
=
{};
>
=
{};
item
.
toolParams
.
forEach
((
item
)
=>
{
item
.
toolParams
.
forEach
((
item
)
=>
{
properties
[
item
.
key
]
=
{
properties
[
item
.
key
]
=
{
type
:
'string'
,
type
:
item
.
valueType
||
'string'
,
description
:
item
.
toolDescription
||
''
description
:
item
.
toolDescription
||
''
};
};
});
});
...
@@ -86,7 +86,34 @@ export const runToolWithToolChoice = async (
...
@@ -86,7 +86,34 @@ export const runToolWithToolChoice = async (
messages
,
messages
,
maxTokens
:
toolModel
.
maxContext
-
300
// filter token. not response maxToken
maxTokens
:
toolModel
.
maxContext
-
300
// filter token. not response maxToken
});
});
const
formativeMessages
=
filterMessages
.
map
((
item
)
=>
{
if
(
item
.
role
===
'assistant'
&&
item
.
tool_calls
)
{
return
{
...
item
,
tool_calls
:
item
.
tool_calls
.
map
((
tool
)
=>
({
id
:
tool
.
id
,
type
:
tool
.
type
,
function
:
tool
.
function
}))
};
}
return
item
;
});
// console.log(
// JSON.stringify(
// {
// ...toolModel?.defaultConfig,
// model: toolModel.model,
// temperature: 0,
// stream,
// messages: formativeMessages,
// tools,
// tool_choice: 'auto'
// },
// null,
// 2
// )
// );
/* Run llm */
/* Run llm */
const
ai
=
getAIApi
({
const
ai
=
getAIApi
({
timeout
:
480000
timeout
:
480000
...
@@ -97,7 +124,7 @@ export const runToolWithToolChoice = async (
...
@@ -97,7 +124,7 @@ export const runToolWithToolChoice = async (
model
:
toolModel
.
model
,
model
:
toolModel
.
model
,
temperature
:
0
,
temperature
:
0
,
stream
,
stream
,
messages
:
f
ilter
Messages
,
messages
:
f
ormative
Messages
,
tools
,
tools
,
tool_choice
:
'auto'
tool_choice
:
'auto'
},
},
...
...
packages/service/core/workflow/dispatch/tools/http468.ts
View file @
89ab17ea
...
@@ -149,7 +149,8 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
...
@@ -149,7 +149,8 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise<H
headers
:
Object
.
keys
(
headers
).
length
>
0
?
headers
:
undefined
,
headers
:
Object
.
keys
(
headers
).
length
>
0
?
headers
:
undefined
,
httpResult
:
rawResponse
httpResult
:
rawResponse
},
},
[
DispatchNodeResponseKeyEnum
.
toolResponses
]:
results
,
[
DispatchNodeResponseKeyEnum
.
toolResponses
]:
Object
.
keys
(
results
).
length
>
0
?
results
:
rawResponse
,
[
NodeOutputKeyEnum
.
httpRawResponse
]:
rawResponse
,
[
NodeOutputKeyEnum
.
httpRawResponse
]:
rawResponse
,
...
results
...
results
};
};
...
...
projects/app/src/pages/api/common/file/uploadImage.ts
View file @
89ab17ea
...
@@ -28,6 +28,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
...
@@ -28,6 +28,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
export
const
config
=
{
export
const
config
=
{
api
:
{
api
:
{
sizeLimit
:
'10mb'
,
bodyParser
:
{
bodyParser
:
{
sizeLimit
:
'16mb'
sizeLimit
:
'16mb'
}
}
...
...
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