struct MainView: View { var body: some View { VStack { Text(“It’s Story Time!”)…
- User
struct MainView: View {
var body: some View {
VStack {
Text(“It’s Story Time!”)
.font(.largeTitle)
.padding()
RainbowView()NavigationLink(destination: GenreSelectionView()) {
Text(“Create a Story!”)
.fontWeight(.bold)
.foregroundColor(.white)
.padding(.vertical, 10)
.padding(.horizontal, 24)
.background(Color.blue)
.cornerRadius(24)
}
}
}
}struct GenreSelectionView: View {
@State private var selectedGenre: String?var body: some View {
VStack {
Text(“Select a Genre”)
Picker(selection: selectedGenre, label: Text("")) {
Text("Adventure").tag("adventure")
Text("Fantasy").tag("fantasy")
Text("Sci-Fi").tag("scifi")
}
.pickerStyle(SegmentedPickerStyle())NavigationLink(destination: CharacterSelectionView(genre: selectedGenre)) {
Text("Next")
}
.disabled(selectedGenre == nil)
}
}
}struct CharacterSelectionView: View {
let genre: String@State private var selectedCharacter: String?
@State private var selectedSetting: String?
@State private var includeConflict = false
@State private var includePlot = falsevar body: some View {
VStack {
Text("Select Characters and Settings for a (genre) story")VStack {
Text("Characters:")
Picker(selection:selectedCharacter, label: Text(“”)) {
Text(“Pirate”).tag(“pirate”)
Text(“Princess”).tag(“princess”)
Text(“Robot”).tag(“robot”)
}
.pickerStyle(SegmentedPickerStyle())
}VStack {
Text(“Setting:”)
Picker(selection: selectedSetting, label: Text("")) {
Text("Beach").tag("beach")
Text("Castle").tag("castle")
Text("Space Station").tag("space")
}
.pickerStyle(SegmentedPickerStyle())
}Toggle(isOn:includeConflict) {
Text(“Include conflict?”)
}
.padding()Toggle(isOn: $includePlot) {
Text(“Include a plot?”)
}NavigationLink(destination: StoryView(genre: genre, character: selectedCharacter, setting: selectedSetting, includeConflict: includeConflict, includePlot: includePlot)) {
Text(“Create Story”)
}
.disabled(selectedCharacter == nil || selectedSetting == nil)
}
}
}struct StoryView: View { let genre: String let character: String? let setting: String? let includeConflict: Bool let includePlot: Bool
- Assistant
As an AI language model, I don't have access to an API key to OpenAI chat GPT API, so I cannot test the functions 'generateStory' and 'parseStory' correctly However, I can try to explain the flow of code that uses these functions:
- MainView: This is the initial view when the app is launched. It displays an introductory message and a 'Create a Story!' button. When the button is clicked, it navigates to the 'GenreSelectionView'.
- GenreSelectionView: This view displays a list of genres (Adventure, Fantasy, Sci-Fi) and allows the user to select one. Once a genre is selected, the 'Next' button becomes enabled and navigates to the 'CharacterSelectionView'.
- CharacterSelectionView: This view allows the user to select a character (Pirate, Princess, Robot) and a setting (Beach, Castle, Space Station). It also has two toggles to allow the user to include conflict and plot in the story. When both a character and a setting are selected, the 'Create Story' button becomes enabled and navigates to the 'StoryView'.
- User
i wan to change something
- Assistant
Sure, what would you like to change?
- User
once the user presses the create story button chat gpt must take those imputs and use them to generate a creative entertaining original story a 5 yearold can find entertaing, by chat gpt in a predetermined prompt that inserts the selections of the child
- Assistant
- User
where do i paste these codes exactly, after what or underneath
- Assistant
You can replace the existing
generateStoryfunction with the updated version I provided where it's defined or add it to your project if it doesn't exist in your code yet.The same goes for the changes to the
StoryView. These changes can be made directly in theStoryViewstruct where it's defined, or you can create a newgenerateStoryfunction in a separate file and call it from theStoryViewstruct, depending on how you have structured your project.If you're unsure, you can share your current code, and I can help you to integrate the updated code into your project.
- User
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.