@difizen/libro-lab 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/command/lab-command.d.ts +4 -0
- package/es/command/lab-command.d.ts.map +1 -1
- package/es/command/lab-command.js +4 -0
- package/es/command/lab-menu-contribution.d.ts +3 -2
- package/es/command/lab-menu-contribution.d.ts.map +1 -1
- package/es/command/lab-menu-contribution.js +151 -110
- package/es/config/config.d.ts +2 -0
- package/es/config/config.d.ts.map +1 -1
- package/es/config/config.js +12 -1
- package/es/guide/content-contribution.d.ts +7 -0
- package/es/guide/content-contribution.d.ts.map +1 -0
- package/es/guide/content-contribution.js +74 -0
- package/es/guide/guide-view.d.ts +19 -0
- package/es/guide/guide-view.d.ts.map +1 -0
- package/es/guide/guide-view.js +141 -0
- package/es/guide/index.d.ts +3 -0
- package/es/guide/index.d.ts.map +1 -0
- package/es/guide/index.js +2 -0
- package/es/guide/index.less +8 -0
- package/es/guide/libro_guide_book.json +333 -0
- package/es/guide/libro_guide_book_zh.json +331 -0
- package/es/lab-app.d.ts.map +1 -1
- package/es/lab-app.js +51 -27
- package/es/module.d.ts.map +1 -1
- package/es/module.js +3 -1
- package/package.json +14 -14
- package/src/command/lab-command.ts +4 -0
- package/src/command/lab-menu-contribution.tsx +15 -2
- package/src/config/config.ts +12 -0
- package/src/guide/content-contribution.ts +50 -0
- package/src/guide/guide-view.tsx +77 -0
- package/src/guide/index.less +8 -0
- package/src/guide/index.ts +2 -0
- package/src/guide/libro_guide_book.json +333 -0
- package/src/guide/libro_guide_book_zh.json +331 -0
- package/src/lab-app.ts +10 -2
- package/src/module.tsx +4 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"id": "d13d3515-05d9-4fb0-a9c4-e62445c9c8af",
|
|
6
|
+
"metadata": {
|
|
7
|
+
"libroCellType": "markdown",
|
|
8
|
+
"libroFormatter": "formatter-string"
|
|
9
|
+
},
|
|
10
|
+
"source": [
|
|
11
|
+
"# <center> ✨A Quick Guide to libro✨ \n",
|
|
12
|
+
"## <center> 🎉🧙🔮 Welcome to libro \n",
|
|
13
|
+
"**<center> libro, more than just a notebook, it’s an inspiration accelerator!**"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"cell_type": "markdown",
|
|
18
|
+
"id": "92d339b1-45f9-42f0-ac2f-e95388d6c6b3",
|
|
19
|
+
"metadata": {
|
|
20
|
+
"libroFormatter": "formatter-string"
|
|
21
|
+
},
|
|
22
|
+
"source": [
|
|
23
|
+
"**libro is a customizable notebook solution that supports generative AI capabilities. It offers a commercial-grade notebook experience with deep integration of AI features, allowing for easy integration into your development environment to build top-tier AI and data science solutions. Let us guide you through a fun and engaging way to quickly get started and unlock a whole new work experience with libro!**"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"cell_type": "markdown",
|
|
28
|
+
"id": "e3bc282a-b4c0-4554-8657-54078632b7fa",
|
|
29
|
+
"metadata": {
|
|
30
|
+
"libroFormatter": "formatter-string"
|
|
31
|
+
},
|
|
32
|
+
"source": ["### Step 1: Unlock the Door to the Notebook 🔑"]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"cell_type": "markdown",
|
|
36
|
+
"id": "2675de53-c92c-4c76-a11b-e01f29d6e249",
|
|
37
|
+
"metadata": {
|
|
38
|
+
"libroFormatter": "formatter-string"
|
|
39
|
+
},
|
|
40
|
+
"source": [
|
|
41
|
+
"Run `libro generate config` in the terminal to generate the `~/.libro/libro_config.yaml` file. Then, configure the settings for large models and databases in libro, and enable the `libro_sql` and `libro_ai` extensions. Give it a try now! \n",
|
|
42
|
+
"\n",
|
|
43
|
+
"```yaml\n",
|
|
44
|
+
"llm:\n",
|
|
45
|
+
" DASHSCOPE_API_KEY: xxxxxxx\n",
|
|
46
|
+
" OPENAI_API_KEY: xxxxxxxx\n",
|
|
47
|
+
" default_model: chatgpt\n",
|
|
48
|
+
"\n",
|
|
49
|
+
"db:\n",
|
|
50
|
+
" - db_type: mysql\n",
|
|
51
|
+
" username: \"root\"\n",
|
|
52
|
+
" password: \"12345678\"\n",
|
|
53
|
+
" host: \"127.0.0.1\"\n",
|
|
54
|
+
" port: 3306\n",
|
|
55
|
+
" database: sql_demo.db\n",
|
|
56
|
+
"\n",
|
|
57
|
+
"ipython_extensions:\n",
|
|
58
|
+
" libro_ai: True\n",
|
|
59
|
+
" libro_sql: True\n",
|
|
60
|
+
"```"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"cell_type": "markdown",
|
|
65
|
+
"id": "43fd242d-69c1-45b8-b606-c07ce5923fbb",
|
|
66
|
+
"metadata": {
|
|
67
|
+
"libroFormatter": "formatter-string"
|
|
68
|
+
},
|
|
69
|
+
"source": [
|
|
70
|
+
"### Step 2: SQL Cell, the Magic Wand of Data 🪄\n",
|
|
71
|
+
"\n",
|
|
72
|
+
"libro supports using SQL Cells to simplify database interactions. It acts like a dialog box that directly connects to your database, without the need for any additional tools—making data analysis a breeze!\n",
|
|
73
|
+
"\n",
|
|
74
|
+
"By combining SQL and Python in libro, you can:\n",
|
|
75
|
+
"\n",
|
|
76
|
+
"- Query your database directly to quickly retrieve data and save the results as a dataframe.\n",
|
|
77
|
+
"- Use Python to further process and visualize the query results.\n",
|
|
78
|
+
"- Leverage the powerful query capabilities of SQL alongside the dynamism of the Notebook to boost development efficiency.\n",
|
|
79
|
+
"\n",
|
|
80
|
+
"Give it a try now!"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "code",
|
|
85
|
+
"execution_count": null,
|
|
86
|
+
"id": "d7b92e18-dd4c-4309-824e-54820bf5b171",
|
|
87
|
+
"metadata": {
|
|
88
|
+
"libroCellType": "sql",
|
|
89
|
+
"libroFormatter": "formatter-sql-magic"
|
|
90
|
+
},
|
|
91
|
+
"outputs": [],
|
|
92
|
+
"source": [
|
|
93
|
+
"%%sql \n",
|
|
94
|
+
"{\"result_variable\":\"df_1\",\"db_id\":\"sqlite: sql_demo.db\",\"sql_script\":\"CREATE TABLE products (\\n id INTEGER PRIMARY KEY AUTOINCREMENT, \\n name TEXT NOT NULL, \\n description TEXT, \\n price REAL NOT NULL, \\n stock INTEGER DEFAULT 0, \\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \\n updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP \\n);\"}"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"cell_type": "code",
|
|
99
|
+
"execution_count": null,
|
|
100
|
+
"id": "12b0e2fa-a4a4-4e17-affb-2dd10ad3cabe",
|
|
101
|
+
"metadata": {
|
|
102
|
+
"execution": {},
|
|
103
|
+
"libroCellType": "sql",
|
|
104
|
+
"libroFormatter": "formatter-sql-magic"
|
|
105
|
+
},
|
|
106
|
+
"outputs": [],
|
|
107
|
+
"source": [
|
|
108
|
+
"%%sql \n",
|
|
109
|
+
"{\"result_variable\":\"df_2\",\"db_id\":\"sqlite: sql_demo.db\",\"sql_script\":\"INSERT INTO products (name, description, price, stock) VALUES\\n('Laptop', 'High performance laptop', 1299.99, 15),\\n('Smartphone', 'Latest model smartphone', 899.99, 50),\\n('Headphones', 'Noise-cancelling headphones', 199.99, 30),\\n('Monitor', '4K Ultra HD Monitor', 349.99, 20),\\n('Keyboard', 'Mechanical gaming keyboard', 99.99, 40),\\n('Mouse', 'Wireless ergonomic mouse', 49.99, 60),\\n('Tablet', '10-inch screen tablet', 499.99, 25),\\n('Smartwatch', 'Water-resistant smartwatch', 199.99, 35),\\n('Camera', 'DSLR camera with 4K video', 799.99, 10),\\n('Printer', 'All-in-one wireless printer', 149.99, 18),\\n('Speaker', 'Bluetooth portable speaker', 89.99, 55),\\n('Router', 'Dual-band WiFi router', 59.99, 50),\\n('Desk', 'Adjustable height standing desk', 299.99, 12),\\n('Chair', 'Ergonomic office chair', 199.99, 25),\\n('Hard Drive', '2TB external hard drive', 119.99, 45),\\n('SSD', '1TB SSD for laptops and PCs', 149.99, 50),\\n('Graphics Card', 'High-end gaming graphics card', 699.99, 5),\\n('Power Bank', 'Fast charging power bank', 39.99, 70),\\n('Projector', 'Full HD home projector', 499.99, 8),\\n('Drone', 'Camera drone with GPS', 899.99, 6);\"}"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"cell_type": "code",
|
|
114
|
+
"execution_count": null,
|
|
115
|
+
"id": "5551d41a-8c8b-45ae-b9e2-a8c342a5d8e5",
|
|
116
|
+
"metadata": {
|
|
117
|
+
"libroCellType": "sql",
|
|
118
|
+
"libroFormatter": "formatter-sql-magic"
|
|
119
|
+
},
|
|
120
|
+
"outputs": [],
|
|
121
|
+
"source": [
|
|
122
|
+
"%%sql \n",
|
|
123
|
+
"{\"result_variable\":\"df_3\",\"db_id\":\"sqlite: sql_demo.db\",\"sql_script\":\"select * from products\"}"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"cell_type": "code",
|
|
128
|
+
"execution_count": null,
|
|
129
|
+
"id": "83edeb90-a116-4ed2-b80e-c0a534e365c0",
|
|
130
|
+
"metadata": {
|
|
131
|
+
"execution": {},
|
|
132
|
+
"libroFormatter": "formatter-string"
|
|
133
|
+
},
|
|
134
|
+
"outputs": [],
|
|
135
|
+
"source": ["df_3"]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"cell_type": "markdown",
|
|
139
|
+
"id": "2d09d97f-8c87-4f80-b865-62239ef4d846",
|
|
140
|
+
"metadata": {
|
|
141
|
+
"libroFormatter": "formatter-string"
|
|
142
|
+
},
|
|
143
|
+
"source": ["### Step 3: AI Assistant, the Perfect Partner for Developers 🤖"]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"cell_type": "markdown",
|
|
147
|
+
"id": "cce8d104-8099-4d16-9dc7-96f6df99259b",
|
|
148
|
+
"metadata": {
|
|
149
|
+
"libroFormatter": "formatter-string"
|
|
150
|
+
},
|
|
151
|
+
"source": [
|
|
152
|
+
"#### Error Fixing\n",
|
|
153
|
+
"\n",
|
|
154
|
+
"When a Cell execution encounters an error, simply click the \"Fix with AI\" button, and the assistant will automatically analyze the error and provide repair suggestions to help you quickly resolve the issue and get back to smooth coding. Try fixing the execution error below now!"
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"cell_type": "code",
|
|
159
|
+
"execution_count": 2,
|
|
160
|
+
"id": "549fbd17-9e22-4844-8cb5-dcf006e88338",
|
|
161
|
+
"metadata": {
|
|
162
|
+
"execution": {
|
|
163
|
+
"shell.execute_reply.end": "2024-11-26T06:08:42.651560Z",
|
|
164
|
+
"shell.execute_reply.started": "2024-11-26T06:08:42.406610Z",
|
|
165
|
+
"to_execute": "2024-11-26T06:08:42.429Z"
|
|
166
|
+
},
|
|
167
|
+
"libroFormatter": "formatter-string"
|
|
168
|
+
},
|
|
169
|
+
"outputs": [
|
|
170
|
+
{
|
|
171
|
+
"ename": "NameError",
|
|
172
|
+
"evalue": "name 'a' is not defined",
|
|
173
|
+
"output_type": "error",
|
|
174
|
+
"traceback": [
|
|
175
|
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
176
|
+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
177
|
+
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43ma\u001b[49m\n",
|
|
178
|
+
"\u001b[0;31mNameError\u001b[0m: name 'a' is not defined"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"source": ["a"]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"cell_type": "markdown",
|
|
186
|
+
"id": "bd071522-2e45-4d3c-b5fc-beb14147271c",
|
|
187
|
+
"metadata": {
|
|
188
|
+
"libroFormatter": "formatter-string"
|
|
189
|
+
},
|
|
190
|
+
"source": [
|
|
191
|
+
"#### AI Chat\n",
|
|
192
|
+
"\n",
|
|
193
|
+
"You can click the conversation button [ in the top-right toolbar / the right toolbar of the Cell ] to interact directly with the AI, receiving in-depth answers and optimization suggestions related to your current code, enhancing your coding efficiency. Try chatting with libro’s AI now!"
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"cell_type": "markdown",
|
|
198
|
+
"id": "d248e413-1411-43cc-b23b-2a1b5626948a",
|
|
199
|
+
"metadata": {
|
|
200
|
+
"libroFormatter": "formatter-string"
|
|
201
|
+
},
|
|
202
|
+
"source": [
|
|
203
|
+
"#### Code Explanation\n",
|
|
204
|
+
"\n",
|
|
205
|
+
"You can click the magic button [in the right toolbar of the Cell], and libro will help you understand the functionality and logic of the code in the Cell, making learning to code easier. Try explaining the code below now!"
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"cell_type": "code",
|
|
210
|
+
"execution_count": null,
|
|
211
|
+
"id": "300242af-2d63-4ea4-bb0c-e785d489fc6b",
|
|
212
|
+
"metadata": {
|
|
213
|
+
"execution": {},
|
|
214
|
+
"libroFormatter": "formatter-string"
|
|
215
|
+
},
|
|
216
|
+
"outputs": [],
|
|
217
|
+
"source": [
|
|
218
|
+
"def quick_sort(arr):\n",
|
|
219
|
+
" if len(arr) <= 1: \n",
|
|
220
|
+
" return arr\n",
|
|
221
|
+
" \n",
|
|
222
|
+
" pivot = arr[len(arr) // 2] \n",
|
|
223
|
+
" left = [x for x in arr if x < pivot] \n",
|
|
224
|
+
" middle = [x for x in arr if x == pivot] \n",
|
|
225
|
+
" right = [x for x in arr if x > pivot] \n",
|
|
226
|
+
" return quick_sort(left) + middle + quick_sort(right)"
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
"cell_type": "markdown",
|
|
231
|
+
"id": "3d120c83-8655-4251-b97a-7177dba537f5",
|
|
232
|
+
"metadata": {
|
|
233
|
+
"libroFormatter": "formatter-string"
|
|
234
|
+
},
|
|
235
|
+
"source": [
|
|
236
|
+
"#### Code Optimization\n",
|
|
237
|
+
"\n",
|
|
238
|
+
"You can click the magic button [ in the right toolbar of the Cell ], and libro will analyze the code in the Cell and provide optimization suggestions to make your code more efficient and readable, enhancing your overall programming experience. Try optimizing the code below now!"
|
|
239
|
+
]
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
"cell_type": "code",
|
|
243
|
+
"execution_count": null,
|
|
244
|
+
"id": "1413a361-a51b-4ece-b673-a8a12e75dfce",
|
|
245
|
+
"metadata": {
|
|
246
|
+
"execution": {},
|
|
247
|
+
"libroFormatter": "formatter-string"
|
|
248
|
+
},
|
|
249
|
+
"outputs": [],
|
|
250
|
+
"source": [
|
|
251
|
+
"def calculate_sum(numbers):\n",
|
|
252
|
+
" total = 0\n",
|
|
253
|
+
" for i in range(len(numbers)):\n",
|
|
254
|
+
" total += numbers[i]\n",
|
|
255
|
+
" return total"
|
|
256
|
+
]
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"cell_type": "markdown",
|
|
260
|
+
"id": "ed705e80-6970-4bc7-8617-a82c70840b9c",
|
|
261
|
+
"metadata": {
|
|
262
|
+
"libroFormatter": "formatter-string"
|
|
263
|
+
},
|
|
264
|
+
"source": [
|
|
265
|
+
"### Step 4: AI Workflow Development Tool 💡\n",
|
|
266
|
+
"\n",
|
|
267
|
+
"The Prompt Cell is a special type of notebook cell. With this cell, users only need to input natural language commands to call large models for inference and receive the desired output. It reduces the need for writing complex code and can be seamlessly integrated into existing workflows. Try the example below now!"
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"cell_type": "code",
|
|
272
|
+
"execution_count": null,
|
|
273
|
+
"id": "758e3891-bec1-4017-9af6-247634d8ba1c",
|
|
274
|
+
"metadata": {
|
|
275
|
+
"execution": {},
|
|
276
|
+
"libroFormatter": "formatter-string"
|
|
277
|
+
},
|
|
278
|
+
"outputs": [],
|
|
279
|
+
"source": ["output_language = \"English\""]
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
"cell_type": "code",
|
|
283
|
+
"execution_count": null,
|
|
284
|
+
"id": "310bf74e-295d-4a31-8a36-7109cac02982",
|
|
285
|
+
"metadata": {
|
|
286
|
+
"libroCellType": "prompt",
|
|
287
|
+
"libroFormatter": "formatter-prompt-magic"
|
|
288
|
+
},
|
|
289
|
+
"outputs": [],
|
|
290
|
+
"source": [
|
|
291
|
+
"%%prompt \n",
|
|
292
|
+
"{\"model_name\":\"LLM:gpt4\",\"chat_key\":\"LLM:gpt4\",\"prompt\":\"You are a helpful assistant that translates Chinese to {output_language}.\",\"cell_id\":\"310bf74e-295d-4a31-8a36-7109cac02982\",\"record\":\"chat1\"}"
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
"cell_type": "code",
|
|
297
|
+
"execution_count": null,
|
|
298
|
+
"id": "3281ba0d-ae5d-4510-b7a5-4968b2300e6f",
|
|
299
|
+
"metadata": {
|
|
300
|
+
"libroCellType": "prompt",
|
|
301
|
+
"libroFormatter": "formatter-prompt-magic"
|
|
302
|
+
},
|
|
303
|
+
"outputs": [],
|
|
304
|
+
"source": [
|
|
305
|
+
"%%prompt \n",
|
|
306
|
+
"{\"model_name\":\"LLM:gpt4\",\"chat_key\":\"LLM:gpt4\",\"prompt\":\"今天天气真好\",\"cell_id\":\"3281ba0d-ae5d-4510-b7a5-4968b2300e6f\",\"record\":\"chat1\"}"
|
|
307
|
+
]
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"cell_type": "markdown",
|
|
311
|
+
"id": "840bbfa2-e89b-4b42-b73a-34ca90ef1736",
|
|
312
|
+
"metadata": {
|
|
313
|
+
"libroFormatter": "formatter-string"
|
|
314
|
+
},
|
|
315
|
+
"source": [
|
|
316
|
+
"### Finally 🎢\n",
|
|
317
|
+
"\n",
|
|
318
|
+
"Looking to the future, libro will continue to leverage its flexibility and ease of integration to explore more use cases for notebook-like products, aiming to become the best notebook experience.\n",
|
|
319
|
+
"\n",
|
|
320
|
+
"At the same time, libro will keep exploring applications that combine with large models, enabling users to have a more intelligent programming experience, making coding with libro as easy as writing documentation.\n",
|
|
321
|
+
"\n",
|
|
322
|
+
"We welcome developers from various fields to join us in building the libro project. Here is the link to the open-source libro project. If you like it, feel free to give us a star 🌟🌟🌟 on GitHub!\n",
|
|
323
|
+
"\n",
|
|
324
|
+
"https://github.com/difizen/libro\n",
|
|
325
|
+
"\n",
|
|
326
|
+
"**libro, more than just a notebook, it’s an inspiration accelerator!**"
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
"metadata": {},
|
|
331
|
+
"nbformat": 4,
|
|
332
|
+
"nbformat_minor": 5
|
|
333
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cells": [
|
|
3
|
+
{
|
|
4
|
+
"cell_type": "markdown",
|
|
5
|
+
"id": "d13d3515-05d9-4fb0-a9c4-e62445c9c8af",
|
|
6
|
+
"metadata": {
|
|
7
|
+
"libroCellType": "markdown",
|
|
8
|
+
"libroFormatter": "formatter-string"
|
|
9
|
+
},
|
|
10
|
+
"source": [
|
|
11
|
+
"# <center> ✨A Quick Guide to libro✨\n",
|
|
12
|
+
"## <center> 🎉🧙🔮 欢迎使用 libro\n",
|
|
13
|
+
"**<center> libro,不只是 notebook,更是一个灵感加速器!**"
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"cell_type": "markdown",
|
|
18
|
+
"id": "92d339b1-45f9-42f0-ac2f-e95388d6c6b3",
|
|
19
|
+
"metadata": {
|
|
20
|
+
"libroFormatter": "formatter-string"
|
|
21
|
+
},
|
|
22
|
+
"source": [
|
|
23
|
+
"**libro 是支持生成式 AI 能力的可定制 notebook 产品方案。提供商业级 notebook 产品的体验,深度集成 AI 能力,可以轻松集成到您的研发环境中,为您构建一流的 AI、数据科学研发方案。让我们用一种有趣的方式带您快速上手,解锁基于 libro 的全新工作体验!**"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"cell_type": "markdown",
|
|
28
|
+
"id": "e3bc282a-b4c0-4554-8657-54078632b7fa",
|
|
29
|
+
"metadata": {
|
|
30
|
+
"libroFormatter": "formatter-string"
|
|
31
|
+
},
|
|
32
|
+
"source": ["### Step 1:开启 Notebook 之门 🔑"]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"cell_type": "markdown",
|
|
36
|
+
"id": "2675de53-c92c-4c76-a11b-e01f29d6e249",
|
|
37
|
+
"metadata": {
|
|
38
|
+
"libroFormatter": "formatter-string"
|
|
39
|
+
},
|
|
40
|
+
"source": [
|
|
41
|
+
"在终端中运行 `libro generate config ` 生成 ` ~/.libro/libro_config.yaml` 文件,按照如下内容,对 libro 中大模型和数据库相关的配置,并且启用 libro_sql、libro_ai 扩展。赶快试试吧~\n",
|
|
42
|
+
"\n",
|
|
43
|
+
"```yaml\n",
|
|
44
|
+
"llm:\n",
|
|
45
|
+
" DASHSCOPE_API_KEY: xxxxxxx\n",
|
|
46
|
+
" OPENAI_API_KEY: xxxxxxxx\n",
|
|
47
|
+
" default_model: chatgpt\n",
|
|
48
|
+
"\n",
|
|
49
|
+
"db:\n",
|
|
50
|
+
" - db_type: mysql\n",
|
|
51
|
+
" username: \"root\"\n",
|
|
52
|
+
" password: \"12345678\"\n",
|
|
53
|
+
" host: \"127.0.0.1\"\n",
|
|
54
|
+
" port: 3306\n",
|
|
55
|
+
" database: sql_demo\n",
|
|
56
|
+
"\n",
|
|
57
|
+
"ipython_extensions:\n",
|
|
58
|
+
" libro_ai: True\n",
|
|
59
|
+
" libro_sql: True\n",
|
|
60
|
+
"```"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"cell_type": "markdown",
|
|
65
|
+
"id": "43fd242d-69c1-45b8-b606-c07ce5923fbb",
|
|
66
|
+
"metadata": {
|
|
67
|
+
"libroFormatter": "formatter-string"
|
|
68
|
+
},
|
|
69
|
+
"source": [
|
|
70
|
+
"### Step 2:SQL Cell,数据界的魔法棒 🪄\n",
|
|
71
|
+
"\n",
|
|
72
|
+
"libro 支持使用 SQL Cell 来简化数据库交互,它就像一个对话框,直接对接您的数据库,不需要任何额外工具,数据分析轻松搞定!\n",
|
|
73
|
+
"\n",
|
|
74
|
+
"通过在 libro 中结合 SQL 和 Python,您可以:\n",
|
|
75
|
+
"\n",
|
|
76
|
+
"- 直接查询数据库,快速获取数据,支持把结果保存为 dataframe。\n",
|
|
77
|
+
"- 使用 Python 对查询结果进行进一步的处理和可视化。\n",
|
|
78
|
+
"- 将 SQL 的强大查询能力与 Notebook 的动态性结合,提升开发效率。\n",
|
|
79
|
+
"\n",
|
|
80
|
+
"赶快试试吧~"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"cell_type": "code",
|
|
85
|
+
"execution_count": null,
|
|
86
|
+
"id": "a8760c9f-d9f2-4937-ace9-2ae29202b9a8",
|
|
87
|
+
"metadata": {
|
|
88
|
+
"libroCellType": "sql",
|
|
89
|
+
"libroFormatter": "formatter-sql-magic"
|
|
90
|
+
},
|
|
91
|
+
"outputs": [],
|
|
92
|
+
"source": [
|
|
93
|
+
"%%sql \n",
|
|
94
|
+
"{\"result_variable\":\"df_1\",\"db_id\":\"sqlite: sql_demo.db\",\"sql_script\":\"CREATE TABLE products (\\n id INTEGER PRIMARY KEY AUTOINCREMENT, \\n name TEXT NOT NULL, \\n description TEXT, \\n price REAL NOT NULL, \\n stock INTEGER DEFAULT 0, \\n created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, \\n updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP \\n);\"}"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"cell_type": "code",
|
|
99
|
+
"execution_count": null,
|
|
100
|
+
"id": "838adfab-9b5b-4000-9e7d-aa29219960bd",
|
|
101
|
+
"metadata": {
|
|
102
|
+
"libroCellType": "sql",
|
|
103
|
+
"libroFormatter": "formatter-sql-magic"
|
|
104
|
+
},
|
|
105
|
+
"outputs": [],
|
|
106
|
+
"source": [
|
|
107
|
+
"%%sql \n",
|
|
108
|
+
"{\"result_variable\":\"df_2\",\"db_id\":\"sqlite: sql_demo.db\",\"sql_script\":\"INSERT INTO products (name, description, price, stock) VALUES\\n('Laptop', 'High performance laptop', 1299.99, 15),\\n('Smartphone', 'Latest model smartphone', 899.99, 50),\\n('Headphones', 'Noise-cancelling headphones', 199.99, 30),\\n('Monitor', '4K Ultra HD Monitor', 349.99, 20),\\n('Keyboard', 'Mechanical gaming keyboard', 99.99, 40),\\n('Mouse', 'Wireless ergonomic mouse', 49.99, 60),\\n('Tablet', '10-inch screen tablet', 499.99, 25),\\n('Smartwatch', 'Water-resistant smartwatch', 199.99, 35),\\n('Camera', 'DSLR camera with 4K video', 799.99, 10),\\n('Printer', 'All-in-one wireless printer', 149.99, 18),\\n('Speaker', 'Bluetooth portable speaker', 89.99, 55),\\n('Router', 'Dual-band WiFi router', 59.99, 50),\\n('Desk', 'Adjustable height standing desk', 299.99, 12),\\n('Chair', 'Ergonomic office chair', 199.99, 25),\\n('Hard Drive', '2TB external hard drive', 119.99, 45),\\n('SSD', '1TB SSD for laptops and PCs', 149.99, 50),\\n('Graphics Card', 'High-end gaming graphics card', 699.99, 5),\\n('Power Bank', 'Fast charging power bank', 39.99, 70),\\n('Projector', 'Full HD home projector', 499.99, 8),\\n('Drone', 'Camera drone with GPS', 899.99, 6);\"}"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"cell_type": "code",
|
|
113
|
+
"execution_count": null,
|
|
114
|
+
"id": "12b0e2fa-a4a4-4e17-affb-2dd10ad3cabe",
|
|
115
|
+
"metadata": {
|
|
116
|
+
"execution": {},
|
|
117
|
+
"libroCellType": "sql",
|
|
118
|
+
"libroFormatter": "formatter-sql-magic"
|
|
119
|
+
},
|
|
120
|
+
"outputs": [],
|
|
121
|
+
"source": [
|
|
122
|
+
"%%sql \n",
|
|
123
|
+
"{\"result_variable\":\"df_3\",\"db_id\":\"sqlite: sql_demo.db\",\"sql_script\":\"select * from products\"}"
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"cell_type": "code",
|
|
128
|
+
"execution_count": null,
|
|
129
|
+
"id": "83edeb90-a116-4ed2-b80e-c0a534e365c0",
|
|
130
|
+
"metadata": {
|
|
131
|
+
"execution": {},
|
|
132
|
+
"libroFormatter": "formatter-string"
|
|
133
|
+
},
|
|
134
|
+
"outputs": [],
|
|
135
|
+
"source": ["df_3"]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"cell_type": "markdown",
|
|
139
|
+
"id": "2d09d97f-8c87-4f80-b865-62239ef4d846",
|
|
140
|
+
"metadata": {
|
|
141
|
+
"libroFormatter": "formatter-string"
|
|
142
|
+
},
|
|
143
|
+
"source": ["### Step 3:AI 助手,开发者的好搭档 🤖"]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"cell_type": "markdown",
|
|
147
|
+
"id": "cce8d104-8099-4d16-9dc7-96f6df99259b",
|
|
148
|
+
"metadata": {
|
|
149
|
+
"libroFormatter": "formatter-string"
|
|
150
|
+
},
|
|
151
|
+
"source": [
|
|
152
|
+
"#### 错误修复\n",
|
|
153
|
+
"\n",
|
|
154
|
+
"当 Cell 执行出现报错时,只需一键点击 “Fix with AI” 按钮,助手会自动分析错误并给出修复建议,帮助您快速解决问题,恢复顺利的编程体验。赶快试试修复下面的执行报错吧~\n"
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"cell_type": "code",
|
|
159
|
+
"execution_count": 2,
|
|
160
|
+
"id": "549fbd17-9e22-4844-8cb5-dcf006e88338",
|
|
161
|
+
"metadata": {
|
|
162
|
+
"execution": {
|
|
163
|
+
"shell.execute_reply.end": "2024-11-26T06:08:28.406750Z",
|
|
164
|
+
"shell.execute_reply.started": "2024-11-26T06:08:28.186003Z",
|
|
165
|
+
"to_execute": "2024-11-26T06:08:28.209Z"
|
|
166
|
+
},
|
|
167
|
+
"libroFormatter": "formatter-string"
|
|
168
|
+
},
|
|
169
|
+
"outputs": [
|
|
170
|
+
{
|
|
171
|
+
"ename": "NameError",
|
|
172
|
+
"evalue": "name 'a' is not defined",
|
|
173
|
+
"output_type": "error",
|
|
174
|
+
"traceback": [
|
|
175
|
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
176
|
+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
177
|
+
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43ma\u001b[49m\n",
|
|
178
|
+
"\u001b[0;31mNameError\u001b[0m: name 'a' is not defined"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"source": ["a"]
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"cell_type": "markdown",
|
|
186
|
+
"id": "bd071522-2e45-4d3c-b5fc-beb14147271c",
|
|
187
|
+
"metadata": {
|
|
188
|
+
"libroFormatter": "formatter-string"
|
|
189
|
+
},
|
|
190
|
+
"source": [
|
|
191
|
+
"#### AI 对话\n",
|
|
192
|
+
"\n",
|
|
193
|
+
"您可以点击会话按钮 [ 顶部右侧工具栏 / Cell 右侧工具栏 ] 直接与 AI 进行互动,获得与当前代码相关的深入解答和优化建议,提升编程效率。赶快试试与 libro 的 AI 对话吧~"
|
|
194
|
+
]
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"cell_type": "markdown",
|
|
198
|
+
"id": "d248e413-1411-43cc-b23b-2a1b5626948a",
|
|
199
|
+
"metadata": {
|
|
200
|
+
"libroFormatter": "formatter-string"
|
|
201
|
+
},
|
|
202
|
+
"source": [
|
|
203
|
+
"#### 代码解释\n",
|
|
204
|
+
"您可以点击魔法按钮 [ Cell 右侧工具栏 ] ,libro 帮您理解 Cell 中代码的功能和逻辑,让编程学习变得更加轻松。赶快试试解释下面这段代码吧~"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"cell_type": "code",
|
|
209
|
+
"execution_count": null,
|
|
210
|
+
"id": "300242af-2d63-4ea4-bb0c-e785d489fc6b",
|
|
211
|
+
"metadata": {
|
|
212
|
+
"execution": {},
|
|
213
|
+
"libroFormatter": "formatter-string"
|
|
214
|
+
},
|
|
215
|
+
"outputs": [],
|
|
216
|
+
"source": [
|
|
217
|
+
"def quick_sort(arr):\n",
|
|
218
|
+
" if len(arr) <= 1: \n",
|
|
219
|
+
" return arr\n",
|
|
220
|
+
" \n",
|
|
221
|
+
" pivot = arr[len(arr) // 2] \n",
|
|
222
|
+
" left = [x for x in arr if x < pivot] \n",
|
|
223
|
+
" middle = [x for x in arr if x == pivot] \n",
|
|
224
|
+
" right = [x for x in arr if x > pivot] \n",
|
|
225
|
+
" return quick_sort(left) + middle + quick_sort(right)"
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"cell_type": "markdown",
|
|
230
|
+
"id": "3d120c83-8655-4251-b97a-7177dba537f5",
|
|
231
|
+
"metadata": {
|
|
232
|
+
"libroFormatter": "formatter-string"
|
|
233
|
+
},
|
|
234
|
+
"source": [
|
|
235
|
+
"#### 代码优化\n",
|
|
236
|
+
"您可以点击魔法按钮 [ Cell 右侧工具栏 ] ,libro 能够分析 Cell 中的代码,并提供优化建议,让您的代码更加高效、可读,提升整体编程体验。赶快试着优化下面的这一段代码吧~"
|
|
237
|
+
]
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"cell_type": "code",
|
|
241
|
+
"execution_count": null,
|
|
242
|
+
"id": "1413a361-a51b-4ece-b673-a8a12e75dfce",
|
|
243
|
+
"metadata": {
|
|
244
|
+
"execution": {},
|
|
245
|
+
"libroFormatter": "formatter-string"
|
|
246
|
+
},
|
|
247
|
+
"outputs": [],
|
|
248
|
+
"source": [
|
|
249
|
+
"def calculate_sum(numbers):\n",
|
|
250
|
+
" total = 0\n",
|
|
251
|
+
" for i in range(len(numbers)):\n",
|
|
252
|
+
" total += numbers[i]\n",
|
|
253
|
+
" return total"
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"cell_type": "markdown",
|
|
258
|
+
"id": "ed705e80-6970-4bc7-8617-a82c70840b9c",
|
|
259
|
+
"metadata": {
|
|
260
|
+
"libroFormatter": "formatter-string"
|
|
261
|
+
},
|
|
262
|
+
"source": [
|
|
263
|
+
"### Step 4:AI 工作流开发利器💡\n",
|
|
264
|
+
"\n",
|
|
265
|
+
"Prompt Cell 是一种特殊的 notebook cell,通过这个 cell,用户只需要输入自然语言指令,就可以调用大模型进行推理,得到所需的输出结果。它的出现减少了编写复杂代码的需求,并且可以灵活地融入现有的工作流中。赶快试试下面的例子吧~"
|
|
266
|
+
]
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
"cell_type": "code",
|
|
270
|
+
"execution_count": null,
|
|
271
|
+
"id": "758e3891-bec1-4017-9af6-247634d8ba1c",
|
|
272
|
+
"metadata": {
|
|
273
|
+
"execution": {},
|
|
274
|
+
"libroFormatter": "formatter-string"
|
|
275
|
+
},
|
|
276
|
+
"outputs": [],
|
|
277
|
+
"source": ["output_language = \"English\""]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
"cell_type": "code",
|
|
281
|
+
"execution_count": null,
|
|
282
|
+
"id": "310bf74e-295d-4a31-8a36-7109cac02982",
|
|
283
|
+
"metadata": {
|
|
284
|
+
"libroCellType": "prompt",
|
|
285
|
+
"libroFormatter": "formatter-prompt-magic"
|
|
286
|
+
},
|
|
287
|
+
"outputs": [],
|
|
288
|
+
"source": [
|
|
289
|
+
"%%prompt \n",
|
|
290
|
+
"{\"model_name\":\"LLM:gpt4\",\"chat_key\":\"LLM:gpt4\",\"prompt\":\"You are a helpful assistant that translates Chinese to {output_language}.\",\"cell_id\":\"310bf74e-295d-4a31-8a36-7109cac02982\",\"record\":\"chat1\"}"
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"cell_type": "code",
|
|
295
|
+
"execution_count": null,
|
|
296
|
+
"id": "3281ba0d-ae5d-4510-b7a5-4968b2300e6f",
|
|
297
|
+
"metadata": {
|
|
298
|
+
"libroCellType": "prompt",
|
|
299
|
+
"libroFormatter": "formatter-prompt-magic"
|
|
300
|
+
},
|
|
301
|
+
"outputs": [],
|
|
302
|
+
"source": [
|
|
303
|
+
"%%prompt \n",
|
|
304
|
+
"{\"model_name\":\"LLM:gpt4\",\"chat_key\":\"LLM:gpt4\",\"prompt\":\"今天天气真好\",\"cell_id\":\"3281ba0d-ae5d-4510-b7a5-4968b2300e6f\",\"record\":\"chat1\"}"
|
|
305
|
+
]
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
"cell_type": "markdown",
|
|
309
|
+
"id": "840bbfa2-e89b-4b42-b73a-34ca90ef1736",
|
|
310
|
+
"metadata": {
|
|
311
|
+
"libroFormatter": "formatter-string"
|
|
312
|
+
},
|
|
313
|
+
"source": [
|
|
314
|
+
"### 最后 🎢\n",
|
|
315
|
+
"\n",
|
|
316
|
+
"面向未来,libro 将继续发挥自身灵活定制、轻松集成的特点,为 notebook 类产品探索更多的使用场景,让 libro 成为体验最好的 notebook 产品。\n",
|
|
317
|
+
"\n",
|
|
318
|
+
"同时,libro 将不断探索与大模型结合的应用场景,通过大模型让用户拥有更加智能的编程体验,让 libro 编程像写文档一样容易。\n",
|
|
319
|
+
"\n",
|
|
320
|
+
"我们欢迎不同场景的开发者,跟我们一起建设 libro 项目,再次附上 libro 开源项目链接,如果你也喜欢这个项目,欢迎在 GitHub 上为我们点亮 🌟🌟🌟\n",
|
|
321
|
+
"\n",
|
|
322
|
+
"https://github.com/difizen/libro\n",
|
|
323
|
+
"\n",
|
|
324
|
+
"**libro,不只是笔记本,更是一个灵感加速器!**"
|
|
325
|
+
]
|
|
326
|
+
}
|
|
327
|
+
],
|
|
328
|
+
"metadata": {},
|
|
329
|
+
"nbformat": 4,
|
|
330
|
+
"nbformat_minor": 5
|
|
331
|
+
}
|
package/es/lab-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lab-app.d.ts","sourceRoot":"","sources":["../src/lab-app.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAChB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,oBAAoB,EAGpB,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"lab-app.d.ts","sourceRoot":"","sources":["../src/lab-app.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,gBAAgB,EAChB,aAAa,EACd,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,oBAAoB,EAGpB,uBAAuB,EACvB,eAAe,EACf,WAAW,EAGZ,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAgB3D,qBACa,WAAY,YAAW,uBAAuB;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IACvC,YAAY,EAAE,YAAY,CAAC;IACxB,eAAe,EAAE,eAAe,CAAC;IACrC,WAAW,EAAE,WAAW,CAAC;IAChB,oBAAoB,EAAE,oBAAoB,CAAC;IAClD,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,EAAE,aAAa,CAAC;IAE9C,OAAO;cAsCG,gBAAgB;CAQjC"}
|