tako-sdk 1.0.1 → 1.0.3

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/dist/index.js CHANGED
@@ -301,6 +301,33 @@ var TextApiResponse = class {
301
301
  }
302
302
  };
303
303
 
304
+ // src/generated/models/AgentUsage.ts
305
+ function instanceOfAgentUsage(value) {
306
+ return true;
307
+ }
308
+ function AgentUsageFromJSON(json) {
309
+ return AgentUsageFromJSONTyped(json, false);
310
+ }
311
+ function AgentUsageFromJSONTyped(json, ignoreDiscriminator) {
312
+ if (json == null) {
313
+ return json;
314
+ }
315
+ return {
316
+ "usd_cost": json["usd_cost"] == null ? void 0 : json["usd_cost"]
317
+ };
318
+ }
319
+ function AgentUsageToJSON(json) {
320
+ return AgentUsageToJSONTyped(json, false);
321
+ }
322
+ function AgentUsageToJSONTyped(value, ignoreDiscriminator = false) {
323
+ if (value == null) {
324
+ return value;
325
+ }
326
+ return {
327
+ "usd_cost": value["usd_cost"]
328
+ };
329
+ }
330
+
304
331
  // src/generated/models/KnowledgeCardMethodology.ts
305
332
  function instanceOfKnowledgeCardMethodology(value) {
306
333
  if (!("methodology_name" in value) || value["methodology_name"] === void 0) return false;
@@ -583,7 +610,8 @@ function TakoCardFromJSONTyped(json, ignoreDiscriminator) {
583
610
  "source_indexes": json["source_indexes"] == null ? void 0 : json["source_indexes"].map(KnowledgeCardSourceIndexesInnerFromJSON),
584
611
  "card_type": json["card_type"] == null ? void 0 : json["card_type"],
585
612
  "relevance": json["relevance"] == null ? void 0 : KnowledgeCardRelevanceFromJSON(json["relevance"]),
586
- "content": json["content"] == null ? void 0 : ResultContentFromJSON(json["content"])
613
+ "content": json["content"] == null ? void 0 : ResultContentFromJSON(json["content"]),
614
+ "relevance_score": json["relevance_score"] == null ? void 0 : json["relevance_score"]
587
615
  };
588
616
  }
589
617
  function TakoCardToJSON(json) {
@@ -606,7 +634,8 @@ function TakoCardToJSONTyped(value, ignoreDiscriminator = false) {
606
634
  "source_indexes": value["source_indexes"] == null ? void 0 : value["source_indexes"].map(KnowledgeCardSourceIndexesInnerToJSON),
607
635
  "card_type": value["card_type"],
608
636
  "relevance": KnowledgeCardRelevanceToJSON(value["relevance"]),
609
- "content": ResultContentToJSON(value["content"])
637
+ "content": ResultContentToJSON(value["content"]),
638
+ "relevance_score": value["relevance_score"]
610
639
  };
611
640
  }
612
641
 
@@ -684,6 +713,105 @@ function AgentResultToJSONTyped(value, ignoreDiscriminator = false) {
684
713
  };
685
714
  }
686
715
 
716
+ // src/generated/models/AgentEffortLevel.ts
717
+ var AgentEffortLevel = {
718
+ Low: "low",
719
+ Medium: "medium"
720
+ };
721
+ function instanceOfAgentEffortLevel(value) {
722
+ for (const key in AgentEffortLevel) {
723
+ if (Object.prototype.hasOwnProperty.call(AgentEffortLevel, key)) {
724
+ if (AgentEffortLevel[key] === value) {
725
+ return true;
726
+ }
727
+ }
728
+ }
729
+ return false;
730
+ }
731
+ function AgentEffortLevelFromJSON(json) {
732
+ return AgentEffortLevelFromJSONTyped(json, false);
733
+ }
734
+ function AgentEffortLevelFromJSONTyped(json, ignoreDiscriminator) {
735
+ return json;
736
+ }
737
+ function AgentEffortLevelToJSON(value) {
738
+ return value;
739
+ }
740
+ function AgentEffortLevelToJSONTyped(value, ignoreDiscriminator) {
741
+ return value;
742
+ }
743
+
744
+ // src/generated/models/AgentOutputSettings.ts
745
+ function instanceOfAgentOutputSettings(value) {
746
+ return true;
747
+ }
748
+ function AgentOutputSettingsFromJSON(json) {
749
+ return AgentOutputSettingsFromJSONTyped(json, false);
750
+ }
751
+ function AgentOutputSettingsFromJSONTyped(json, ignoreDiscriminator) {
752
+ if (json == null) {
753
+ return json;
754
+ }
755
+ return {
756
+ "image_dark_mode": json["image_dark_mode"] == null ? void 0 : json["image_dark_mode"]
757
+ };
758
+ }
759
+ function AgentOutputSettingsToJSON(json) {
760
+ return AgentOutputSettingsToJSONTyped(json, false);
761
+ }
762
+ function AgentOutputSettingsToJSONTyped(value, ignoreDiscriminator = false) {
763
+ if (value == null) {
764
+ return value;
765
+ }
766
+ return {
767
+ "image_dark_mode": value["image_dark_mode"]
768
+ };
769
+ }
770
+
771
+ // src/generated/models/AgentRunRequest.ts
772
+ var AgentRunRequestSourceIndexesEnum = {
773
+ Data: "data",
774
+ Web: "web"
775
+ };
776
+ function instanceOfAgentRunRequest(value) {
777
+ if (!("query" in value) || value["query"] === void 0) return false;
778
+ return true;
779
+ }
780
+ function AgentRunRequestFromJSON(json) {
781
+ return AgentRunRequestFromJSONTyped(json, false);
782
+ }
783
+ function AgentRunRequestFromJSONTyped(json, ignoreDiscriminator) {
784
+ if (json == null) {
785
+ return json;
786
+ }
787
+ return {
788
+ "query": json["query"],
789
+ "thread_id": json["thread_id"] == null ? void 0 : json["thread_id"],
790
+ "effort": json["effort"] == null ? void 0 : AgentEffortLevelFromJSON(json["effort"]),
791
+ "source_indexes": json["source_indexes"] == null ? void 0 : json["source_indexes"],
792
+ "locale": json["locale"] == null ? void 0 : json["locale"],
793
+ "timezone": json["timezone"] == null ? void 0 : json["timezone"],
794
+ "output_settings": json["output_settings"] == null ? void 0 : AgentOutputSettingsFromJSON(json["output_settings"])
795
+ };
796
+ }
797
+ function AgentRunRequestToJSON(json) {
798
+ return AgentRunRequestToJSONTyped(json, false);
799
+ }
800
+ function AgentRunRequestToJSONTyped(value, ignoreDiscriminator = false) {
801
+ if (value == null) {
802
+ return value;
803
+ }
804
+ return {
805
+ "query": value["query"],
806
+ "thread_id": value["thread_id"],
807
+ "effort": AgentEffortLevelToJSON(value["effort"]),
808
+ "source_indexes": value["source_indexes"],
809
+ "locale": value["locale"],
810
+ "timezone": value["timezone"],
811
+ "output_settings": AgentOutputSettingsToJSON(value["output_settings"])
812
+ };
813
+ }
814
+
687
815
  // src/generated/models/AgentRunStatus.ts
688
816
  var AgentRunStatus = {
689
817
  Queued: "queued",
@@ -770,7 +898,9 @@ function AgentRunFromJSONTyped(json, ignoreDiscriminator) {
770
898
  "created_at": json["created_at"],
771
899
  "completed_at": json["completed_at"] == null ? void 0 : json["completed_at"],
772
900
  "result": json["result"] == null ? void 0 : AgentResultFromJSON(json["result"]),
773
- "error": json["error"] == null ? void 0 : ErrorObjectFromJSON(json["error"])
901
+ "error": json["error"] == null ? void 0 : ErrorObjectFromJSON(json["error"]),
902
+ "usage": json["usage"] == null ? void 0 : AgentUsageFromJSON(json["usage"]),
903
+ "request": json["request"] == null ? void 0 : AgentRunRequestFromJSON(json["request"])
774
904
  };
775
905
  }
