Remove tool calling for Cohere v1

559f1b81f79b2c4e2dc68538d29ead31ed738c36

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +1 -93Showing whitespace changes
public/scripts/tool-calling.js+0 -13
@@ -461,19 +461,6 @@ export class ToolManager {
461461 }
462462 */
463463
464- /*
465- if ([chat_completion_sources.COHERE].includes(oai_settings.chat_completion_source)) {
466- if (!Array.isArray(data?.tool_calls)) {
467- return;
468- }
469-
470- for (const toolCall of data.tool_calls) {
471- const args = { name: toolCall.name, arguments: JSON.stringify(toolCall.parameters) };
472- console.log('Function tool call:', toolCall);
473- }
474- }
475- */
476-
477464 return result;
478465 }
479466
src/endpoints/backends/chat-completions.js+1 -9
@@ -4,7 +4,7 @@ const fetch = require('node-fetch').default;
44const { jsonParser } = require('../../express-common');
55const { CHAT_COMPLETION_SOURCES, GEMINI_SAFETY, BISON_SAFETY, OPENROUTER_HEADERS } = require('../../constants');
66const { forwardFetchResponse, getConfigValue, tryParse, uuidv4, mergeObjectWithYaml, excludeKeysByYaml, color } = require('../../util');
77const { convertClaudeMessages, convertGooglePrompt, convertTextCompletionPrompt, convertCohereMessages, convertMistralMessages, convertCohereTools, convertAI21Messages } = require('../../prompt-converters');
88const CohereStream = require('../../cohere-stream');
99
1010const { readSecret, SECRET_KEYS } = require('../secrets');
@@ -555,14 +555,6 @@ async function sendCohereRequest(request, response) {
555555 });
556556 }
557557
558- /*
559- if (Array.isArray(request.body.tools) && request.body.tools.length > 0) {
560- tools.push(...convertCohereTools(request.body.tools));
561- // Can't have both connectors and tools in the same request
562- connectors.splice(0, connectors.length);
563- }
564- */
565-
566558 // https://docs.cohere.com/reference/chat
567559 const requestBody = {
568560 stream: Boolean(request.body.stream),
src/prompt-converters.js+0 -71
@@ -522,76 +522,6 @@ function convertTextCompletionPrompt(messages) {
522522 return messageStrings.join('\n') + '\nassistant:';
523523}
524524
525-/**
526- * Convert OpenAI Chat Completion tools to the format used by Cohere.
527- * @param {object[]} tools OpenAI Chat Completion tool definitions
528- */
529-function convertCohereTools(tools) {
530- if (!Array.isArray(tools) || tools.length === 0) {
531- return [];
532- }
533-
534- const jsonSchemaToPythonTypes = {
535- 'string': 'str',
536- 'number': 'float',
537- 'integer': 'int',
538- 'boolean': 'bool',
539- 'array': 'list',
540- 'object': 'dict',
541- };
542-
543- const cohereTools = [];
544-
545- for (const tool of tools) {
546- if (tool?.type !== 'function') {
547- console.log(`Unsupported tool type: ${tool.type}`);
548- continue;
549- }
550-
551- const name = tool?.function?.name;
552- const description = tool?.function?.description;
553- const properties = tool?.function?.parameters?.properties;
554- const required = tool?.function?.parameters?.required;
555- const parameters = {};
556-
557- if (!name) {
558- console.log('Tool name is missing');
559- continue;
560- }
561-
562- if (!description) {
563- console.log('Tool description is missing');
564- }
565-
566- if (!properties || typeof properties !== 'object') {
567- console.log(`No properties found for tool: ${tool?.function?.name}`);
568- continue;
569- }
570-
571- for (const property in properties) {
572- const parameterDefinition = properties[property];
573- const description = parameterDefinition.description || (parameterDefinition.enum ? JSON.stringify(parameterDefinition.enum) : '');
574- const type = jsonSchemaToPythonTypes[parameterDefinition.type] || 'str';
575- const isRequired = Array.isArray(required) && required.includes(property);
576- parameters[property] = {
577- description: description,
578- type: type,
579- required: isRequired,
580- };
581- }
582-
583- const cohereTool = {
584- name: tool.function.name,
585- description: tool.function.description,
586- parameter_definitions: parameters,
587- };
588-
589- cohereTools.push(cohereTool);
590- }
591-
592- return cohereTools;
593-}
594-
595525module.exports = {
596526 convertClaudePrompt,
597527 convertClaudeMessages,
@@ -599,6 +529,5 @@ module.exports = {
599529 convertTextCompletionPrompt,
600530 convertCohereMessages,
601531 convertMistralMessages,
602- convertCohereTools,
603532 convertAI21Messages,
604533};