-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Issue Report for elizaos-plugins/plugin-telegram
1. Describe the bug
The @elizaos/plugin-telegram crashes when a user uploads an image "as a photo" via the Telegram client (as opposed to sending it "as a file"). The internal processImage function within the plugin's messageManager.ts calls runtime.useModel(ModelType.IMAGE_DESCRIPTION, ...) with incorrect parameters. It passes a raw string (imageUrl) as the second argument, but the useModel function for IMAGE_DESCRIPTION expects an object (ImageDescriptionParams). This results in a TypeError: paramsObj is not an Object. which halts all further message processing.
2. To Reproduce
Steps to reproduce the behavior:
- Set up an ElizaOS project with
@elizaos/plugin-telegram. - Ensure a model provider that can handle
ModelType.IMAGE_DESCRIPTIONis configured (e.g.,@elizaos/plugin-google-genaiwithGOOGLE_IMAGE_MODELset). - Start the ElizaOS server (
elizaos dev). - In a Telegram chat with the bot, send an image by selecting it as a "Photo" (using the compressed/gallery option), not as a "File".
- Observe the server logs. The application will throw a
TypeErrorand likely fail to respond to the message.
3. Expected behavior
The processImage function should not crash. It should successfully call runtime.useModel with the correct parameters, receive an image description, and create a valid attachment object that can be passed to the main message processing pipeline.
4. Logs
Here is the relevant stack trace from the crash:
❌ Error processing image: TypeError: paramsObj is not an Object. (evaluating '"prompt" in paramsObj')
at useModel (.../node_modules/@elizaos/core/dist/node/index.node.js:48866:53)
at processImage (.../node_modules/@elizaos/plugin-telegram/dist/index.js:207:59)
at async processMessage (.../node_modules/@elizaos/plugin-telegram/dist/index.js:431:36)
...```
**5. Suggested Fix**
The call to `useModel` inside the `processImage` function in `plugin-telegram/src/messageManager.ts` needs to be updated to match the expected `ImageDescriptionParams` interface.
The current implementation is:
```typescript
const { title, description } = await this.runtime.useModel(
ModelType.IMAGE_DESCRIPTION,
imageUrl
);
This should be changed to pass an object, and it should also include the user's caption as the prompt for better contextual analysis:
const { title, description } = await this.runtime.useModel(
ModelType.IMAGE_DESCRIPTION,
{
imageUrl: imageUrl,
prompt: message.caption || "Describe this image."
}
);This change aligns the function call with the core @elizaos/core type definitions and resolves the TypeError.