776
906
  function AgentRunToJSON(json) {
@@ -788,105 +918,9 @@ function AgentRunToJSONTyped(value, ignoreDiscriminator = false) {
788
918
  "created_at": value["created_at"],
789
919
  "completed_at": value["completed_at"],
790
920
  "result": AgentResultToJSON(value["result"]),
791
- "error": ErrorObjectToJSON(value["error"])
792
- };
793
- }
794
-
795
- // src/generated/models/AgentEffortLevel.ts
796
- var AgentEffortLevel = {
797
- Medium: "medium"
798
- };
799
- function instanceOfAgentEffortLevel(value) {
800
- for (const key in AgentEffortLevel) {
801
- if (Object.prototype.hasOwnProperty.call(AgentEffortLevel, key)) {
802
- if (AgentEffortLevel[key] === value) {
803
- return true;
804
- }
805
- }
806
- }
807
- return false;
808
- }
809
- function AgentEffortLevelFromJSON(json) {
810
- return AgentEffortLevelFromJSONTyped(json, false);
811
- }
812
- function AgentEffortLevelFromJSONTyped(json, ignoreDiscriminator) {
813
- return json;
814
- }
815
- function AgentEffortLevelToJSON(value) {
816
- return value;
817
- }
818
- function AgentEffortLevelToJSONTyped(value, ignoreDiscriminator) {
819
- return value;
820
- }
821
-
822
- // src/generated/models/AgentOutputSettings.ts
823
- function instanceOfAgentOutputSettings(value) {
824
- return true;
825
- }
826
- function AgentOutputSettingsFromJSON(json) {
827
- return AgentOutputSettingsFromJSONTyped(json, false);
828
- }
829
- function AgentOutputSettingsFromJSONTyped(json, ignoreDiscriminator) {
830
- if (json == null) {
831
- return json;
832
- }
833
- return {
834
- "image_dark_mode": json["image_dark_mode"] == null ? void 0 : json["image_dark_mode"]
835
- };
836
- }
837
- function AgentOutputSettingsToJSON(json) {
838
- return AgentOutputSettingsToJSONTyped(json, false);
839
- }
840
- function AgentOutputSettingsToJSONTyped(value, ignoreDiscriminator = false) {
841
- if (value == null) {
842
- return value;
843
- }
844
- return {
845
- "image_dark_mode": value["image_dark_mode"]
846
- };
847
- }
848
-
849
- // src/generated/models/AgentRunRequest.ts
850
- var AgentRunRequestSourceIndexesEnum = {
851
- Tako: "tako",
852
- Web: "web"
853
- };
854
- function instanceOfAgentRunRequest(value) {
855
- if (!("query" in value) || value["query"] === void 0) return false;
856
- return true;
857
- }
858
- function AgentRunRequestFromJSON(json) {
859
- return AgentRunRequestFromJSONTyped(json, false);
860
- }
861
- function AgentRunRequestFromJSONTyped(json, ignoreDiscriminator) {
862
- if (json == null) {
863
- return json;
864
- }
865
- return {
866
- "query": json["query"],
867
- "thread_id": json["thread_id"] == null ? void 0 : json["thread_id"],
868
- "effort": json["effort"] == null ? void 0 : AgentEffortLevelFromJSON(json["effort"]),
869
- "source_indexes": json["source_indexes"] == null ? void 0 : json["source_indexes"],
870
- "locale": json["locale"] == null ? void 0 : json["locale"],
871
- "timezone": json["timezone"] == null ? void 0 : json["timezone"],
872
- "output_settings": json["output_settings"] == null ? void 0 : AgentOutputSettingsFromJSON(json["output_settings"])
873
- };
874
- }
875
- function AgentRunRequestToJSON(json) {
876
- return AgentRunRequestToJSONTyped(json, false);
877
- }
878
- function AgentRunRequestToJSONTyped(value, ignoreDiscriminator = false) {
879
- if (value == null) {
880
- return value;
881
- }
882
- return {
883
- "query": value["query"],
884
- "thread_id": value["thread_id"],
885
- "effort": AgentEffortLevelToJSON(value["effort"]),
886
- "source_indexes": value["source_indexes"],
887
- "locale": value["locale"],
888
- "timezone": value["timezone"],
889
- "output_settings": AgentOutputSettingsToJSON(value["output_settings"])
921
+ "error": ErrorObjectToJSON(value["error"]),
922
+ "usage": AgentUsageToJSON(value["usage"]),
923
+ "request": AgentRunRequestToJSON(value["request"])
890
924
  };
891
925
  }
