这是indexloc提供的服务,不要输入任何密码
Skip to content

githubmonkey/wine_snob

Repository files navigation

The wine_snob project

WineSnob - become a wine expert with AI

Motivation

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:

Code generation

The project uses the Riverpod code generator. To monitor the source directly and rerun the generator on chances use

dart run build_runner watch 

Firebase emulators

In debugging mode, I use the Firebase emulator suite.

firebase emulators:start --import ./data --export-on-exit

Deploy to firebase hosting

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

Sanity check when formatting a prompt

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)));
}

Attributions

This project borrows ideas, code, and code snippets from some open-source projects I would like to thank the authors for sharing their work.

Please reach out if you feel that I used your code without attribution.

About

A demo project combining Flutter and PaLM API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published