Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify system message separately from user for the request? #46

Open
lofti198 opened this issue Mar 12, 2024 · 1 comment
Open

Comments

@lofti198
Copy link

I am using code as below:

 ChatGptOptions options = new ChatGptOptions()
 {
     BaseUrl = "https://api.openai.com", // The base URL for the OpenAI API
     Model = "gpt-3.5-turbo",           // The specific model to use
     Temperature = 0.7,                   // Controls randomness in the response (0-1)
     TopP = 0.9,                         // Controls diversity in the response (0-1)
     MaxTokens = 3500,                   // The maximum number of tokens in the response
     Stop = null,       // Sequence of tokens that will stop generation
     PresencePenalty = 0.0,              // Penalizes new tokens based on their existing presence in the context
     FrequencyPenalty = 0.0              // Penalizes new tokens based on their frequency in the context
 };

 var openai = new ChatGpt(openAiKey, options);
 var fixedSentence = await openai.Ask($"{instruction}: {data}");
 return fixedSentence;

However cant get how to speficy system message separately. For example I want to ask to rephrase user message and keep it in the original language (not-English).

@zeecorleone
Copy link
Contributor

@lofti198 , you need to call SetConversationSystemMessage method of ChatGpt object. It expects two parameters, first one being 'conversationId' and second one being the 'system message'.
For example, in your case, you can do:

var openai = new ChatGpt(openAiKey, options);
//set system message
openai.SetConversationSystemMessage("your-conversationId", "rephrase user message and keep it in the original language");
//chat with user message
var fixedSentence = await openai.Ask($"{instruction}: {data}");
 return fixedSentence;

zeecorleone added a commit to zeecorleone/ChatGPT.Net that referenced this issue May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants