Cohere empowers every developer and enterprise to build amazing products and capture true business value with language AI.
This package provides a powerful bridge between your Flutter application and Cohere AI. It empowers you to seamlessly integrate Cohere's capabilities into your app, unlocking possibilities for building innovative, intelligent, and engaging experiences that redefine user interaction.
Table of content
To use the Cohere API, you'll need an API key. If you don't already have one, create a key in Cohere's official website. Get an API key.
Add flutter_cohere as a dependency in your pubspec.yaml file.
dependencies:
flutter_cohere: ^0.0.1Import the package into your Dart code.
import 'package:flutter_cohere/flutter_cohere.dart';For initialization, you must call the CohereClient constructor for Flutter Cohere.
void myFunction() {
/// Add this line
var co = CohereClient(apiKey: '--- Your Cohere Api Key ---');
}This feature lets you perform natural language processing (NLP) tasks such as text generation and completion.
var co = CohereClient(apiKey: '--- Your Cohere Api Key ---');
co.generate(
prompt: "Write a story about a magic backpack.",)
.then((value) => print( value.values.first )) /// or value?.values.first
.catchError((e) => print(e));Using Cohere, you can build freeform conversations across multiple turns.
var co = CohereClient(apiKey: '--- Your Cohere Api Key ---');
co.chat([
{"role": "USER", "message": "Who discovered gravity?"},
{"role": "CHATBOT", "message": "The man who is widely credited with discovering gravity is Sir Isaac Newton"}
])
.then((value) => log(value.values.first ?? 'without output'))
.catchError((e) => log('chat', error: e));soon
soon
soon
soon
soon
soon
soon
soon
soon
soon
soon