10
Views
1
Comments
Solved
How can I assign a variable to a MessageItem from OpenAI?
Application Type
Traditional Web, Mobile, Reactive, Service
Service Studio Version
11.54.49 (Build 63182)
Platform Version
11.26.0 (Build 41987)

I'm trying to consume the OpenAI GPT-4 Chat Consumption API (there is no plugin in Forge for it now):

https://api.openai.com/v1/chat/completions

When I create the REST call, a new type is created:

I want to assign a new element since I need to pass a JSON like this:

{ "role": "system", "content": "You are a helpful assistant." },        { "role": "user", "content": "User message goes here." }

When I try to assign a value and create a temp variable:

I cannot find a way to assign the value:

I actually would like to assign both values at once, the role and the content, but I cannot find a way to do it. I tried something like new MessageItem() { Role = "System", Content = "Message 1" }, but it also failed. Any idea what am I doing wrong? Or how should I assign them? Thanks.

2019-09-30 07-35-56
Aurelio Junior
Solution

Hello,

You have to assign values to your structure attributes separately. In your case, it would look something like this:


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.