chat method

Future<String?> chat(
  1. String userInput,
  2. String context
)

Implementation

Future<String?> chat(String userInput, String context) async {
  String systemInstruction = '''
  You are a professional organic chemist with extensive knowledge in:
  - Organic synthesis
  - Reaction mechanisms
  - Spectroscopy interpretation (NMR, IR, Mass Spec)
  - Retrosynthetic analysis
  - Named reactions
  - Stereochemistry
  - Functional group transformations

  Your responses should be:
  - Technical but clear
  - Include relevant chemical structures (in text form)
  - Use IUPAC nomenclature
  - Provide reaction equations where applicable
  - Highlight safety considerations
  - Cite important references when appropriate

  consider the following context: $context
''';
  try {
    final response = await generateContent(userInput, systemInstruction);
    return response;
  } catch (e) {
    return 'Error: ${e.toString()}';
  }
}