Skip to content

Create simpleprompt.cs #488

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Create simpleprompt.cs #488

wants to merge 1 commit into from

Conversation

achandmsft
Copy link
Collaborator

@KrzysztofCwalina Example on tying openai-dotnet docs to openai.com docs folder structure

Example on tying openai-dotnet docs to openai.com docs folder structure
@achandmsft
Copy link
Collaborator Author

Actually please rename to chat_simpleprompt.cs

Copy link
Collaborator

@jsquire jsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend that we're more generous with whitespace in samples to help cluster concepts together and improve readability.

The file also looks like it should be name chat_simple_prompt.cs to follow the snake naming conventions in the folder

// 1. Set OPENAI_KEY environment variable to your OpenAI API key, never hardcode it.
// 2. Run this command: type chat_simpleprompt.cs
// 3. Run this commnd: dotnet run chat_simpleprompt.cs
#:package OpenAI@2.*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#:package OpenAI@2.*
#:package OpenAI@2.*

// 3. Run this commnd: dotnet run chat_simpleprompt.cs
#:package OpenAI@2.*
#:property PublishAot=false
using OpenAI.Chat;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
using OpenAI.Chat;
using OpenAI.Chat;

string key = Environment.GetEnvironmentVariable("OPENAI_KEY")!;
ChatClient client = new (model: "gpt-4.1", apiKey: apiKey);
ChatCompletion acompletion = client.CompleteChat("list all noble gases");
Console.WriteLine(acompletion.Content[0].Text);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Console.WriteLine(acompletion.Content[0].Text);
Console.WriteLine(acompletion.Content[0].Text);

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

Successfully merging this pull request may close these issues.

2 participants