Skip to content

Completion error: Cannot read properties of undefined (reading 'trim') #9

@mixerthebeardman

Description

@mixerthebeardman

Tried several OpenAI models and using each of them I get the same error:
TypeError: Cannot read properties of undefined (reading 'trim')

const it = [{ role: "user", content: Wt }]; Xt("Generating completion..."), Et.create({ model: bn, messages: it, temperature: Br, maxTokens: sn }).then(ht=>{ yn(ht?.choices[0]?.text.trim()), mr(ht?.choices[0]?.finish_reason) } ).finally(()=>{ Xt("Generate") } )

OpenAI chat completion response is valid:
{ "id": "chatcmpl-9XrZqgnCuP2Nf6r8Cg4VEsCCIaTQY", "object": "chat.completion", "created": 1717857802, "model": "gpt-3.5-turbo-0125", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Dubrovnik is a picturesque coastal city located in southern Croatia bordering the Adriatic Sea. It is known for its stunning medieval architecture, well-preserved city walls, and beautiful waterfront setting. Dubrovnik is a popular tourist destination, attracting visitors from around the world to explore its historic Old Town, which is a UNESCO World Heritage Site.\n\nThe city has a rich history, with traces of its past visible in the many churches, palaces, and fortresses that dot the landscape. One of the most iconic landmarks in Dubrovnik is the massive city walls that encircle the Old Town, offering panoramic views of the city and sea.\n\nIn addition to its cultural and historical attractions, Dubrovnik also offers a variety of outdoor activities such as swimming, sailing, and kayaking. The nearby islands of Lokrum and Mljet are popular day trip destinations for visitors looking to explore the stunning natural beauty of the region.\n\nOverall, Dubrovnik is a charming and enchanting city that offers a perfect blend of history, culture, and natural beauty, making it a must-visit destination for any traveler." }, "logprobs": null, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 13, "completion_tokens": 223, "total_tokens": 236 }, "system_fingerprint": null }

STRAPI VERSION
v4.24.5
NODE VERSION
v18.20.3
PLUGIN VERSION
1.0.3

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