Skip to content

Commit e3902eb

Browse files
jameszyaoSimsonW
authored andcommitted
feat: add semantic search example
1 parent d672986 commit e3902eb

File tree

11 files changed

+559
-36
lines changed

11 files changed

+559
-36
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "initial_id",
7+
"metadata": {
8+
"collapsed": true
9+
},
10+
"outputs": [],
11+
"source": [
12+
"import taskingai\n",
13+
"# Load TaskingAI API Key fron environment variable"
14+
]
15+
}
16+
],
17+
"metadata": {
18+
"kernelspec": {
19+
"display_name": "Python 3",
20+
"language": "python",
21+
"name": "python3"
22+
},
23+
"language_info": {
24+
"codemirror_mode": {
25+
"name": "ipython",
26+
"version": 2
27+
},
28+
"file_extension": ".py",
29+
"mimetype": "text/x-python",
30+
"name": "python",
31+
"nbconvert_exporter": "python",
32+
"pygments_lexer": "ipython2",
33+
"version": "2.7.6"
34+
}
35+
},
36+
"nbformat": 4,
37+
"nbformat_minor": 5
38+
}

examples/assistant/conversation.py

Whitespace-only changes.

examples/crud/assistant_crud.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"outputs": [],
1313
"source": [
1414
"import taskingai\n",
15-
"# Load TaskingAI API Key fron environment variable"
15+
"# Load TaskingAI API Key from environment variable"
1616
]
1717
},
1818
{
1919
"cell_type": "markdown",
2020
"source": [
21-
"# Assistant Module CRUD"
21+
"# TasingAI Assistant Module CRUD"
2222
],
2323
"metadata": {
2424
"collapsed": false

examples/crud/retrieval_crud.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"source": [
1616
"import taskingai\n",
1717
"import time\n",
18-
"# Load TaskingAI API Key fron environment variable"
18+
"# Load TaskingAI API Key from environment variable"
1919
]
2020
},
2121
{
2222
"cell_type": "markdown",
2323
"source": [
24-
"# Retrieval Module CRUD"
24+
"# TasingAI Retrieval Module CRUD"
2525
],
2626
"metadata": {
2727
"collapsed": false
@@ -85,7 +85,7 @@
8585
"def create_collection() -> Collection:\n",
8686
" collection: Collection = taskingai.retrieval.create_collection(\n",
8787
" embedding_model_id=embedding_model_id,\n",
88-
" capacity=1000 # it means maximum text chunks can be stored \n",
88+
" capacity=1000 # maximum text chunks can be stored \n",
8989
" )\n",
9090
" return collection\n",
9191
"\n",
@@ -291,7 +291,7 @@
291291
"# create a new text record\n",
292292
"record: Record = taskingai.retrieval.create_text_record(\n",
293293
" collection_id=collection.collection_id,\n",
294-
" text=\"Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data. The term \\\"machine learning\\\" was coined by Arthur Samuel in 1959. In other words, machine learning enables a system to automatically learn and improve from experience without being explicitly programmed. This is achieved by feeding the system massive amounts of data, which it uses to learn patterns and make inferences. There are three main types of machine learning: 1. **Supervised Learning:** This is where the model is given labeled training data and the goal of learning is to generalize from the training data to unseen situations in a principled way. 2. **Unsupervised Learning:** This involves training on a dataset without explicit labels. The goal might be to discover inherent groupings or patterns within the data. 3. **Reinforcement Learning:** In this type, an agent learns to perform actions based on reward/penalty feedback to achieve a goal. It's commonly used in robotics, gaming, and navigation. Deep learning, a subset of machine learning, uses neural networks with many layers (\\\"deep\\\" structures) and has been responsible for many recent breakthroughs in AI, including speech recognition, image recognition, and natural language processing. It's important to note that machine learning is a rapidly developing field, with new techniques and applications emerging regularly.\"\n",
294+
" text=\"Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data. The term \\\"machine learning\\\" was coined by Arthur Samuel in 1959. In other words, machine learning enables a system to automatically learn and improve from experience without being explicitly programmed. This is achieved by feeding the system massive amounts of data, which it uses to learn patterns and make inferences. There are three main types of machine learning: 1. Supervised Learning: This is where the model is given labeled training data and the goal of learning is to generalize from the training data to unseen situations in a principled way. 2. Unsupervised Learning: This involves training on a dataset without explicit labels. The goal might be to discover inherent groupings or patterns within the data. 3. Reinforcement Learning: In this type, an agent learns to perform actions based on reward/penalty feedback to achieve a goal. It's commonly used in robotics, gaming, and navigation. Deep learning, a subset of machine learning, uses neural networks with many layers (\\\"deep\\\" structures) and has been responsible for many recent breakthroughs in AI, including speech recognition, image recognition, and natural language processing. It's important to note that machine learning is a rapidly developing field, with new techniques and applications emerging regularly.\"\n",
295295
")\n",
296296
"print(f\"created record: {record.record_id} for collection: {collection.collection_id}\\n\")"
297297
],

examples/crud/tool_crud.ipynb

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
"metadata": {
88
"collapsed": true,
99
"ExecuteTime": {
10-
"end_time": "2023-11-28T06:12:56.855519Z",
11-
"start_time": "2023-11-28T06:12:56.802199Z"
10+
"end_time": "2023-11-28T07:09:49.102426Z",
11+
"start_time": "2023-11-28T07:09:49.061326Z"
1212
}
1313
},
1414
"outputs": [],
1515
"source": [
1616
"import taskingai\n",
17-
"# Load TaskingAI API Key fron environment variable"
17+
"# Load TaskingAI API Key from environment variable"
1818
]
1919
},
2020
{
2121
"cell_type": "markdown",
2222
"source": [
23-
"# Tool Module CRUD"
23+
"# TasingAI Tool Module CRUD"
2424
],
2525
"metadata": {
2626
"collapsed": false
@@ -37,8 +37,8 @@
3737
"metadata": {
3838
"collapsed": false,
3939
"ExecuteTime": {
40-
"end_time": "2023-11-28T06:12:58.243357Z",
41-
"start_time": "2023-11-28T06:12:58.208415Z"
40+
"end_time": "2023-11-28T07:09:50.420467Z",
41+
"start_time": "2023-11-28T07:09:50.403560Z"
4242
}
4343
},
4444
"id": "1da88cd4d728ced9"
@@ -61,9 +61,9 @@
6161
"name": "stdout",
6262
"output_type": "stream",
6363
"text": [
64-
"created action: {'action_id': 'bFBdwq9eBsCHelP2Rd1mkaI8',\n",
64+
"created action: {'action_id': 'bFBdAAXYO6B0X1AbZwvEXxjA',\n",
6565
" 'authentication': {'content': None, 'secret': None, 'type': 'none'},\n",
66-
" 'created_timestamp': 1701151980773,\n",
66+
" 'created_timestamp': 1701155392625,\n",
6767
" 'object': 'Action',\n",
6868
" 'schema': {'components': {},\n",
6969
" 'info': {'description': 'API for fetching interesting number facts',\n",
@@ -154,8 +154,8 @@
154154
"metadata": {
155155
"collapsed": false,
156156
"ExecuteTime": {
157-
"end_time": "2023-11-28T06:13:00.837654Z",
158-
"start_time": "2023-11-28T06:12:59.549717Z"
157+
"end_time": "2023-11-28T07:09:52.745555Z",
158+
"start_time": "2023-11-28T07:09:51.708768Z"
159159
}
160160
},
161161
"id": "1b40bb3464107aa6"
@@ -168,9 +168,9 @@
168168
"name": "stdout",
169169
"output_type": "stream",
170170
"text": [
171-
"got action: {'action_id': 'bFBdwq9eBsCHelP2Rd1mkaI8',\n",
171+
"got action: {'action_id': 'bFBdAAXYO6B0X1AbZwvEXxjA',\n",
172172
" 'authentication': {'content': None, 'secret': None, 'type': 'none'},\n",
173-
" 'created_timestamp': 1701151980773,\n",
173+
" 'created_timestamp': 1701155392625,\n",
174174
" 'object': 'Action',\n",
175175
" 'schema': {'components': {},\n",
176176
" 'info': {'description': 'API for fetching interesting number facts',\n",
@@ -213,8 +213,8 @@
213213
"metadata": {
214214
"collapsed": false,
215215
"ExecuteTime": {
216-
"end_time": "2023-11-28T06:13:02.735027Z",
217-
"start_time": "2023-11-28T06:13:01.672743Z"
216+
"end_time": "2023-11-28T07:09:59.797187Z",
217+
"start_time": "2023-11-28T07:09:58.796202Z"
218218
}
219219
},
220220
"id": "e991bb600ca2bca9"
@@ -227,9 +227,9 @@
227227
"name": "stdout",
228228
"output_type": "stream",
229229
"text": [
230-
"updated action: {'action_id': 'bFBdwq9eBsCHelP2Rd1mkaI8',\n",
230+
"updated action: {'action_id': 'bFBdXmaIak6LBDjmNb7LFWdc',\n",
231231
" 'authentication': {'content': None, 'secret': None, 'type': 'none'},\n",
232-
" 'created_timestamp': 1701151980773,\n",
232+
" 'created_timestamp': 1701155360846,\n",
233233
" 'object': 'Action',\n",
234234
" 'schema': {'info': {'description': 'API for fetching interesting number facts',\n",
235235
" 'title': 'Numbers API',\n",
@@ -271,21 +271,52 @@
271271
"metadata": {
272272
"collapsed": false,
273273
"ExecuteTime": {
274-
"end_time": "2023-11-28T06:13:04.242253Z",
275-
"start_time": "2023-11-28T06:13:03.300837Z"
274+
"end_time": "2023-11-28T07:09:25.048213Z",
275+
"start_time": "2023-11-28T07:09:24.147021Z"
276276
}
277277
},
278278
"id": "495db38e51c0531f"
279279
},
280280
{
281281
"cell_type": "code",
282-
"execution_count": 6,
282+
"execution_count": 10,
283283
"outputs": [
284284
{
285285
"name": "stdout",
286286
"output_type": "stream",
287287
"text": [
288-
"deleted action: bFBdwq9eBsCHelP2Rd1mkaI8\n"
288+
"ran action result: {'status': 200, 'data': '127 is the atomic number of Unbiseptium, an element that has not yet been discovered.'}\n"
289+
]
290+
}
291+
],
292+
"source": [
293+
"# run action for test purpose\n",
294+
"result = taskingai.tool.run_action(\n",
295+
" action_id=action_id,\n",
296+
" parameters={\n",
297+
" \"number\": 127\n",
298+
" }\n",
299+
")\n",
300+
"print(f\"ran action result: {result}\\n\")"
301+
],
302+
"metadata": {
303+
"collapsed": false,
304+
"ExecuteTime": {
305+
"end_time": "2023-11-28T07:19:37.431926Z",
306+
"start_time": "2023-11-28T07:19:36.227121Z"
307+
}
308+
},
309+
"id": "36d4c722d4b9bd74"
310+
},
311+
{
312+
"cell_type": "code",
313+
"execution_count": 11,
314+
"outputs": [
315+
{
316+
"name": "stdout",
317+
"output_type": "stream",
318+
"text": [
319+
"deleted action: bFBdAAXYO6B0X1AbZwvEXxjA\n"
289320
]
290321
}
291322
],
@@ -297,21 +328,21 @@
297328
"metadata": {
298329
"collapsed": false,
299330
"ExecuteTime": {
300-
"end_time": "2023-11-28T06:13:05.854062Z",
301-
"start_time": "2023-11-28T06:13:04.852340Z"
331+
"end_time": "2023-11-28T07:19:39.304243Z",
332+
"start_time": "2023-11-28T07:19:38.238621Z"
302333
}
303334
},
304335
"id": "dd53cb15efa35298"
305336
},
306337
{
307338
"cell_type": "code",
308-
"execution_count": 7,
339+
"execution_count": 12,
309340
"outputs": [
310341
{
311342
"name": "stdout",
312343
"output_type": "stream",
313344
"text": [
314-
"fbFBdwq9eBsCHelP2Rd1mkaI8 in action_ids: False\n"
345+
"fbFBdAAXYO6B0X1AbZwvEXxjA in action_ids: False\n"
315346
]
316347
}
317348
],
@@ -325,8 +356,8 @@
325356
"metadata": {
326357
"collapsed": false,
327358
"ExecuteTime": {
328-
"end_time": "2023-11-28T06:13:07.841316Z",
329-
"start_time": "2023-11-28T06:13:06.744946Z"
359+
"end_time": "2023-11-28T07:19:44.780194Z",
360+
"start_time": "2023-11-28T07:19:43.747175Z"
330361
}
331362
},
332363
"id": "5a1a36d15055918f"

0 commit comments

Comments
 (0)