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

Pass the instruction in the first request #7

Open
erossini opened this issue Oct 7, 2024 · 2 comments
Open

Pass the instruction in the first request #7

erossini opened this issue Oct 7, 2024 · 2 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@erossini
Copy link

erossini commented Oct 7, 2024

I'm creating an application with ChatGPT and I saw your project. My project for university is to create a simple English teacher that speaks with the user. To do that, I understood, I have to pass the instruction to ChatGPT like

var request = new CreateAssistantRequest(Model.GPT4o);
Assistant = await ChatGPTClient.AssistantsEndpoint.CreateAssistantAsync(
    new CreateAssistantRequest(
        name: $"English Teacher",
        instructions: $"You are a personal English Teacher. Help me learn English by interacting with me " + 
                      "based on my questions and interests.",
        model: Model.GPT4o));

Looking at your code, I didn't understand if and where I can add these instructions. Can you point me in the right direction?

I really appreciate any help you can provide.
Enrico

@danielmonettelli
Copy link
Owner

danielmonettelli commented Oct 15, 2024

Hi @erossini, first of all, thank you for your interest in my project. I've updated the project to Chat Completion, including the current model for both requests and responses. To add instructions for the assistant bot, you'll need to do so in the system role's content, located in OpenAIService.cs. For modifying the tokens, you can adjust them in the Usage class found in CompletionResponse.cs I've included the code where you can change these parameters. Let me know if you encounter any errors so I can improve the code. Thanks!

public async Task<string> AskQuestion(string query)
{
    var completion = new CompletionRequest
    {
        Model = "gpt-4o-mini",
        Messages = new List<MessageRequest>
        {
            new MessageRequest
            {
                Role = "system",
                Content = "You are a helpful assistant."
            },
            new MessageRequest
            {
                Role = "user",
                Content = query
            }
        }
    };

    // ...
}
public class CompletionResponse
{
    public string Id { get; set; }

    public List<Choice> Choices { get; set; }

    public Usage Usage { get; set; }
}

public class Usage
{
    public int Prompt_Tokens { get; set; } = 9;

    public int Completion_Tokens { get; set; } = 12;

    public int Total_Tokens { get; set; } = 21;
}

@erossini
Copy link
Author

Thank you so much for your code!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants