@tool-bridge/server 0.21.1 → 0.22.1
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/admin.js +170 -0
- package/dist/airtable-ML2GIGCH.js +790 -0
- package/dist/{alt_text_generator_ai-W7O34SNG.js → alt_text_generator_ai-FGYQAF2A.js} +12 -11
- package/dist/{amap-VOX4T2AW.js → amap-G7V65NGK.js} +221 -220
- package/dist/anthropic-6ZK24TBB.js +203 -0
- package/dist/apify-VDGYHP6W.js +248 -0
- package/dist/brave_search-TAATLZOS.js +302 -0
- package/dist/chunk-2IAI3XQM.js +302 -0
- package/dist/chunk-7ISGFRC6.js +161 -0
- package/dist/{chunk-E6JCVKW6.js → chunk-BNMLA2RC.js} +3 -3
- package/dist/chunk-HA4BGL6C.js +8429 -0
- package/dist/{chunk-KMTT3I6D.js → chunk-RMAWSG7E.js} +19172 -25717
- package/dist/{chunk-XYBU3WZH.js → chunk-RTW5VRTK.js} +3 -3
- package/dist/chunk-U7PTOA3U.js +7320 -0
- package/dist/chunk-UY6ANCOY.js +378 -0
- package/dist/{chunk-ATK45BXV.js → chunk-X7ZUTKHR.js} +4 -2
- package/dist/circleci-BQ2UWXL2.js +389 -0
- package/dist/clerk-2JYWQNOI.js +1019 -0
- package/dist/cohere-6MI7AQM4.js +185 -0
- package/dist/{confluence-B3EWPZVE.js → confluence-6Y6GDETF.js} +105 -104
- package/dist/{convertapi-EUWSQYPF.js → convertapi-HBZCSWOX.js} +32 -31
- package/dist/{currencyapi-KVTIK3GL.js → currencyapi-337U5TGI.js} +71 -71
- package/dist/deepseek-OSPASO7O.js +210 -0
- package/dist/docker_hub-3ATQOY5L.js +933 -0
- package/dist/dropbox-LSA4GM2Y.js +1305 -0
- package/dist/dub-VZPJSPI6.js +680 -0
- package/dist/e2b-6SDYQZL2.js +278 -0
- package/dist/exa-B6EUYDVP.js +332 -0
- package/dist/{fal_ai-23E7JPNT.js → fal_ai-K4Q27IME.js} +81 -80
- package/dist/{feishu-7QRIDUV6.js → feishu-4TKXG4SU.js} +528 -572
- package/dist/{feishu_custom_bot-TJ4K7QNJ.js → feishu_custom_bot-7CTEAKRB.js} +57 -53
- package/dist/figma-OUKSZLD5.js +777 -0
- package/dist/firehydrant-7MOYL7QH.js +563 -0
- package/dist/{fixer-BWON27UO.js → fixer-H2BV2NO4.js} +34 -33
- package/dist/fly-PXKY6PNH.js +469 -0
- package/dist/{front-QCGXYEDJ.js → front-UZYIV5DW.js} +104 -104
- package/dist/geocodio-NSYO7TFP.js +213 -0
- package/dist/ghost-QBKKQQMF.js +338 -0
- package/dist/github-ENLSJ4CL.js +5421 -0
- package/dist/gmail-KQSDEB47.js +1887 -0
- package/dist/googlecalendar-5YCX4SZF.js +2524 -0
- package/dist/{googledocs-BUHL4J2H.js → googledocs-SSWIVFKA.js} +341 -340
- package/dist/{grafana-GLU2DWF2.js → grafana-TF2LXDQA.js} +221 -220
- package/dist/graphhopper-CURBVHYK.js +325 -0
- package/dist/index.d.ts +1132 -332
- package/dist/index.js +31 -14
- package/dist/{ip2proxy-EZ64Y4ZH.js → ip2proxy-YNVMTZEM.js} +28 -27
- package/dist/ipgeolocation_io-NAU7VJ4J.js +315 -0
- package/dist/ipqualityscore-OT63L4TI.js +279 -0
- package/dist/{jina_ai-EFBHTBXL.js → jina_ai-6WBMBGWM.js} +23 -23
- package/dist/{jira-HQSHAA5K.js → jira-DVDVTHNO.js} +118 -117
- package/dist/langsmith-IM5N4YAU.js +593 -0
- package/dist/lemlist-277SHUQF.js +289 -0
- package/dist/{linear-K7RYFYAD.js → linear-AEPH7B5V.js} +327 -326
- package/dist/logsnag-VEWRAGBG.js +150 -0
- package/dist/main.js +57 -280
- package/dist/{mattermost-S2BRCWLQ.js → mattermost-Q3A2BIZA.js} +59 -58
- package/dist/mem0-AXS7GZGI.js +544 -0
- package/dist/memos-7TXG4ZTU.js +744 -0
- package/dist/{metabase-MMSEPCOF.js → metabase-NSVACWQM.js} +90 -89
- package/dist/mistral_ai-YZ52RGD4.js +1196 -0
- package/dist/{mother_duck-H7PCQNZ2.js → mother_duck-XLLL6FVL.js} +94 -93
- package/dist/ngrok-4O4W3WZW.js +356 -0
- package/dist/{notes-PFMKRO33.js → notes-YTB3TJOO.js} +11 -9
- package/dist/notion-4W4O7J7V.js +940 -0
- package/dist/open_exchange_rates-23QJXVO5.js +215 -0
- package/dist/openai-ZS7GLSLH.js +800 -0
- package/dist/opengraph_io-PMVH7OYI.js +362 -0
- package/dist/openrouter-ONRGFNB6.js +441 -0
- package/dist/outline-UCUYZZ7J.js +599 -0
- package/dist/paddle-35HTKTUL.js +454 -0
- package/dist/perplexity-NVOBYN24.js +220 -0
- package/dist/pinecone-55CJY73C.js +571 -0
- package/dist/{pipedrive-Y2O7QGFF.js → pipedrive-WMCAKS72.js} +99 -98
- package/dist/polar-SM4ZM53B.js +395 -0
- package/dist/posthog-NWCXVXNJ.js +3464 -0
- package/dist/postmark-QJV5PHUQ.js +427 -0
- package/dist/{prerender-MENYM2TY.js → prerender-2W7UT4SC.js} +31 -30
- package/dist/{pubmed-GOXUVVH5.js → pubmed-VVV7XYLU.js} +239 -238
- package/dist/{railway-V2SID4WV.js → railway-KGI57S3O.js} +118 -117
- package/dist/readwise-AGHTQB42.js +470 -0
- package/dist/render-O4HBROCK.js +461 -0
- package/dist/{replicate-756MXPYX.js → replicate-KWBOMX7D.js} +81 -80
- package/dist/{resend-ZKH3BTBI.js → resend-DRH6Y6I4.js} +20 -16
- package/dist/rootly-XGCUDW6X.js +336 -0
- package/dist/{scrapfly-NSRHFDIQ.js → scrapfly-OIQ3OY6L.js} +62 -61
- package/dist/{scrapingbee-OQHLAVEY.js → scrapingbee-OCZO4FHX.js} +56 -56
- package/dist/{screenshot_fyi-DVWG3AXC.js → screenshot_fyi-CUNGFZOC.js} +16 -16
- package/dist/semantic_scholar-3UJRLKES.js +611 -0
- package/dist/{sentry-546MNDJG.js → sentry-5BWVZFJV.js} +208 -207
- package/dist/{shodan-C3OON3Z3.js → shodan-HI37CTEW.js} +62 -61
- package/dist/shopify-LJ2EV2HH.js +610 -0
- package/dist/stripe-3LHMV55K.js +585 -0
- package/dist/{supabase-U2SL4D63.js → supabase-H2KPX3Q2.js} +245 -244
- package/dist/tavily-FBEWGH3Z.js +326 -0
- package/dist/telegram-MYYO3JND.js +1767 -0
- package/dist/{telnyx-CXQ4EZUX.js → telnyx-H4ALEGAX.js} +57 -56
- package/dist/todoist-OBWICA5Q.js +664 -0
- package/dist/trello-GUFUJRWO.js +1080 -0
- package/dist/turso-NIAK4UMS.js +416 -0
- package/dist/{twilio-4PDBJKWX.js → twilio-K6SLK2CX.js} +70 -69
- package/dist/umami-42RS2EPS.js +389 -0
- package/dist/unsplash-V7TOTETT.js +351 -0
- package/dist/{upstash_redis-G4LQBYHA.js → upstash_redis-AWQMB6Y3.js} +51 -50
- package/dist/uptimerobot-AZC2DHOT.js +483 -0
- package/dist/v2ex-4TVRNMLS.js +667 -0
- package/dist/vercel-DPHTJ3XR.js +1076 -0
- package/dist/{wolfram_alpha_api-3G4PUJWB.js → wolfram_alpha_api-XAG7IXBW.js} +36 -35
- package/dist/wordpress-KMPKVGUX.js +812 -0
- package/dist/workos-PKB2YR7S.js +664 -0
- package/dist/zhihu-Y4H4XYPB.js +254 -0
- package/package.json +18 -9
- package/dist/airtable-LLZDFN7M.js +0 -789
- package/dist/anthropic-G23NN3X5.js +0 -202
- package/dist/apify-Y3SS734K.js +0 -247
- package/dist/brave_search-ZC7OAPSZ.js +0 -301
- package/dist/chunk-R6P4XAE5.js +0 -248
- package/dist/chunk-U7B6DS2O.js +0 -977
- package/dist/chunk-UZM2RXZH.js +0 -23436
- package/dist/circleci-3BAX5FCG.js +0 -388
- package/dist/clerk-6LEM6TNU.js +0 -1019
- package/dist/cloudflare_dns-KINYTJUD.js +0 -588
- package/dist/cohere-XCJ5AJ6B.js +0 -185
- package/dist/deepseek-PC5YGNC5.js +0 -209
- package/dist/docker_hub-C3MA5FU6.js +0 -932
- package/dist/dropbox-XBV7Z2IR.js +0 -1304
- package/dist/dub-LDOFG3HC.js +0 -679
- package/dist/e2b-JMCPSVBW.js +0 -277
- package/dist/exa-RAK7O7RD.js +0 -331
- package/dist/figma-E6IX5DTH.js +0 -773
- package/dist/firehydrant-ZBLPQREE.js +0 -562
- package/dist/fly-ZH3HFCZJ.js +0 -468
- package/dist/geocodio-YGNI7DA4.js +0 -212
- package/dist/ghost-EVSGKH2Q.js +0 -337
- package/dist/github-MA2BGRCJ.js +0 -5420
- package/dist/gmail-E5E6AADE.js +0 -1886
- package/dist/googlecalendar-BTLFPXTD.js +0 -2523
- package/dist/graphhopper-WSMB3TCD.js +0 -324
- package/dist/ipgeolocation_io-AA7HAS22.js +0 -315
- package/dist/ipqualityscore-BHJXVTJT.js +0 -277
- package/dist/langsmith-5W6SCT6F.js +0 -592
- package/dist/lemlist-HJWH6UMK.js +0 -288
- package/dist/logsnag-4KFOHL37.js +0 -150
- package/dist/mem0-CAW43CIC.js +0 -543
- package/dist/memos-TWEGPKFM.js +0 -740
- package/dist/mistral_ai-64BGZQHP.js +0 -1195
- package/dist/ngrok-GQCUGZKJ.js +0 -356
- package/dist/notion-DQWZWP4N.js +0 -936
- package/dist/open_exchange_rates-QMMD735E.js +0 -214
- package/dist/openai-W6PX32NZ.js +0 -799
- package/dist/opengraph_io-HNDBXYNW.js +0 -361
- package/dist/openrouter-JJYMEAUL.js +0 -437
- package/dist/outline-MCBNQZYY.js +0 -595
- package/dist/paddle-D2SKLUDN.js +0 -453
- package/dist/perplexity-XIFMKUAE.js +0 -219
- package/dist/pinecone-HUFTALV2.js +0 -570
- package/dist/polar-TYTOMOSR.js +0 -394
- package/dist/posthog-43JAR3VW.js +0 -3463
- package/dist/postmark-KL2QJYSG.js +0 -426
- package/dist/readwise-CI4GIMMJ.js +0 -469
- package/dist/render-SUBJ6YRZ.js +0 -460
- package/dist/rootly-CD2LJHPI.js +0 -336
- package/dist/semantic_scholar-T4A252KW.js +0 -610
- package/dist/shopify-Y2HN2MCQ.js +0 -609
- package/dist/stripe-VE3CD3AY.js +0 -584
- package/dist/tavily-KCZHK6HE.js +0 -326
- package/dist/telegram-3URFBCMY.js +0 -1766
- package/dist/todoist-HNPWNYTD.js +0 -663
- package/dist/trello-3W2MIXRP.js +0 -1079
- package/dist/turso-2EQF7C2Z.js +0 -415
- package/dist/umami-5REN7TGP.js +0 -388
- package/dist/unsplash-EIXL424F.js +0 -350
- package/dist/uptimerobot-KNJ3EYLY.js +0 -482
- package/dist/v2ex-RHJ234PZ.js +0 -666
- package/dist/vercel-AS6NCIC7.js +0 -1075
- package/dist/wordpress-KNDAAUV7.js +0 -811
- package/dist/workos-R6UITSJ7.js +0 -663
- package/dist/zhihu-AGK4HILK.js +0 -253
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createAuthedClient
|
|
3
|
+
} from "./chunk-RTW5VRTK.js";
|
|
4
|
+
import "./chunk-BNMLA2RC.js";
|
|
5
|
+
import "./chunk-JXHMDBAY.js";
|
|
6
|
+
import {
|
|
7
|
+
createProviderPlugin,
|
|
8
|
+
upstreamError
|
|
9
|
+
} from "./chunk-X7ZUTKHR.js";
|
|
10
|
+
import "./chunk-7ISGFRC6.js";
|
|
11
|
+
import "./chunk-UY6ANCOY.js";
|
|
12
|
+
import {
|
|
13
|
+
TBError
|
|
14
|
+
} from "./chunk-HA4BGL6C.js";
|
|
15
|
+
import "./chunk-U67V476Y.js";
|
|
16
|
+
|
|
17
|
+
// ../plugins/src/perplexity/api.ts
|
|
18
|
+
var SERVICE = "perplexity";
|
|
19
|
+
var API_BASE = "https://api.perplexity.ai";
|
|
20
|
+
var http = createAuthedClient({
|
|
21
|
+
baseUrl: API_BASE,
|
|
22
|
+
service: SERVICE,
|
|
23
|
+
auth: { kind: "bearer" },
|
|
24
|
+
headers: { accept: "application/json" },
|
|
25
|
+
errorMessage: {
|
|
26
|
+
keys: ["error.message", "error.detail", "message", "detail"],
|
|
27
|
+
fallback: (status) => `perplexity request failed with ${status}`
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
var EMBEDDING_MIN_DIMENSIONS = 128;
|
|
31
|
+
var EMBEDDING_MAX_DIMENSIONS = { "pplx-embed-v1-0.6b": 1024 };
|
|
32
|
+
var EMBEDDING_MAX_DIMENSIONS_FALLBACK = 2560;
|
|
33
|
+
async function request(ctx, method, path, body) {
|
|
34
|
+
const { data } = await http.request(ctx, {
|
|
35
|
+
path,
|
|
36
|
+
method,
|
|
37
|
+
// 上游先过一道 `compactObject`;JSON.stringify 本来就丢 undefined 值,故不再重复一遍。
|
|
38
|
+
...method === "POST" ? { json: body ?? {} } : {},
|
|
39
|
+
invalidJsonMessage: "Perplexity \u8FD4\u56DE\u4E86\u975E JSON \u54CD\u5E94",
|
|
40
|
+
// 消息里带着本次的 method/path,只能逐请求给,不能挪到 client 级。
|
|
41
|
+
mapTransportError: ({ message }) => upstreamError(
|
|
42
|
+
502,
|
|
43
|
+
`perplexity ${method} ${path} failed before receiving response: ${message ?? "unknown network error"}`
|
|
44
|
+
)
|
|
45
|
+
});
|
|
46
|
+
return data ?? null;
|
|
47
|
+
}
|
|
48
|
+
function assertStreamingDisabled(input) {
|
|
49
|
+
if (input.stream === true) {
|
|
50
|
+
throw new TBError("invalid_argument", "stream=true is not supported by connector actions");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function assertEmbeddingDimensions(input) {
|
|
54
|
+
const dimensions = input.dimensions;
|
|
55
|
+
if (dimensions === void 0) return;
|
|
56
|
+
const max = EMBEDDING_MAX_DIMENSIONS[input.model] ?? EMBEDDING_MAX_DIMENSIONS_FALLBACK;
|
|
57
|
+
if (dimensions < EMBEDDING_MIN_DIMENSIONS || dimensions > max) {
|
|
58
|
+
throw new TBError(
|
|
59
|
+
"invalid_argument",
|
|
60
|
+
`${input.model} dimensions must be between ${EMBEDDING_MIN_DIMENSIONS} and ${max}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function listModels(_input, ctx) {
|
|
65
|
+
return request(ctx, "GET", "/v1/models");
|
|
66
|
+
}
|
|
67
|
+
async function search(input, ctx) {
|
|
68
|
+
return request(ctx, "POST", "/search", input);
|
|
69
|
+
}
|
|
70
|
+
async function createChatCompletion(input, ctx) {
|
|
71
|
+
assertStreamingDisabled(input);
|
|
72
|
+
return request(ctx, "POST", "/v1/sonar", input);
|
|
73
|
+
}
|
|
74
|
+
async function createEmbeddings(input, ctx) {
|
|
75
|
+
assertEmbeddingDimensions(input);
|
|
76
|
+
return request(ctx, "POST", "/v1/embeddings", input);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ../plugins/src/perplexity/schema.ts
|
|
80
|
+
import { z } from "zod/v4";
|
|
81
|
+
var listModelsInput = z.strictObject({}).describe("No input parameters are required for this action.");
|
|
82
|
+
var listModelsOutput = z.looseObject({
|
|
83
|
+
object: z.string().describe("The top-level object type.").optional(),
|
|
84
|
+
data: z.array(z.looseObject({
|
|
85
|
+
id: z.string().describe("The model identifier."),
|
|
86
|
+
object: z.string().describe("The object type returned by the API.").optional(),
|
|
87
|
+
created: z.int().describe("The Unix timestamp when the model metadata was created.").optional(),
|
|
88
|
+
owned_by: z.string().describe("The organization or owner that provides the model.").optional(),
|
|
89
|
+
type: z.string().describe("The model family or type.").optional()
|
|
90
|
+
}).describe("A Perplexity model entry.")).describe("The list of available models.")
|
|
91
|
+
}).describe("The response payload for listing Perplexity models.");
|
|
92
|
+
var searchInput = z.strictObject({
|
|
93
|
+
query: z.union([z.string().min(1).describe("One or more raw web search queries."), z.array(z.string().min(1).describe("One raw web search query.")).min(1).describe("One raw web search query.")]).describe("One or more raw web search queries."),
|
|
94
|
+
country: z.string().min(2).max(2).describe("The ISO 3166-1 alpha-2 country code used to localize search results.").optional(),
|
|
95
|
+
max_results: z.int().min(1).max(20).describe("The maximum number of search results to return.").optional(),
|
|
96
|
+
search_after_date: z.string().describe("Only return content published after this date, for example 01/15/2024.").optional(),
|
|
97
|
+
search_before_date: z.string().describe("Only return content published before this date, for example 12/31/2024.").optional(),
|
|
98
|
+
max_tokens_per_page: z.int().min(1).describe("The maximum number of tokens to retrieve from each webpage.").optional(),
|
|
99
|
+
search_domain_filter: z.array(z.string().min(1).describe("A domain or URL prefix used to filter results.")).max(20).describe("Only return search results from these domains or URL prefixes.").optional()
|
|
100
|
+
}).describe("The input payload for the raw Perplexity web search action.");
|
|
101
|
+
var searchOutput = z.looseObject({
|
|
102
|
+
results: z.array(z.looseObject({
|
|
103
|
+
title: z.string().describe("The search result title.").optional(),
|
|
104
|
+
url: z.string().describe("The canonical URL of the result.").optional(),
|
|
105
|
+
snippet: z.string().describe("A short snippet extracted from the result page.").optional(),
|
|
106
|
+
date: z.string().describe("The published date reported for the result.").optional(),
|
|
107
|
+
last_updated: z.string().describe("The last updated date reported for the result.").optional()
|
|
108
|
+
}).describe("A raw search result returned by Perplexity.")).describe("The ranked raw search results.").optional()
|
|
109
|
+
}).describe("The response payload for the raw search action.");
|
|
110
|
+
var createChatCompletionInput = z.strictObject({
|
|
111
|
+
model: z.string().describe("The Sonar model to use for the chat completion."),
|
|
112
|
+
messages: z.array(z.strictObject({
|
|
113
|
+
role: z.enum(["system", "user", "assistant"]).describe("The role of the message author.").optional(),
|
|
114
|
+
content: z.string().describe("The plain-text message content.").optional()
|
|
115
|
+
}).describe("A chat message.")).min(1).describe("The ordered conversation messages."),
|
|
116
|
+
max_tokens: z.int().min(1).describe("The maximum number of tokens to generate.").optional(),
|
|
117
|
+
temperature: z.number().min(0).max(2).describe("The sampling temperature for generation.").optional(),
|
|
118
|
+
top_p: z.number().min(0).max(1).describe("The nucleus sampling threshold.").optional(),
|
|
119
|
+
top_k: z.int().min(0).describe("The number of top tokens to consider per step.").optional(),
|
|
120
|
+
stream: z.boolean().describe("Whether to stream the response. This connector only accepts false or an omitted value.").optional(),
|
|
121
|
+
return_images: z.boolean().describe("Whether to include image references in the response.").optional(),
|
|
122
|
+
return_citations: z.boolean().describe("Whether to include citations in the response.").optional(),
|
|
123
|
+
disable_search: z.boolean().describe("Whether to disable web search grounding for this request.").optional(),
|
|
124
|
+
search_domain_filter: z.array(z.string().min(1).describe("A domain or URL prefix used to limit web search.")).describe("Only search within these domains or URL prefixes.").optional(),
|
|
125
|
+
search_recency_filter: z.string().describe("A recency filter such as day, week, month, or year.").optional(),
|
|
126
|
+
presence_penalty: z.number().min(-2).max(2).describe("The penalty applied to tokens that have already appeared.").optional(),
|
|
127
|
+
frequency_penalty: z.number().min(0).max(2).describe("The penalty applied based on token frequency.").optional()
|
|
128
|
+
}).describe("The input payload for the Perplexity chat completion action.");
|
|
129
|
+
var createChatCompletionOutput = z.looseObject({
|
|
130
|
+
id: z.string().describe("The completion identifier.").optional(),
|
|
131
|
+
model: z.string().describe("The model that generated the completion.").optional(),
|
|
132
|
+
created: z.int().describe("The Unix timestamp when the completion was created.").optional(),
|
|
133
|
+
choices: z.array(z.looseObject({
|
|
134
|
+
index: z.int().describe("The choice index.").optional(),
|
|
135
|
+
finish_reason: z.string().describe("The reason why generation stopped.").optional(),
|
|
136
|
+
message: z.looseObject({
|
|
137
|
+
role: z.string().describe("The role of the generated message.").optional(),
|
|
138
|
+
content: z.string().describe("The generated message content.").optional()
|
|
139
|
+
}).describe("The generated message.").optional()
|
|
140
|
+
}).describe("A single generated completion choice.")).describe("The completion choices."),
|
|
141
|
+
citations: z.array(z.string().min(1).describe("A citation URL returned with the response.")).describe("The citation URLs referenced by the answer.").optional(),
|
|
142
|
+
search_results: z.array(z.looseObject({
|
|
143
|
+
title: z.string().describe("The search result title.").optional(),
|
|
144
|
+
url: z.string().describe("The canonical URL of the result.").optional(),
|
|
145
|
+
snippet: z.string().describe("A short snippet extracted from the result page.").optional(),
|
|
146
|
+
date: z.string().describe("The published date reported for the result.").optional(),
|
|
147
|
+
last_updated: z.string().describe("The last updated date reported for the result.").optional()
|
|
148
|
+
}).describe("A raw search result returned by Perplexity.")).describe("The search results used to ground the response.").optional(),
|
|
149
|
+
usage: z.looseObject({
|
|
150
|
+
prompt_tokens: z.int().describe("The number of prompt tokens consumed.").optional(),
|
|
151
|
+
completion_tokens: z.int().describe("The number of completion tokens generated.").optional(),
|
|
152
|
+
total_tokens: z.int().describe("The total number of tokens consumed.").optional()
|
|
153
|
+
}).describe("Token usage metadata for the completion.").optional()
|
|
154
|
+
}).describe("The response payload for the chat completion action.");
|
|
155
|
+
var createEmbeddingsInput = z.strictObject({
|
|
156
|
+
model: z.enum(["pplx-embed-v1-0.6b", "pplx-embed-v1-4b"]).describe("The embedding model identifier."),
|
|
157
|
+
input: z.union([z.string().min(1).describe("One or more input strings to embed."), z.array(z.string().min(1).describe("One input string to embed.")).min(1).max(512).describe("One input string to embed.")]).describe("One or more input strings to embed."),
|
|
158
|
+
dimensions: z.int().describe("The target embedding dimension count.").optional(),
|
|
159
|
+
encoding_format: z.enum(["base64_int8", "base64_binary"]).describe("The output encoding format for embeddings.").optional()
|
|
160
|
+
}).describe("The input payload for the embeddings action.");
|
|
161
|
+
var createEmbeddingsOutput = z.looseObject({
|
|
162
|
+
object: z.string().describe("The top-level object type.").optional(),
|
|
163
|
+
model: z.string().describe("The embedding model that generated the output.").optional(),
|
|
164
|
+
data: z.array(z.looseObject({
|
|
165
|
+
object: z.string().describe("The object type for the embedding item.").optional(),
|
|
166
|
+
index: z.int().describe("The zero-based embedding index.").optional(),
|
|
167
|
+
embedding: z.union([z.array(z.number().describe("One embedding vector value.")).describe("The numeric embedding vector."), z.string().describe("The encoded embedding value.")]).describe("The embedding payload.").optional()
|
|
168
|
+
}).describe("A single embedding item.")).describe("The generated embeddings."),
|
|
169
|
+
usage: z.looseObject({
|
|
170
|
+
prompt_tokens: z.int().describe("The number of prompt tokens consumed.").optional(),
|
|
171
|
+
total_tokens: z.int().describe("The total number of tokens consumed.").optional()
|
|
172
|
+
}).describe("Usage information for the embeddings request.").optional()
|
|
173
|
+
}).describe("The response payload for the embeddings action.");
|
|
174
|
+
var perplexityActions = {
|
|
175
|
+
list_models: {
|
|
176
|
+
description: "List the models currently available from Perplexity.",
|
|
177
|
+
effect: "read",
|
|
178
|
+
inputSchema: listModelsInput,
|
|
179
|
+
outputSchema: z.toJSONSchema(listModelsOutput, { io: "output", unrepresentable: "any" })
|
|
180
|
+
},
|
|
181
|
+
search: {
|
|
182
|
+
description: "Search the web and return ranked raw results from Perplexity without LLM synthesis.",
|
|
183
|
+
effect: "write",
|
|
184
|
+
inputSchema: searchInput,
|
|
185
|
+
outputSchema: z.toJSONSchema(searchOutput, { io: "output", unrepresentable: "any" })
|
|
186
|
+
},
|
|
187
|
+
create_chat_completion: {
|
|
188
|
+
description: "Create a Perplexity Sonar chat completion grounded by web search when enabled.",
|
|
189
|
+
effect: "write",
|
|
190
|
+
inputSchema: createChatCompletionInput,
|
|
191
|
+
outputSchema: z.toJSONSchema(createChatCompletionOutput, { io: "output", unrepresentable: "any" })
|
|
192
|
+
},
|
|
193
|
+
create_embeddings: {
|
|
194
|
+
description: "Generate vector embeddings for one or more input strings with Perplexity.",
|
|
195
|
+
effect: "write",
|
|
196
|
+
inputSchema: createEmbeddingsInput,
|
|
197
|
+
outputSchema: z.toJSONSchema(createEmbeddingsOutput, { io: "output", unrepresentable: "any" })
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// ../plugins/src/perplexity/index.ts
|
|
202
|
+
function createPerplexityPlugin() {
|
|
203
|
+
return createProviderPlugin({
|
|
204
|
+
description: "Perplexity",
|
|
205
|
+
actions: perplexityActions,
|
|
206
|
+
// 上游 credentialValidators 也打 /v1/models —— 只读、无必填入参,正好当挂载时的凭证探针。
|
|
207
|
+
credentialProbe: "list_models",
|
|
208
|
+
handlers: {
|
|
209
|
+
list_models: listModels,
|
|
210
|
+
search,
|
|
211
|
+
create_chat_completion: createChatCompletion,
|
|
212
|
+
create_embeddings: createEmbeddings
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
var perplexity_default = createPerplexityPlugin();
|
|
217
|
+
export {
|
|
218
|
+
createPerplexityPlugin,
|
|
219
|
+
perplexity_default as default
|
|
220
|
+
};
|