Hello guys, i want to integrate chatgpt with f&o, is there a documentation explaining step by step how it can be done?
can i have more explanation related to the forms created in the documentation, like what form design its used, and in the OpenapiquestionWindow, what data source is added etc..
my code is fixed. when i compile im getting this error:
The model element was saved with unparsable source code and cannot be used. Please edit the element in Visual Studio to fix the errors.
Let's not waste time with runtime errors if your code doesn't even compile. Fix your code, compile everything and try it again.
Also, your code is pasted in a wrong way. Please always use Insert > Code. It'll prevent the double line spacing, for instance.
i have added the parameter for apikey and heres how my code is :
when i compile i get this error:
The model element was saved with unparsable source code and cannot be used. Please edit the element in Visual Studio to fix the errors.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Globalization;
using Newtonsoft.Json;
namespace ClassOPENAPI
{
public class OpenAPIQuestions
{
public static string callOpenAI(int tokens, string input, string engine,
double temperature, int topP, int frequencyPenalty, int presencePenalty, string apikey)
{
var openAiKey = "get from Chat GPT";
var apiCall = "api.openai.com/.../" + engine + "/completions";
try
{
using (var httpClient = new HttpClient())
{
using (var request = new HttpRequestMessage(new HttpMethod("POST"), apiCall))
{
request.Headers.TryAddWithoutValidation("Authorization", "Bearer " + openAiKey);
request.Content = new StringContent("{\n \"prompt\": \"" + input + "\",\n \"temperature\": " +
temperature.ToString(CultureInfo.InvariantCulture) + ",\n \"max_tokens\": " + tokens + ",\n \"top_p\": " + topP +
",\n \"frequency_penalty\": " + frequencyPenalty + ",\n \"presence_penalty\": " + presencePenalty + "\n}");
request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application / json");
var response = httpClient.SendAsync(request).Result;
var json = response.Content.ReadAsStringAsync().Result;
dynamic dynObj = JsonConvert.DeserializeObject(json);
if (dynObj != null)
{
return dynObj.choices[0].text.ToString();
}
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return null;
}
}
}
Im following the same steps of the documentation, so what do u suggest in order to fix it?
The message is correct - your method doesn't accept such parameters. It doesn't have a parameter for the last string (apikey).
After downloading the dll file, the error is resolved and was able to build my solution. but when i go back to my x++ code, and i remove the comments from the:
// output = ClassOPENAPI.OpenAPIQuestions::callOpenAI(tokens, _question, engine,temperature,topP,frequencyPenalty,presencePenalty,apikey);
if i remove the comments i get this error message:
Method 'call OpenAI(System.Int32, System.String, System.String, System.Decimal, System.Int32, System.Int32, System.Int32, System.String)'is not found on type 'ClassOPENAPI.OpenAPIQuestions'.
You should use a search engine in such cases. For example, this thread on Stack Overflow suggest adding a reference to Microsoft.CSharp.dll. Give it a try and look for other suggestions if this one doesn't help.
after all the errors are gone, when i try to rebuild, a new error showing:
CS0656 Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'
I was able to solve the errors by choosing a higher .NET framework (4.7)
André Arnaud de Cal...
292,111
Super User 2025 Season 1
Martin Dráb
230,934
Most Valuable Professional
nmaenpaa
101,156