Skip to content

Every request to ollama ends up in "Cannot read properties of undefined (reading 'createMessageContent')" #15475

@xpomul

Description

@xpomul

Bug Description:

This seems to be a regression in Theia 1.60, introduced with #15092 (see below).
Since upgrading to Theia 1.60, every request to ollama (in the code, every call to OllamaModel.request fails with the error Cannot read properties of undefined (reading 'createMessageContent')

Steps to Reproduce:

  1. Start Theia IDE or a Theia application that includes the AI modules.
  2. Enable AI, Configure ollama (note: this does not even need a local ollama server running to reproduce), configure the chat naming agent and the Orchestrator agent to use an ollama model.
  3. Open AI Chat and enter any message.

Expected behavior:

The chat agent answers the message.

Actual behavior:

The chat view reports the error:
Cannot read properties of undefined (reading 'createMessageContent')

Additional Information

  • Operating System: MacOS, Arm64 (M1 MacBook)
  • Theia Version: Theia IDE 1.60.200

Anaylsis:

In the line

messages: request.messages.map(this.toOllamaMessage).filter(m => m !== undefined) as Message[],

and the following line, we pass methods to the map() function which causes this to be unbound when the methods are called.

This was like this already in previous versions, but only since #15092, this is referenced within toOllamaMessage() which introduces the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions