Well, assuming that your statement is correct, and I do believe that it works on your side, then I don’t know then how to explain this - the same code is used in both cases - the short content of the “system” role works fine but the long produces Bad request. The same user content is used which is very short (two words).
and BTW, I do not provide any Assistant role…
So here it is again:
The C# code:
string jsonContent = JsonConvert.SerializeObject(request, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore });
var stringContent = new StringContent(jsonContent, UnicodeEncoding.UTF8, "application/json");
string url = String.Format("{0}/chat/completions", Api.BaseUrl);
Log.VerboseFormat("Calling SendAsync with URL: {0}, and Engine: {1}", url, request.Model);
using (HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, url))
{
req.Content = stringContent;
req.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Api.Auth.ApiKey);
req.Headers.Add("Accept", "application/json");
req.Headers.Add("User-Agent", "GSS/OpenAI_GPT3");
var response = await client.SendAsync(req, HttpCompletionOption.ResponseHeadersRead);
if (response.IsSuccessStatusCode)
I comprise a short “content” for “system” that looks like that and produces nice result.
{“messages”:[{“role”:“system”,“content”:“You are a professional writer tasked with creating engaging articles, blogs, and descriptions based on user prompts.”},{“role”:“user”,“content”:“Traveling Canada”}],“model”:“gpt-3.5-turbo”,“max_tokens”:4000,“temperature”:0.9,“top_p”:1.0,“presence_penalty”:0.5,“frequency_penalty”:0.5,“n”:1,“stream”:true}
Then I comprise a longer “content” for the “system” role that looks like that, but produces Bad Request response (400).
{“messages”:[{“role”:“system”,“content”:“You are a writer tasked with creating engaging articles, blogs, and descriptions based on user prompts. Your goal is to use your creativity and writing skills to craft compelling content that captures the user’s attention and provides them with valuable information. Think about how you can use storytelling techniques, descriptive language, and a clear writing style to bring your articles to life and engage your readers. Whether you’re writing a product description or a blog post, your writing should inform, entertain, and leave a lasting impression on your audience. So, how will you use your writing skills to craft content that resonates with your readers and achieves your client’s goals?”},{“role”:“user”,“content”:“Traveling Canada”}],“model”:“gpt-3.5-turbo”,“max_tokens”:4000,“temperature”:0.9,“top_p”:1.0,“presence_penalty”:0.5,“frequency_penalty”:0.5,“n”:1,“stream”:true}
Both of them are the ‘jsonContent’ string of the code.
I compared two and both look valid.
That brought me to the question what I am doing wrong here, because ruby_coder says it works on his side (in a different language, I presume, and seems with different parameters…).