|
6 | 6 | }, |
7 | 7 | "cell_type": "markdown", |
8 | 8 | "source": [ |
9 | | - "Colab is making it easier than ever to integrate powerful Generative AI capabilities into your projects. We are launching public preview for a simple and intuitive Python library (google.colab.ai) to access state-of-the-art language models directly within Pro and Pro+ subscriber Colab environments. This means subscribers can spend less time on configuration and set up and more time bringing their ideas to life. With just a few lines of code, you can now perform a variety of tasks:\n", |
| 9 | + "Colab is making it easier than ever to integrate powerful Generative AI capabilities into your projects. We are launching public preview for a simple and intuitive Python library (google.colab.ai) to access state-of-the-art language models directly within Colab environments. All users have free access to most popular LLMs, while paid users have access to a wider selection of models. This means users can spend less time on configuration and set up and more time bringing their ideas to life. With just a few lines of code, you can now perform a variety of tasks:\n", |
10 | 10 | "- Generate text\n", |
11 | 11 | "- Translate languages\n", |
12 | 12 | "- Write creative content\n", |
|
98 | 98 | ] |
99 | 99 | } |
100 | 100 | ], |
101 | | - "execution_count": 5 |
| 101 | + "execution_count": null |
102 | 102 | }, |
103 | 103 | { |
104 | 104 | "metadata": { |
|
126 | 126 | ] |
127 | 127 | } |
128 | 128 | ], |
129 | | - "execution_count": 2 |
| 129 | + "execution_count": null |
130 | 130 | }, |
131 | 131 | { |
132 | 132 | "metadata": { |
|
200 | 200 | " def print(self, text_chunk):\n", |
201 | 201 | " i = 0\n", |
202 | 202 | " n = len(text_chunk)\n", |
203 | | - " while i \u003c n:\n", |
| 203 | + " while i < n:\n", |
204 | 204 | " start_index = i\n", |
205 | | - " while i \u003c n and text_chunk[i] not in ' \\n': # Find end of word\n", |
| 205 | + " while i < n and text_chunk[i] not in ' \\n': # Find end of word\n", |
206 | 206 | " i += 1\n", |
207 | 207 | " current_word = text_chunk[start_index:i]\n", |
208 | 208 | "\n", |
209 | 209 | " delimiter = \"\"\n", |
210 | | - " if i \u003c n: # If not end of chunk, we found a delimiter\n", |
| 210 | + " if i < n: # If not end of chunk, we found a delimiter\n", |
211 | 211 | " delimiter = text_chunk[i]\n", |
212 | 212 | " i += 1 # Consume delimiter\n", |
213 | 213 | "\n", |
214 | 214 | " if current_word:\n", |
215 | | - " needs_leading_space = (self.current_line_length \u003e 0)\n", |
| 215 | + " needs_leading_space = (self.current_line_length > 0)\n", |
216 | 216 | "\n", |
217 | 217 | " # Case 1: Word itself is too long for a line (must be broken)\n", |
218 | | - " if len(current_word) \u003e self.max_length:\n", |
| 218 | + " if len(current_word) > self.max_length:\n", |
219 | 219 | " if needs_leading_space: # Newline if current line has content\n", |
220 | 220 | " sys.stdout.write('\\n')\n", |
221 | 221 | " self.current_line_length = 0\n", |
222 | 222 | " for char_val in current_word: # Break the long word\n", |
223 | | - " if self.current_line_length \u003e= self.max_length:\n", |
| 223 | + " if self.current_line_length >= self.max_length:\n", |
224 | 224 | " sys.stdout.write('\\n')\n", |
225 | 225 | " self.current_line_length = 0\n", |
226 | 226 | " sys.stdout.write(char_val)\n", |
227 | 227 | " self.current_line_length += 1\n", |
228 | 228 | " # Case 2: Word doesn't fit on current line (print on new line)\n", |
229 | | - " elif self.current_line_length + (1 if needs_leading_space else 0) + len(current_word) \u003e self.max_length:\n", |
| 229 | + " elif self.current_line_length + (1 if needs_leading_space else 0) + len(current_word) > self.max_length:\n", |
230 | 230 | " sys.stdout.write('\\n')\n", |
231 | 231 | " sys.stdout.write(current_word)\n", |
232 | 232 | " self.current_line_length = len(current_word)\n", |
|
254 | 254 | " self.current_line_length = 0\n", |
255 | 255 | " elif delimiter == ' ':\n", |
256 | 256 | " # If line is full and a space delimiter arrives, it implies a wrap.\n", |
257 | | - " if self.current_line_length \u003e= self.max_length:\n", |
| 257 | + " if self.current_line_length >= self.max_length:\n", |
258 | 258 | " sys.stdout.write('\\n')\n", |
259 | 259 | " self.current_line_length = 0\n", |
260 | 260 | "\n", |
|
0 commit comments