892
926
 
@@ -1011,6 +1045,95 @@ function AnswerResponseToJSONTyped(value, ignoreDiscriminator = false) {
1011
1045
  };
1012
1046
  }
1013
1047
 
1048
+ // src/generated/models/ClassifyRequest.ts
1049
+ function instanceOfClassifyRequest(value) {
1050
+ if (!("queries" in value) || value["queries"] === void 0) return false;
1051
+ return true;
1052
+ }
1053
+ function ClassifyRequestFromJSON(json) {
1054
+ return ClassifyRequestFromJSONTyped(json, false);
1055
+ }
1056
+ function ClassifyRequestFromJSONTyped(json, ignoreDiscriminator) {
1057
+ if (json == null) {
1058
+ return json;
1059
+ }
1060
+ return {
1061
+ "queries": json["queries"]
1062
+ };
1063
+ }
1064
+ function ClassifyRequestToJSON(json) {
1065
+ return ClassifyRequestToJSONTyped(json, false);
1066
+ }
1067
+ function ClassifyRequestToJSONTyped(value, ignoreDiscriminator = false) {
1068
+ if (value == null) {
1069
+ return value;
1070
+ }
1071
+ return {
1072
+ "queries": value["queries"]
1073
+ };
1074
+ }
1075
+
1076
+ // src/generated/models/QueryClassification.ts
1077
+ function instanceOfQueryClassification(value) {
1078
+ if (!("query" in value) || value["query"] === void 0) return false;
1079
+ if (!("score" in value) || value["score"] === void 0) return false;
1080
+ if (!("keep" in value) || value["keep"] === void 0) return false;
1081
+ return true;
1082
+ }
1083
+ function QueryClassificationFromJSON(json) {
1084
+ return QueryClassificationFromJSONTyped(json, false);
1085
+ }
1086
+ function QueryClassificationFromJSONTyped(json, ignoreDiscriminator) {
1087
+ if (json == null) {
1088
+ return json;
1089
+ }
1090
+ return {
1091
+ "query": json["query"],
1092
+ "score": json["score"],
1093
+ "keep": json["keep"]
1094
+ };
1095
+ }
1096
+ function QueryClassificationToJSON(json) {
1097
+ return QueryClassificationToJSONTyped(json, false);
1098
+ }
1099
+ function QueryClassificationToJSONTyped(value, ignoreDiscriminator = false) {
1100
+ if (value == null) {
1101
+ return value;
1102
+ }
1103
+ return {
1104
+ "query": value["query"],
1105
+ "score": value["score"],
1106
+ "keep": value["keep"]
1107
+ };
1108
+ }
1109
+
1110
+ // src/generated/models/ClassifyResponse.ts
1111
+ function instanceOfClassifyResponse(value) {
1112
+ return true;
1113
+ }
1114
+ function ClassifyResponseFromJSON(json) {
1115
+ return ClassifyResponseFromJSONTyped(json, false);
1116
+ }
1117
+ function ClassifyResponseFromJSONTyped(json, ignoreDiscriminator) {
1118
+ if (json == null) {
1119
+ return json;
1120
+ }
1121
+ return {
1122
+ "results": json["results"] == null ? void 0 : json["results"].map(QueryClassificationFromJSON)
1123
+ };
1124
+ }
1125
+ function ClassifyResponseToJSON(json) {
1126
+ return ClassifyResponseToJSONTyped(json, false);
1127
+ }
1128
+ function ClassifyResponseToJSONTyped(value, ignoreDiscriminator = false) {
1129
+ if (value == null) {
1130
+ return value;
1131
+ }
1132
+ return {
1133
+ "results": value["results"] == null ? void 0 : value["results"].map(QueryClassificationToJSON)
1134
+ };
1135
+ }
1136
+
1014
1137
  // src/generated/models/ContentsDeliveryMode.ts
