fromText

fun fromText(text: String, role: String = "user"): Content

Creates a content holding one text part.

Useful wherever the API takes a Content but the caller only has a string, such as a system instruction:

GenerateContentConfig(systemInstruction = Content.fromText("You are a helpful assistant."))

Parameters

text

The text of the part.

role

The producer of the content, either "user" or "model". The service reads an unset role as "user".