{"record":{"id":"3234fe6ac65205a7","repo":"HKUDS/DeepTutor","slug":"cohere-v2-does-not-support-content-type-kind","errorCode":null,"errorMessage":"Cohere v2 does not support content type '{kind}'","messagePattern":"Cohere v2 does not support content type '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/embedding/adapters/cohere.py","lineNumber":114,"sourceCode":"\n            if request.contents:\n                # Cohere v2 multimodal: `inputs: [{content: [{type, text|image_url}]}]`\n                # We translate the simple [{text|image|video}] contract into v2's\n                # nested form. v2 cannot mix text+image in one input, so each\n                # content dict becomes its own input item.\n                inputs = []\n                for item in request.contents:\n                    if not isinstance(item, dict):\n                        continue\n                    kind, value = next(iter(item.items()))\n                    if kind == \"text\":\n                        inputs.append({\"content\": [{\"type\": \"text\", \"text\": value}]})\n                    elif kind == \"image\":\n                        inputs.append(\n                            {\"content\": [{\"type\": \"image_url\", \"image_url\": {\"url\": value}}]}\n                        )\n                    else:\n                        raise ValueError(f\"Cohere v2 does not support content type '{kind}'\")\n                payload[\"inputs\"] = inputs\n            else:\n                payload[\"texts\"] = request.texts\n\n            supported_dims = model_info.get(\"dimensions\", [])\n            if isinstance(supported_dims, list) and len(supported_dims) > 1:\n                payload[\"output_dimension\"] = dimension or model_info.get(\"default\")\n\n            if not request.truncate:\n                payload[\"truncate\"] = \"NONE\"\n\n        url = self.base_url\n\n        logger.debug(f\"Sending embedding request to {url} with {len(request.texts)} texts\")\n\n        async with httpx.AsyncClient(\n            timeout=self.request_timeout, verify=not disable_ssl_verify_enabled()\n        ) as client:","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/embedding/adapters/cohere.py#L96-L132","documentation":"While mapping multimodal contents to Cohere v2 inputs, the adapter handles only 'text' and 'image' kinds; any other content kind (audio, video, generic 'file') raises with the offending kind. Cohere's embed-v4.0 input schema accepts text and image_url parts only.","triggerScenarios":"EmbeddingRequest(contents=[{\"kind\": \"audio\", ...}]) or kind='file'/'video' passed to the Cohere v2 adapter's embed().","commonSituations":"Sharing a generic multimodal request builder across providers where another provider accepts audio; upstream pipelines adding new content kinds that reach the Cohere adapter.","solutions":["Filter contents to text/image parts before calling the Cohere adapter","Route non-text/image modalities to a provider whose SDK supports them (e.g. DashScope multimodal)","Reject unsupported kinds at request-build time with a clear error instead of deep in the adapter"],"exampleFix":"# before\ncontents = all_parts  # includes {\"kind\": \"audio\", ...}\nawait cohere.embed(EmbeddingRequest(contents=contents))\n# after\nsupported = [p for p in all_parts if p[\"kind\"] in (\"text\", \"image\")]\nawait cohere.embed(EmbeddingRequest(contents=supported))","handlingStrategy":"type-guard","validationCode":"ALLOWED = {\"text\", \"image\"}\ncontents = [p for p in contents if p[\"kind\"] in ALLOWED]","typeGuard":"def is_cohere_content(part: dict) -> bool:\n    return part.get(\"kind\") in (\"text\", \"image\")","tryCatchPattern":"try:\n    await adapter.embed(req)\nexcept ValueError as e:\n    if \"does not support content type\" in str(e):\n        req = replace(req, contents=[p for p in req.contents if p[\"kind\"] in (\"text\", \"image\")])\n        return await adapter.embed(req)\n    raise","preventionTips":["Advertise per-provider modality support and route accordingly","Reject unsupported kinds at request-build time"],"tags":["cohere","embeddings","multimodal","content-type"],"backgroundTag":"unsupported-content-type","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}