{"record":{"id":"1ed0b5bdd8432544","repo":"agentscope-ai/agentscope","slug":"text-embedding-model-self-model-r-only-accepts-s","errorCode":null,"errorMessage":"Text embedding model {self.model!r} only accepts str inputs, got {type(item).__name__}.","messagePattern":"Text embedding model (.+?) only accepts str inputs, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/embedding/_dashscope/_model.py","lineNumber":345,"sourceCode":"        self,\n        inputs: list[str | DataBlock],\n        **kwargs: Any,\n    ) -> EmbeddingResponse:\n        \"\"\"Call the DashScope text embedding API for a single batch.\n\n        Args:\n            inputs (`list[str | DataBlock]`):\n                Must all be ``str``; raises ``ValueError`` otherwise.\n            **kwargs:\n                Forwarded to the API.\n\n        Returns:\n            `EmbeddingResponse`: Embedding vectors and usage info.\n        \"\"\"\n        texts: list[str] = []\n        for item in inputs:\n            if not isinstance(item, str):\n                raise ValueError(\n                    f\"Text embedding model {self.model!r} only accepts \"\n                    f\"str inputs, got {type(item).__name__}.\",\n                )\n            texts.append(item)\n\n        api_kwargs: dict[str, Any] = {\n            \"input\": texts,\n            \"model\": self.model,\n            \"dimension\": self.dimensions,\n            **kwargs,\n        }\n\n        if self.embedding_cache:\n            cached = await self.embedding_cache.retrieve(\n                identifier=api_kwargs,\n            )\n            if cached:\n                return EmbeddingResponse(","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/embedding/_dashscope/_model.py#L327-L363","documentation":"DashScope text embedding models accept only string inputs; _call_text type-checks every element of the batch and raises ValueError on the first non-str item, reporting its type name.","triggerScenarios":"Calling the model with a list containing non-str entries, e.g. bytes, DataBlock, dict, pathlib.Path, or None, via __call__ with text-mode inputs.","commonSituations":"Passing file contents read in binary mode (bytes); passing multimodal DataBlock objects to a text-only model; None values from upstream data pipelines with missing fields.","solutions":["Convert all inputs to str before calling (decode bytes, stringify paths)","Filter or default None values to \"\" if your pipeline can emit them","Use a multimodal-capable model if you need to embed images/video"],"exampleFix":"# before\nvecs = await model([b\"hello\", \"world\"])\n# after\nvecs = await model([x.decode(\"utf-8\") if isinstance(x, bytes) else str(x) for x in items])","handlingStrategy":"type-guard","validationCode":"inputs = [x.decode() if isinstance(x, bytes) else x for x in inputs]","typeGuard":"def all_str(items: list) -> bool:\\n    return all(isinstance(i, str) for i in items)","tryCatchPattern":"try:\\n    await model(texts)\\nexcept ValueError as e:\\n    if \\\"only accepts str\\\" in str(e): texts = [str(t) for t in texts]; await model(texts)\\n    else: raise","preventionTips":["Normalize to str at data-ingestion boundaries","Use a multimodal model for non-text content"],"tags":["embedding","dashscope","type-validation","input"],"backgroundTag":"invalid-input-type","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}