Skip to content

Instantly share code, notes, and snippets.

@stepan-bezhuk-axon
Last active October 16, 2023 10:47
Show Gist options
  • Save stepan-bezhuk-axon/1ab4b1e8ff47cccb9c5c0ba65d1616cb to your computer and use it in GitHub Desktop.
Save stepan-bezhuk-axon/1ab4b1e8ff47cccb9c5c0ba65d1616cb to your computer and use it in GitHub Desktop.
PaLM Service
abstract class IPaLMDataSource {
Future<PaLMModel> generateText(String text);
}
@override
Future<PaLMModel> generateText(String text) async {
return await dioClient.onRequest(() async {
const url = 'https://generativelanguage.googleapis.com/v1beta2/models/text-bison-001:generateText';
final queryParameters = {'key': <API_KEY>};
final body = {'prompt': {'text': text}};
final response = await dioClient.post(url, queryParameters: queryParameters, data: body);
return PaLMModel.fromJson(response.data);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment