Skip to content

Commit 0b097d4

Browse files
authored
feat(fai-chat): add support for conditoinal query decomposition per enablement (#5941)
1 parent a1df23e commit 0b097d4

File tree

31 files changed

+191
-450
lines changed

31 files changed

+191
-450
lines changed

fern/apis/fai/openapi.json

Lines changed: 16 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,10 +3728,10 @@
37283728
"required": true,
37293729
"schema": {
37303730
"type": "string",
3731-
"description": "The GitHub repository to install the Fern Writer for. Must have the `fern-api` bot installed. Must be in the format `owner/repo`.Example: `fern-api/docs`",
3731+
"description": "The GitHub repository to install the Fern Writer for. Must have the `fern-api` bot installed. Must be in the format `owner/repo`. Example: `fern-api/docs`",
37323732
"title": "Github Repo"
37333733
},
3734-
"description": "The GitHub repository to install the Fern Writer for. Must have the `fern-api` bot installed. Must be in the format `owner/repo`.Example: `fern-api/docs`"
3734+
"description": "The GitHub repository to install the Fern Writer for. Must have the `fern-api` bot installed. Must be in the format `owner/repo`. Example: `fern-api/docs`"
37353735
}
37363736
],
37373737
"responses": {
@@ -4012,51 +4012,6 @@
40124012
]
40134013
}
40144014
},
4015-
"/upstash/qstash/failure-callback": {
4016-
"post": {
4017-
"tags": [
4018-
"Upstash"
4019-
],
4020-
"summary": "Qstash Failure Callback",
4021-
"description": "Callback endpoint for Upstash QStash to notify about failed requests.\nLogs the failure details and posts to Slack #search-notifs channel.",
4022-
"operationId": "qstash_failure_callback",
4023-
"requestBody": {
4024-
"content": {
4025-
"application/json": {
4026-
"schema": {
4027-
"$ref": "#/components/schemas/QStashFailureCallback"
4028-
}
4029-
}
4030-
},
4031-
"required": true
4032-
},
4033-
"responses": {
4034-
"200": {
4035-
"description": "Successful Response",
4036-
"content": {
4037-
"application/json": {
4038-
"schema": {
4039-
"$ref": "#/components/schemas/QStashFailureCallbackResponse"
4040-
}
4041-
}
4042-
}
4043-
},
4044-
"422": {
4045-
"description": "Validation Error",
4046-
"content": {
4047-
"application/json": {
4048-
"schema": {
4049-
"$ref": "#/components/schemas/HTTPValidationError"
4050-
}
4051-
}
4052-
}
4053-
}
4054-
},
4055-
"x-fern-audiences": [
4056-
"internal"
4057-
]
4058-
}
4059-
},
40604015
"/sources/website/{domain}/index": {
40614016
"post": {
40624017
"tags": [
@@ -6665,59 +6620,6 @@
66656620
],
66666621
"title": "PostChatCompletionResponse"
66676622
},
6668-
"QStashFailureCallback": {
6669-
"properties": {
6670-
"dlqId": {
6671-
"type": "string",
6672-
"title": "Dlqid"
6673-
},
6674-
"url": {
6675-
"type": "string",
6676-
"title": "Url"
6677-
},
6678-
"status": {
6679-
"type": "integer",
6680-
"title": "Status"
6681-
},
6682-
"sourceHeader": {
6683-
"additionalProperties": {
6684-
"anyOf": [
6685-
{
6686-
"type": "string"
6687-
},
6688-
{
6689-
"items": {
6690-
"type": "string"
6691-
},
6692-
"type": "array"
6693-
}
6694-
]
6695-
},
6696-
"type": "object",
6697-
"title": "Sourceheader"
6698-
}
6699-
},
6700-
"type": "object",
6701-
"required": [
6702-
"dlqId",
6703-
"url",
6704-
"status"
6705-
],
6706-
"title": "QStashFailureCallback"
6707-
},
6708-
"QStashFailureCallbackResponse": {
6709-
"properties": {
6710-
"success": {
6711-
"type": "boolean",
6712-
"title": "Success"
6713-
}
6714-
},
6715-
"type": "object",
6716-
"required": [
6717-
"success"
6718-
],
6719-
"title": "QStashFailureCallbackResponse"
6720-
},
67216623
"Query": {
67226624
"properties": {
67236625
"query_id": {
@@ -6759,6 +6661,20 @@
67596661
}
67606662
],
67616663
"title": "Time To First Token"
6664+
},
6665+
"subqueries": {
6666+
"anyOf": [
6667+
{
6668+
"items": {
6669+
"type": "string"
6670+
},
6671+
"type": "array"
6672+
},
6673+
{
6674+
"type": "null"
6675+
}
6676+
],
6677+
"title": "Subqueries"
67626678
}
67636679
},
67646680
"type": "object",

