Merge pull request #847 from trheyi/main
Refine tool call system prompt formatting and connector settings hand…
This commit is contained in:
commit
03f7fd6ca2
1 changed files with 9 additions and 8 deletions
|
|
@ -497,7 +497,8 @@ func (ast *Assistant) withPrompts(messages []chatMessage.Message) []chatMessage.
|
||||||
|
|
||||||
// Add tool_calls
|
// Add tool_calls
|
||||||
if ast.Tools != nil && ast.Tools.Tools != nil && len(ast.Tools.Tools) > 0 {
|
if ast.Tools != nil && ast.Tools.Tools != nil && len(ast.Tools.Tools) > 0 {
|
||||||
if settings, has := connectorSettings[ast.Connector]; has && !settings.Tools {
|
settings, has := connectorSettings[ast.Connector]
|
||||||
|
if !has || !settings.Tools {
|
||||||
raw, _ := jsoniter.MarshalToString(ast.Tools.Tools)
|
raw, _ := jsoniter.MarshalToString(ast.Tools.Tools)
|
||||||
messages = append(messages, *chatMessage.New().Map(map[string]interface{}{
|
messages = append(messages, *chatMessage.New().Map(map[string]interface{}{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
|
|
@ -515,13 +516,13 @@ func (ast *Assistant) withPrompts(messages []chatMessage.Message) []chatMessage.
|
||||||
messages = append(messages, *chatMessage.New().Map(map[string]interface{}{
|
messages = append(messages, *chatMessage.New().Map(map[string]interface{}{
|
||||||
"role": "system",
|
"role": "system",
|
||||||
"content": "## Tool Calls Response Rules:\n" +
|
"content": "## Tool Calls Response Rules:\n" +
|
||||||
"1. The response should be a valid JSON object.\n" +
|
"1. The response should be a valid JSON object:\n" +
|
||||||
"2. The JSON object should be wrapped by <tool_calls> and </tool_calls>.\n" +
|
" 1.1. e.g: <tool_calls>{\"arguments\":{\"assistant_id\":\"xxxx\"},\"function\":\"select_assistant\"}</tool_calls>\n" +
|
||||||
"3. The structure of the JSON object is { \"arguments\": {...}, function:\"function_name\"}\n" +
|
" 1.2. strict the example format, do not add any additional information.\n" +
|
||||||
"4. The function_name should be the name of the function defined in tool_calls.\n" +
|
" 1.3. The JSON object should be wrapped by <tool_calls> and </tool_calls>.\n" +
|
||||||
"5. The arguments should be the arguments of the function defined in tool_calls.\n" +
|
"2. The structure of the JSON object is { \"arguments\": {...}, function:\"function_name\"}\n" +
|
||||||
"6. Do not add any additional information to the response.\n" +
|
"3. The function_name should be the name of the function defined in tool_calls.\n" +
|
||||||
"7. e.g: <tool_calls>{\"arguments\":{\"assistant_id\":\"xxxx\"},\"function\":\"select_assistant\"}</tool_calls>",
|
"4. The arguments should be the arguments of the function defined in tool_calls.\n",
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// Add tool_calls prompts
|
// Add tool_calls prompts
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue