tako-sdk 0.1.1 → 0.1.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/README.md +1 -1
- package/dist/index.cjs +10 -3
- package/dist/index.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ const results = await tako.knowledgeSearch('AMD vs. Nvidia headcount since 2015'
|
|
|
71
71
|
|
|
72
72
|
Parameters:
|
|
73
73
|
- `text` (string): The natural language query text
|
|
74
|
-
- `sourceIndexes` (
|
|
74
|
+
- `sourceIndexes` (SourceIndex[], optional): Array of source indexes to search within. Available values: `SourceIndex.TAKO` or `SourceIndex.WEB`
|
|
75
75
|
|
|
76
76
|
Returns: `Promise<KnowledgeSearchResponse>`
|
|
77
77
|
|
package/dist/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ var TakoClient = class {
|
|
|
55
55
|
async request(path, method, body) {
|
|
56
56
|
const url = `${this.baseUrl}${path}`;
|
|
57
57
|
const headers = {
|
|
58
|
-
|
|
58
|
+
"X-API-Key": this.apiKey,
|
|
59
59
|
"Content-Type": "application/json"
|
|
60
60
|
};
|
|
61
61
|
const options = {
|
|
@@ -87,10 +87,17 @@ var TakoClient = class {
|
|
|
87
87
|
const requestBody = {
|
|
88
88
|
inputs: {
|
|
89
89
|
text,
|
|
90
|
-
...sourceIndexes && sourceIndexes.length > 0 ? { source_indexes: sourceIndexes } : {}
|
|
90
|
+
...sourceIndexes && sourceIndexes.length > 0 ? { source_indexes: sourceIndexes } : { source_indexes: ["tako" /* TAKO */] }
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
-
|
|
93
|
+
try {
|
|
94
|
+
return await this.request("/knowledge_search", "POST", requestBody);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (error.status === 404) {
|
|
97
|
+
return { outputs: { knowledge_cards: [] } };
|
|
98
|
+
}
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
};
|
|
96
103
|
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ var TakoClient = class {
|
|
|
28
28
|
async request(path, method, body) {
|
|
29
29
|
const url = `${this.baseUrl}${path}`;
|
|
30
30
|
const headers = {
|
|
31
|
-
|
|
31
|
+
"X-API-Key": this.apiKey,
|
|
32
32
|
"Content-Type": "application/json"
|
|
33
33
|
};
|
|
34
34
|
const options = {
|
|
@@ -60,10 +60,17 @@ var TakoClient = class {
|
|
|
60
60
|
const requestBody = {
|
|
61
61
|
inputs: {
|
|
62
62
|
text,
|
|
63
|
-
...sourceIndexes && sourceIndexes.length > 0 ? { source_indexes: sourceIndexes } : {}
|
|
63
|
+
...sourceIndexes && sourceIndexes.length > 0 ? { source_indexes: sourceIndexes } : { source_indexes: ["tako" /* TAKO */] }
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
|
|
66
|
+
try {
|
|
67
|
+
return await this.request("/knowledge_search", "POST", requestBody);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error.status === 404) {
|
|
70
|
+
return { outputs: { knowledge_cards: [] } };
|
|
71
|
+
}
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
67
74
|
}
|
|
68
75
|
};
|
|
69
76
|
|