packages/fai-sdk/src/Client.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { Settings } from "./api/resources/settings/client/Client.js";
2424
import { SlackAskFern } from "./api/resources/slackAskFern/client/Client.js";
2525
import { SlackScribe } from "./api/resources/slackScribe/client/Client.js";
2626
import { Sources } from "./api/resources/sources/client/Client.js";
27-
import { Upstash } from "./api/resources/upstash/client/Client.js";
2827
import { Website } from "./api/resources/website/client/Client.js";
2928

3029
export declare namespace FernAIClient {
@@ -72,7 +71,6 @@ export class FernAIClient {
7271
protected _slackAskFern: SlackAskFern | undefined;
7372
protected _slackScribe: SlackScribe | undefined;
7473
protected _sources: Sources | undefined;
75-
protected _upstash: Upstash | undefined;
7674
protected _website: Website | undefined;
7775

7876
constructor(_options: FernAIClient.Options = {}) {
@@ -165,10 +163,6 @@ export class FernAIClient {
165163
return (this._sources ??= new Sources(this._options));
166164
}
167165

168-
public get upstash(): Upstash {
169-
return (this._upstash ??= new Upstash(this._options));
170-
}
171-
172166
public get website(): Website {
173167
return (this._website ??= new Website(this._options));
174168
}

packages/fai-sdk/src/api/resources/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export * as sdks from "./sdks/index.js";
1818
export * as slackAskFern from "./slackAskFern/index.js";
1919
export * as slackScribe from "./slackScribe/index.js";
2020
export * as sources from "./sources/index.js";
21-
export * as upstash from "./upstash/index.js";
2221
export * as website from "./website/index.js";
2322
export * from "./analytics/client/requests/index.js";
2423
export * from "./chat/client/requests/index.js";
@@ -37,5 +36,4 @@ export * from "./settings/client/requests/index.js";
3736
export * from "./slackAskFern/client/requests/index.js";
3837
export * from "./slackScribe/client/requests/index.js";
3938
export * from "./sources/client/requests/index.js";
40-
export * from "./upstash/client/requests/index.js";
4139
export * from "./website/client/requests/index.js";

packages/fai-sdk/src/api/resources/settings/client/Client.ts

Lines changed: 2 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,6 @@ export class Settings {
483483
/**
484484
* Manually trigger reindex for an already enabled Ask AI setup.
485485
*
486-
* Args:
487-
* domain: The domain to reindex
488-
* org_name: Organization name (unused, kept for backwards compatibility)
489-
* incremental: If True, only reindex changed content based on content hashes
490-
* db: Database session
491-
* _: Token verification
492-
*
493486
* @param {FernAI.ReindexAskAiRequest} request
494487
* @param {Settings.RequestOptions} requestOptions - Request-specific configuration.
495488
*
@@ -498,8 +491,7 @@ export class Settings {
498491
* @example
499492
* await client.settings.reindexAskAi({
500493
* domain: "domain",
501-
* org_name: "org_name",
502-
* incremental: true
494+
* org_name: "org_name"
503495
* })
504496
*/
505497
public reindexAskAi(
@@ -513,17 +505,13 @@ export class Settings {
513505
request: FernAI.ReindexAskAiRequest,
514506
requestOptions?: Settings.RequestOptions,
515507
): Promise<core.WithRawResponse<FernAI.ToggleAskAiResponse>> {
516-
const { domain, org_name: orgName, incremental } = request;
508+
const { domain, org_name: orgName } = request;
517509
const _queryParams: Record<string, string | string[] | object | object[] | null> = {};
518510
_queryParams["domain"] = domain;
519511
if (orgName != null) {
520512
_queryParams["org_name"] = orgName;
521513
}
522514

523-
if (incremental != null) {
524-
_queryParams["incremental"] = incremental.toString();
525-
}
526-
527515
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
528516
this._options?.headers,
529517
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
@@ -665,92 +653,6 @@ export class Settings {
665653
}
666654
}
667655

668-
/**
669-
* Handle callback from Upstash QStash when preview reindex completes.
670-
*
671-
* @param {FernAI.UpstashCallbackRequest} request
672-
* @param {Settings.RequestOptions} requestOptions - Request-specific configuration.
673-
*
674-
* @throws {@link FernAI.UnprocessableEntityError}
675-
*
676-
* @example
677-
* await client.settings.reindexPreviewCallback({
678-
* status: 1,
679-
* sourceMessageId: "sourceMessageId"
680-
* })
681-
*/
682-
public reindexPreviewCallback(
683-
request: FernAI.UpstashCallbackRequest,
684-
requestOptions?: Settings.RequestOptions,
685-
): core.HttpResponsePromise<unknown> {
686-
return core.HttpResponsePromise.fromPromise(this.__reindexPreviewCallback(request, requestOptions));
687-
}
688-
689-
private async __reindexPreviewCallback(
690-
request: FernAI.UpstashCallbackRequest,
691-
requestOptions?: Settings.RequestOptions,
692-
): Promise<core.WithRawResponse<unknown>> {
693-
let _headers: core.Fetcher.Args["headers"] = mergeHeaders(
694-
this._options?.headers,
695-
mergeOnlyDefinedHeaders({ Authorization: await this._getAuthorizationHeader() }),
696-
requestOptions?.headers,
697-
);
698-
const _response = await core.fetcher({
699-
url: core.url.join(
700-
(await core.Supplier.get(this._options.baseUrl)) ??
701-
(await core.Supplier.get(this._options.environment)) ??
702-
environments.FernAIEnvironment.Production,
703-
"settings/reindex-preview-callback",
704-
),
705-
method: "POST",
706-
headers: _headers,
707-
contentType: "application/json",
708-
queryParameters: requestOptions?.queryParams,
709-
requestType: "json",
710-
body: request,
711-
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
712-
maxRetries: requestOptions?.maxRetries,
713-
abortSignal: requestOptions?.abortSignal,
714-
});
715-
if (_response.ok) {
716-
return { data: _response.body, rawResponse: _response.rawResponse };
717-
}
718-
719-
if (_response.error.reason === "status-code") {
720-
switch (_response.error.statusCode) {
721-
case 422:
722-
throw new FernAI.UnprocessableEntityError(
723-
_response.error.body as FernAI.HttpValidationError,
724-
_response.rawResponse,
725-
);
726-
default:
727-
throw new errors.FernAIError({
728-
statusCode: _response.error.statusCode,
729-
body: _response.error.body,
730-
rawResponse: _response.rawResponse,
731-
});
732-
}
733-
}
734-
735-
switch (_response.error.reason) {
736-
case "non-json":
737-
throw new errors.FernAIError({
738-
statusCode: _response.error.statusCode,
739-
body: _response.error.rawBody,
740-
rawResponse: _response.rawResponse,
741-
});
742-
case "timeout":
743-
throw new errors.FernAITimeoutError(
744-
"Timeout exceeded when calling POST /settings/reindex-preview-callback.",
745-
);
746-
case "unknown":
747-
throw new errors.FernAIError({
748-
message: _response.error.errorMessage,
749-
rawResponse: _response.rawResponse,
750-
});
751-
}
752-
}
753-
754656
/**
755657
* Set the job_id for a domain when reindex starts processing.
756658
*

packages/fai-sdk/src/api/resources/settings/client/requests/ReindexAskAiRequest.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
* @example
77
* {
88
* domain: "domain",
9-
* org_name: "org_name",
10-
* incremental: true
9+
* org_name: "org_name"
1110
* }
1211
*/
1312
export interface ReindexAskAiRequest {
1413
domain: string;
1514
org_name?: string;
16-
incremental?: boolean;
1715
}

packages/fai-sdk/src/api/resources/settings/client/requests/UpstashCallbackRequest.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

packages/fai-sdk/src/api/resources/settings/client/requests/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ export { type EnableAskAiRequest } from "./EnableAskAiRequest.js";
55
export { type ToggleAskAiRequest } from "./ToggleAskAiRequest.js";
66
export { type ReindexAskAiRequest } from "./ReindexAskAiRequest.js";
77
export { type GetToggleStatusRequest } from "./GetToggleStatusRequest.js";
8-
export { type UpstashCallbackRequest } from "./UpstashCallbackRequest.js";
98
export { type SetJobIdRequest } from "./SetJobIdRequest.js";
109
export { type ReindexCallbackRequest } from "./ReindexCallbackRequest.js";

0 commit comments

Comments
 (0)