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

Add a Swift Playground as an example #69

Closed
wants to merge 1 commit into from
Closed

Conversation

andrewheard
Copy link
Collaborator

Added a starter Swift Playground for generating text from a prompt.

@github-actions github-actions bot added component:swift sdk Issue/PR related to Swift SDK status:awaiting review PR awaiting review from a maintainer labels Dec 14, 2023
@andrewheard andrewheard requested a review from paulb777 December 14, 2023 22:47
@peterfriese peterfriese self-requested a review December 14, 2023 23:06
}.padding()
}

func generateText() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should rename this to send or sendMessage, like in the other samples.

}
Spacer()
HStack {
TextField("Enter a prompt...", text: $prompt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add an onSubmit handler so people can just hit [enter] to send the message.

Spacer()
HStack {
TextField("Enter a prompt...", text: $prompt)
Button("Send", systemImage: "arrow.up.circle.fill") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use a Button with a nested Image, like in the other samples

Copy link
Collaborator

@peterfriese peterfriese left a comment

Choose a reason for hiding this comment

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

Great idea, thanks for putting this together!

I found it pretty difficult to edit the text in the Swift Playground app, as the code is formatted using 2 spaces, but the Playground app doesn't seem to allow changing the indentation width. So you constantly end up fighting the editor, which is a pretty bad user experience.

We should change the formatter configuration for this example.

@andrewheard
Copy link
Collaborator Author

Thanks for the review, @peterfriese! Closing this in favour of adding docs instead (#72).

@github-actions github-actions bot removed the status:awaiting review PR awaiting review from a maintainer label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:swift sdk Issue/PR related to Swift SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants