startNewChat method
GroqChat
startNewChat(
- String modelId, {
- GroqChatSettings settings = const GroqChatSettings.defaults(),
- String? customApiKey,
Returns a new chat instance with the given model id
modelId
is the model id to use for the chat
settings
are the chat settings, defaults to GroqChatSettings.defaults()
customApiKey
is the API key to use for the chat, defaults to the Groq instance API key
Example:
final chat = groq.startNewChat(llama3_8b);
final (response, resourceUsage) = await chat.sendMessage('YOUR_MESSAGE');
Or use the chat as a stream:
chat.stream.listen((event) {
if (event is RequestChatEvent) {
print(event.request.message.message);
} else if (event is ResponseChatEvent) {
print(event.response.choices.first.message);
print(event.usage.totalTokens);
}
});
Implementation
GroqChat startNewChat(
String modelId, {
GroqChatSettings settings = const GroqChatSettings.defaults(),
String? customApiKey,
}) {
final specificApiKey = customApiKey ?? apiKey;
return GroqChat(modelId, specificApiKey, settings);
}