Skip to content

Commit

Permalink
🐛 fix: fix tool call error with gpt-4-turbo (lobehub#2042)
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx authored Apr 14, 2024
1 parent 3a771df commit 63d91b8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/config/modelProviders/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const OpenAI: ModelProviderCard = {
},
{
description: 'GPT-4 Turbo 视觉版',
displayName: 'GPT-4 Turbo Vision',
displayName: 'GPT-4 Turbo',
enabled: true,
functionCall: true,
id: 'gpt-4-turbo',
Expand Down
28 changes: 27 additions & 1 deletion src/store/tool/selectors/tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ const mockState = {
identifier: 'plugin-3',
manifest: {
identifier: 'plugin-3',
api: [{ name: 'api-3' }],
api: [
{
name: 'api-3',
url: 'bac',
description: '123123',
parameters: { type: 'object', properties: { a: { type: 'string' } } },
},
],
},
type: 'customPlugin',
},
Expand Down Expand Up @@ -132,6 +139,25 @@ describe('toolSelectors', () => {
const result = toolSelectors.enabledSchema([])(mockState);
expect(result).toEqual([]);
});

// fix https://github.com/lobehub/lobe-chat/issues/2036
it('should not contain url', () => {
const result = toolSelectors.enabledSchema(['plugin-3'])(mockState);
expect(result[0].function).toEqual({
description: '123123',
name: 'plugin-3____api-3',
parameters: {
properties: {
a: {
type: 'string',
},
},
type: 'object',
},
});

expect(result[0].function).not.toHaveProperty('url');
});
});

describe('getPluginManifestLoadingStatus', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/store/tool/selectors/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ const enabledSchema =
.filter((m) => tools.includes(m?.identifier))
.flatMap((manifest) =>
manifest.api.map((m) => ({
...m,
description: m.description,
name: getAPIName(manifest.identifier, m.name, manifest.type),
parameters: m.parameters,
})),
);

Expand Down

0 comments on commit 63d91b8

Please sign in to comment.