1015
1138
  var ContentsDeliveryMode = {
1016
1139
  Url: "url",
@@ -1367,7 +1490,8 @@ function KnowledgeCardToJSONTyped(value, ignoreDiscriminator = false) {
1367
1490
  // src/generated/models/SearchEffortLevel.ts
1368
1491
  var SearchEffortLevel = {
1369
1492
  Fast: "fast",
1370
- Instant: "instant"
1493
+ Instant: "instant",
1494
+ Deep: "deep"
1371
1495
  };
1372
1496
  function instanceOfSearchEffortLevel(value) {
1373
1497
  for (const key in SearchEffortLevel) {
@@ -1493,7 +1617,7 @@ function SourcesFromJSONTyped(json, ignoreDiscriminator) {
1493
1617
  return json;
1494
1618
  }
1495
1619
  return {
1496
- "tako": json["tako"] == null ? void 0 : TakoSourceSettingsFromJSON(json["tako"]),
1620
+ "data": json["data"] == null ? void 0 : TakoSourceSettingsFromJSON(json["data"]),
1497
1621
  "web": json["web"] == null ? void 0 : SourceSettingsFromJSON(json["web"])
1498
1622
  };
1499
1623
  }
@@ -1505,7 +1629,7 @@ function SourcesToJSONTyped(value, ignoreDiscriminator = false) {
1505
1629
  return value;
1506
1630
  }
1507
1631
  return {
1508
- "tako": TakoSourceSettingsToJSON(value["tako"]),
1632
+ "data": TakoSourceSettingsToJSON(value["data"]),
1509
1633
  "web": SourceSettingsToJSON(value["web"])
1510
1634
  };
1511
1635
  }
@@ -1622,6 +1746,42 @@ var TakoApi = class extends BaseAPI {
1622
1746
  const response = await this.answerRaw(requestParameters, initOverrides);
1623
1747
  return await response.value();
1624
1748
  }
1749
+ /**
1750
+ * Creates request options for classify without sending the request
1751
+ */
1752
+ async classifyRequestOpts(requestParameters) {
1753
+ const queryParameters = {};
1754
+ const headerParameters = {};
1755
+ headerParameters["Content-Type"] = "application/json";
1756
+ if (this.configuration && this.configuration.apiKey) {
1757
+ headerParameters["X-API-Key"] = await this.configuration.apiKey("X-API-Key");
1758
+ }
1759
+ let urlPath = `/v1/classify`;
1760
+ return {
1761
+ path: urlPath,
1762
+ method: "POST",
1763
+ headers: headerParameters,
1764
+ query: queryParameters,
1765
+ body: ClassifyRequestToJSON(requestParameters["classifyRequest"])
1766
+ };
1767
+ }
1768
+ /**
1769
+ * Score a batch of queries for whether Tako search will return a result. Returns a probability and a recall-skewed keep flag per query. Free; intended for pre-filtering before /v3/search.
1770
+ * Classify queries
1771
+ */
1772
+ async classifyRaw(requestParameters, initOverrides) {
1773
+ const requestOptions = await this.classifyRequestOpts(requestParameters);
1774
+ const response = await this.request(requestOptions, initOverrides);
1775
+ return new JSONApiResponse(response, (jsonValue) => ClassifyResponseFromJSON(jsonValue));
1776
+ }
1777
+ /**
1778
+ * Score a batch of queries for whether Tako search will return a result. Returns a probability and a recall-skewed keep flag per query. Free; intended for pre-filtering before /v3/search.
1779
+ * Classify queries
1780
+ */
1781
+ async classify(requestParameters = {}, initOverrides) {
1782
+ const response = await this.classifyRaw(requestParameters, initOverrides);
1783
+ return await response.value();
1784
+ }
1625
1785
  /**
1626
1786
  * Creates request options for contents without sending the request
1627
1787
  */
@@ -1740,7 +1900,8 @@ var APIErrorType = {
1740
1900
  PaymentRequired: "PAYMENT_REQUIRED",
1741
1901
  RequestTimeout: "REQUEST_TIMEOUT",
1742
1902
  Forbidden: "FORBIDDEN",
1743
- NotFound: "NOT_FOUND"
1903
+ NotFound: "NOT_FOUND",
1904
+ ServiceUnavailable: "SERVICE_UNAVAILABLE"
1744
1905
  };
1745
1906
  function instanceOfAPIErrorType(value) {
1746
1907
  for (const key in APIErrorType) {
@@ -2770,6 +2931,10 @@ export {
2770
2931
  AgentStreamEnvelopeFromJSONTyped,
2771
2932
  AgentStreamEnvelopeToJSON,
2772
2933
  AgentStreamEnvelopeToJSONTyped,
2934
+ AgentUsageFromJSON,
2935
+ AgentUsageFromJSONTyped,
2936
+ AgentUsageToJSON,
2937
+ AgentUsageToJSONTyped,
2773
2938
  AnswerResponseFromJSON,
2774
2939
  AnswerResponseFromJSONTyped,
2775
2940
  AnswerResponseToJSON,
@@ -2799,6 +2964,14 @@ export {
2799
2964
  CardSourcePrivateIndexFromJSONTyped,
2800
2965
  CardSourcePrivateIndexToJSON,
2801
2966
  CardSourcePrivateIndexToJSONTyped,
2967
+ ClassifyRequestFromJSON,
2968
+ ClassifyRequestFromJSONTyped,
2969
+ ClassifyRequestToJSON,
2970
+ ClassifyRequestToJSONTyped,
2971
+ ClassifyResponseFromJSON,
2972
+ ClassifyResponseFromJSONTyped,
2973
+ ClassifyResponseToJSON,
2974
+ ClassifyResponseToJSONTyped,
2802
2975
  ComponentConfigFromJSON,
2803
2976
  ComponentConfigFromJSONTyped,
2804
2977
  ComponentConfigToJSON,
@@ -2885,6 +3058,10 @@ export {
2885
3058
  OutputSettingsFromJSONTyped,
2886
3059
  OutputSettingsToJSON,
2887
3060
  OutputSettingsToJSONTyped,
3061
+ QueryClassificationFromJSON,
3062
+ QueryClassificationFromJSONTyped,
3063
+ QueryClassificationToJSON,
3064
+ QueryClassificationToJSONTyped,
2888
3065
  ReasoningEventFromJSON,
2889
3066
  ReasoningEventFromJSONTyped,
2890
3067
  ReasoningEventKindEnum,
@@ -2999,11 +3176,14 @@ export {
2999
3176
  instanceOfAgentRunRequest,
3000
3177
  instanceOfAgentRunStatus,
3001
3178
  instanceOfAgentStreamEnvelope,
3179
+ instanceOfAgentUsage,
3002
3180
  instanceOfAnswerResponse,
3003
3181
  instanceOfBaseAPIError,
3004
3182
  instanceOfCardSourceIndex,
3005
3183
  instanceOfCardSourceIndexSegment,
3006
3184
  instanceOfCardSourcePrivateIndex,
3185
+ instanceOfClassifyRequest,
3186
+ instanceOfClassifyResponse,
3007
3187
  instanceOfComponentConfig,
3008
3188
  instanceOfComponentTypeEnum,
3009
3189
  instanceOfContentFormat,
@@ -3023,6 +3203,7 @@ export {
3023
3203
  instanceOfKnowledgeCardSource,
3024
3204
  instanceOfKnowledgeCardSourceIndexesInner,
3025
3205
  instanceOfOutputSettings,
3206
+ instanceOfQueryClassification,
3026
3207
  instanceOfReasoningEvent,
3027
3208
  instanceOfResultContent,
3028
3209
  instanceOfSearchEffortLevel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tako-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "JavaScript/TypeScript SDK for the Tako API",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",