WineSnob - become a wine expert with AI
This project is part of a generative AI demo. It is designed to demonstrate the ease of building a prompt with Google AI Studio and integrating the resulting model call into Flutter. It does not claim to be a finished product.
WineSnob is available as a web app. Feel free to try it out.
The project was introduced in a medium article With Flutter and PaLM API to Instant Wine Expertise 🍷
Several upcoming presentations will discuss the idea and aspects of the implementation with local developer communities:
- DevFest Mauritius, 28.10.2023, slides, video
- Droidcon Kenya, 8-10.11.2023, slides, video
- Droidcon Uganda, 11-12.11.2023, slides, video
- Flutterista conference, 11.11.2023, slides, video
The project uses the Riverpod code generator. To monitor the source directly and rerun the generator on chances use
dart run build_runner watch
In debugging mode, I use the Firebase emulator suite.
firebase emulators:start --import ./data --export-on-exit
Firebase deploy magic builds and deploys the project automatically, but doesn't take extra args.
firebase deploy
firebase hosting:channel:deploy beta
If the indexes have changed on the hosting site it might be a good idea to
run firebase firestore:indexes
and update the local firebase.indexes.json
The prompt data is saved as stringified json in Firestore. It's easy to mess up the formatting when manipulating strings by hand so I am checking my request strings at dart.dev before pasting them into the Firestore prompt.request field.
Important: make sure description (the interpolated variable) is escaped.
import 'dart:convert';
void main() {
const str = '''
{
"prompt": {
"context": "You are a wine expert. You are asked to describe the style and aroma of a particular wine.",
"examples": [],
"messages": [
{
"content": "Write one paragraph to describe this particular wine: \${description}"
}
]
},
"candidate_count": 3,
"temperature": 0.5
}
''';
print(jsonEncode(jsonDecode(str)));
}
This project borrows ideas, code, and code snippets from some open-source projects I would like to thank the authors for sharing their work.
- Flutter codelab haiku generator
- Andrea Bizzotto starter architecture
- more references included in the code
Please reach out if you feel that I used your code without attribution.