@@ -48,11 +48,58 @@ Reads the content of a file.
4848
4949## ` gemini `
5050
51- A module for interacting with the Google Gemini API.
51+ This module provides a single function, generate_content, which uses the
52+ Gemini API to generate text, optionally with an image as context.
53+
54+ It accepts the following keyword arguments:
55+
56+ - model (str): The name of the model to use for generation (e.g., "gemini-1.5-flash").
57+ - contents (list of (str, str) tuples): A list of (role, text) tuples representing
58+ the conversation history. Valid roles are typically "user" and "model".
59+ - image (bytes, optional): The raw bytes of an image to include. The image is
60+ inserted as a new part just before the last part of the 'contents'.
61+ This is useful for multimodal prompts (e.g., asking a question about an image).
62+ - system_instructions (str, optional): System instructions to guide Gemini's response.
63+ - unsafe (bool, optional): If set to true, disables all safety settings for the
64+ content generation, allowing potentially harmful content. Use with caution.
65+
66+ For example, for a text-only prompt:
67+
68+ responses = gemini.generate_content(
69+ model="gemini-1.5-flash",
70+ contents=[
71+ ("user", "Once upon a time,"),
72+ ("model", "there was a brave knight."),
73+ ("user", "What happened next?")
74+ ],
75+ system_instructions="You are a creative story writer. Write a short story based on the provided prompt."
76+ )
77+
78+ To ask a question about an image:
79+
80+ image_data = ... # read image file content as bytes
81+ responses = gemini.generate_content(
82+ model="gemini-1.5-flash",
83+ contents=[
84+ ("user", "Describe this image in detail.")
85+ ],
86+ image=image_data
87+ )
88+
89+ The responses variable will contain a list of generated responses, where each response
90+ is a list of strings representing the parts of the generated content.
5291
5392## ` kvcache `
5493
55- A module for caching key-value pairs.
94+ This module provides two functions:
95+
96+ - get(key: str) -> value | None: Retrieves the value associated with the
97+ given string key. Returns the stored value if the key exists and has
98+ not expired. Returns None if the key is not found or if the entry
99+ has expired. Accessing a key resets its TTL timer.
100+ - set(key: str, value: any): Stores the given value under the specified
101+ string key. Any existing value for the key is overwritten. Storing a
102+ value resets the TTL timer for that key.
56103
57104## ` markdown `
58105
@@ -64,16 +111,45 @@ Converts a Markdown string to a Telegram message struct.
64111
65112## ` module() `
66113
67- Creates a new Starlark module from a dictionary .
114+ Instantiates a module struct with the name from the specified keyword arguments .
68115
69116## ` struct() `
70117
71- Creates a new Starlark struct from a dictionary .
118+ Instantiates an immutable struct from the specified keyword arguments .
72119
73120## ` telegram `
74121
75- A module for interacting with the Telegram Bot API.
122+ This module provides two functions: call and get_file.
123+
124+ # call
125+
126+ The call function takes two arguments:
127+
128+ - method (string): The Telegram Bot API method to call.
129+ - args (dict): The arguments to pass to the method.
130+
131+ For example, to send a message to a chat:
132+
133+ response = telegram.call(
134+ method="sendMessage",
135+ args={
136+ "chat_id": 123456789,
137+ "text": "Hello, world!",
138+ }
139+ )
140+
141+ The response variable will contain the response from the Telegram Bot API.
142+
143+ # get_file
144+
145+ The get_file function takes one argument:
146+
147+ - file_id (string): The ID of the file to download.
148+
149+ It returns the content of the file as bytes. For example:
150+
151+ file_content = telegram.get_file(file_id="...")
76152
77153## ` time `
78154
79- A module for time-related functions.
155+ A module for time-related functions. See https://pkg.go.dev/go.starlark.net/lib/time#Module .
0 commit comments