phonic 0.32.20 → 0.32.21
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/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +3 -0
- package/dist/cjs/Client.js +13 -8
- package/dist/cjs/api/errors/BadGatewayError.d.ts +6 -0
- package/dist/cjs/api/errors/BadGatewayError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/resources/conversations/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/conversations/client/Client.js +9 -0
- package/dist/cjs/api/resources/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.js +3 -1
- package/dist/cjs/api/resources/responses/client/Client.d.ts +72 -0
- package/dist/cjs/api/resources/responses/client/Client.js +169 -0
- package/dist/cjs/api/resources/responses/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/responses/client/index.js +17 -0
- package/dist/cjs/api/resources/responses/client/requests/GenerateResponsesRequest.d.ts +46 -0
- package/dist/cjs/api/resources/responses/client/requests/GenerateResponsesRequest.js +3 -0
- package/dist/cjs/api/resources/responses/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/responses/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/responses/exports.d.ts +2 -0
- package/dist/cjs/api/resources/responses/exports.js +21 -0
- package/dist/cjs/api/resources/responses/index.d.ts +1 -0
- package/dist/cjs/api/resources/responses/index.js +17 -0
- package/dist/cjs/api/types/ConflictErrorBody.d.ts +2 -0
- package/dist/cjs/api/types/ConflictErrorBody.js +3 -0
- package/dist/cjs/api/types/GenerateResponsesResponse.d.ts +5 -0
- package/dist/cjs/api/types/GenerateResponsesResponse.js +3 -0
- package/dist/cjs/api/types/GeneratedResponse.d.ts +7 -0
- package/dist/cjs/api/types/GeneratedResponse.js +3 -0
- package/dist/cjs/api/types/GeneratedToolCall.d.ts +10 -0
- package/dist/cjs/api/types/GeneratedToolCall.js +3 -0
- package/dist/cjs/api/types/ResponsesAssistantMessage.d.ts +11 -0
- package/dist/cjs/api/types/ResponsesAssistantMessage.js +3 -0
- package/dist/cjs/api/types/ResponsesInputItem.d.ts +5 -0
- package/dist/cjs/api/types/ResponsesInputItem.js +3 -0
- package/dist/cjs/api/types/ResponsesToolCall.d.ts +13 -0
- package/dist/cjs/api/types/ResponsesToolCall.js +3 -0
- package/dist/cjs/api/types/ResponsesToolCallOutput.d.ts +24 -0
- package/dist/cjs/api/types/ResponsesToolCallOutput.js +3 -0
- package/dist/cjs/api/types/ResponsesToolDefinition.d.ts +11 -0
- package/dist/cjs/api/types/ResponsesToolDefinition.js +3 -0
- package/dist/cjs/api/types/ResponsesUserMessage.d.ts +8 -0
- package/dist/cjs/api/types/ResponsesUserMessage.js +3 -0
- package/dist/cjs/api/types/index.d.ts +10 -0
- package/dist/cjs/api/types/index.js +10 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +3 -0
- package/dist/esm/Client.mjs +5 -0
- package/dist/esm/api/errors/BadGatewayError.d.mts +6 -0
- package/dist/esm/api/errors/BadGatewayError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/resources/conversations/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/conversations/client/Client.mjs +9 -0
- package/dist/esm/api/resources/index.d.mts +2 -0
- package/dist/esm/api/resources/index.mjs +2 -0
- package/dist/esm/api/resources/responses/client/Client.d.mts +72 -0
- package/dist/esm/api/resources/responses/client/Client.mjs +132 -0
- package/dist/esm/api/resources/responses/client/index.d.mts +1 -0
- package/dist/esm/api/resources/responses/client/index.mjs +1 -0
- package/dist/esm/api/resources/responses/client/requests/GenerateResponsesRequest.d.mts +46 -0
- package/dist/esm/api/resources/responses/client/requests/GenerateResponsesRequest.mjs +2 -0
- package/dist/esm/api/resources/responses/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/responses/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/responses/exports.d.mts +2 -0
- package/dist/esm/api/resources/responses/exports.mjs +3 -0
- package/dist/esm/api/resources/responses/index.d.mts +1 -0
- package/dist/esm/api/resources/responses/index.mjs +1 -0
- package/dist/esm/api/types/ConflictErrorBody.d.mts +2 -0
- package/dist/esm/api/types/ConflictErrorBody.mjs +2 -0
- package/dist/esm/api/types/GenerateResponsesResponse.d.mts +5 -0
- package/dist/esm/api/types/GenerateResponsesResponse.mjs +2 -0
- package/dist/esm/api/types/GeneratedResponse.d.mts +7 -0
- package/dist/esm/api/types/GeneratedResponse.mjs +2 -0
- package/dist/esm/api/types/GeneratedToolCall.d.mts +10 -0
- package/dist/esm/api/types/GeneratedToolCall.mjs +2 -0
- package/dist/esm/api/types/ResponsesAssistantMessage.d.mts +11 -0
- package/dist/esm/api/types/ResponsesAssistantMessage.mjs +2 -0
- package/dist/esm/api/types/ResponsesInputItem.d.mts +5 -0
- package/dist/esm/api/types/ResponsesInputItem.mjs +2 -0
- package/dist/esm/api/types/ResponsesToolCall.d.mts +13 -0
- package/dist/esm/api/types/ResponsesToolCall.mjs +2 -0
- package/dist/esm/api/types/ResponsesToolCallOutput.d.mts +24 -0
- package/dist/esm/api/types/ResponsesToolCallOutput.mjs +2 -0
- package/dist/esm/api/types/ResponsesToolDefinition.d.mts +11 -0
- package/dist/esm/api/types/ResponsesToolDefinition.mjs +2 -0
- package/dist/esm/api/types/ResponsesUserMessage.d.mts +8 -0
- package/dist/esm/api/types/ResponsesUserMessage.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +10 -0
- package/dist/esm/api/types/index.mjs +10 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +12 -1
- package/reference.md +104 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as Phonic from "../index.js";
|
|
2
|
+
export interface GeneratedResponse {
|
|
3
|
+
/** The text the assistant would say. Empty when the response only makes tool calls. */
|
|
4
|
+
text: string;
|
|
5
|
+
/** Tool calls the assistant would make - note that the tools are not actually called. */
|
|
6
|
+
tool_calls: Phonic.GeneratedToolCall[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface GeneratedToolCall {
|
|
2
|
+
/** Identifier for this tool call. Send it back as the `tool_call_id` of the matching `tool_call_output` input item. */
|
|
3
|
+
tool_call_id: string;
|
|
4
|
+
/** Name of the tool to call. Always one of the `tool_definitions` from the request. */
|
|
5
|
+
tool_name: string;
|
|
6
|
+
/** Arguments the assistant produced for the request body. */
|
|
7
|
+
request_body?: Record<string, unknown> | undefined;
|
|
8
|
+
/** Arguments the assistant produced as query parameters. */
|
|
9
|
+
query_params?: Record<string, string> | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as Phonic from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* An assistant turn. Must carry `text`, `tool_calls`, or both.
|
|
4
|
+
*/
|
|
5
|
+
export interface ResponsesAssistantMessage {
|
|
6
|
+
role: "assistant";
|
|
7
|
+
/** What the assistant said. Empty when the turn only made tool calls. */
|
|
8
|
+
text: string;
|
|
9
|
+
/** Tool calls the assistant made on this turn. Each one must be followed immediately by its matching `tool_call_output` item. */
|
|
10
|
+
tool_calls?: Phonic.ResponsesToolCall[] | undefined;
|
|
11
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as Phonic from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* One item of conversation history - a user message, an assistant message, or the output of an assistant tool call.
|
|
4
|
+
*/
|
|
5
|
+
export type ResponsesInputItem = Phonic.ResponsesUserMessage | Phonic.ResponsesAssistantMessage | Phonic.ResponsesToolCallOutput;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool call the assistant made earlier in the conversation.
|
|
3
|
+
*/
|
|
4
|
+
export interface ResponsesToolCall {
|
|
5
|
+
/** Identifier for this tool call, unique within `input`. */
|
|
6
|
+
tool_call_id: string;
|
|
7
|
+
/** Name of the called tool. */
|
|
8
|
+
tool_name: string;
|
|
9
|
+
/** Arguments the assistant passed in the request body. */
|
|
10
|
+
request_body?: (Record<string, unknown> | null) | undefined;
|
|
11
|
+
/** Arguments the assistant passed as query parameters. An argument cannot appear in both `request_body` and `query_params`. */
|
|
12
|
+
query_params?: (Record<string, string | null> | null) | undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The result of an assistant tool call. Must record an outcome through `response_body`, `response_status_code`, `error_message`, `timed_out`, or `interrupted`.
|
|
3
|
+
*/
|
|
4
|
+
export interface ResponsesToolCallOutput {
|
|
5
|
+
type: "tool_call_output";
|
|
6
|
+
/** The `tool_call_id` of the assistant tool call this output belongs to. */
|
|
7
|
+
tool_call_id: string;
|
|
8
|
+
/** The value the tool returned. Can be any JSON-serializable value. */
|
|
9
|
+
response_body?: (ResponsesToolCallOutput.ResponseBody | null) | undefined;
|
|
10
|
+
/** HTTP status code the tool returned, for tools called over HTTP. */
|
|
11
|
+
response_status_code?: (number | null) | undefined;
|
|
12
|
+
/** Whether the tool call timed out. */
|
|
13
|
+
timed_out?: boolean | undefined;
|
|
14
|
+
/** The error the tool call failed with. */
|
|
15
|
+
error_message?: (string | null) | undefined;
|
|
16
|
+
/** Whether the tool call was interrupted before it finished. */
|
|
17
|
+
interrupted?: boolean | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare namespace ResponsesToolCallOutput {
|
|
20
|
+
/**
|
|
21
|
+
* The value the tool returned. Can be any JSON-serializable value.
|
|
22
|
+
*/
|
|
23
|
+
type ResponseBody = Record<string, unknown> | unknown[] | string | number | boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as Phonic from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A tool the assistant may call, defined inline for this request only.
|
|
4
|
+
*/
|
|
5
|
+
export interface ResponsesToolDefinition {
|
|
6
|
+
/** The tool name. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** What the tool does. The model uses this to decide when to call it. */
|
|
9
|
+
description: string;
|
|
10
|
+
parameters: Phonic.ToolParametersJsonSchema;
|
|
11
|
+
}
|
|
@@ -16,6 +16,7 @@ export * from "./BuiltInToolDefinition.js";
|
|
|
16
16
|
export * from "./ChooseNotToRespondToolConfig.js";
|
|
17
17
|
export * from "./ConfigOptions.js";
|
|
18
18
|
export * from "./ConfigPayload.js";
|
|
19
|
+
export * from "./ConflictErrorBody.js";
|
|
19
20
|
export * from "./Conversation.js";
|
|
20
21
|
export * from "./ConversationAnalysis.js";
|
|
21
22
|
export * from "./ConversationCreatedPayload.js";
|
|
@@ -37,7 +38,10 @@ export * from "./ErrorPayload.js";
|
|
|
37
38
|
export * from "./ExternalStoragePolicy.js";
|
|
38
39
|
export * from "./ExtractionField.js";
|
|
39
40
|
export * from "./ExtractionSchema.js";
|
|
41
|
+
export * from "./GeneratedResponse.js";
|
|
42
|
+
export * from "./GeneratedToolCall.js";
|
|
40
43
|
export * from "./GenerateReplyPayload.js";
|
|
44
|
+
export * from "./GenerateResponsesResponse.js";
|
|
41
45
|
export * from "./InlineWebSocketTool.js";
|
|
42
46
|
export * from "./InputCancelledPayload.js";
|
|
43
47
|
export * from "./InputTextPayload.js";
|
|
@@ -55,6 +59,12 @@ export * from "./ReadyToStartConversationPayload.js";
|
|
|
55
59
|
export * from "./ReplayConversationItemResponse.js";
|
|
56
60
|
export * from "./ReplayToolCall.js";
|
|
57
61
|
export * from "./ResetPayload.js";
|
|
62
|
+
export * from "./ResponsesAssistantMessage.js";
|
|
63
|
+
export * from "./ResponsesInputItem.js";
|
|
64
|
+
export * from "./ResponsesToolCall.js";
|
|
65
|
+
export * from "./ResponsesToolCallOutput.js";
|
|
66
|
+
export * from "./ResponsesToolDefinition.js";
|
|
67
|
+
export * from "./ResponsesUserMessage.js";
|
|
58
68
|
export * from "./SayPayload.js";
|
|
59
69
|
export * from "./SetExternalIdPayload.js";
|
|
60
70
|
export * from "./SipCallError.js";
|
|
@@ -32,6 +32,7 @@ __exportStar(require("./BuiltInToolDefinition.js"), exports);
|
|
|
32
32
|
__exportStar(require("./ChooseNotToRespondToolConfig.js"), exports);
|
|
33
33
|
__exportStar(require("./ConfigOptions.js"), exports);
|
|
34
34
|
__exportStar(require("./ConfigPayload.js"), exports);
|
|
35
|
+
__exportStar(require("./ConflictErrorBody.js"), exports);
|
|
35
36
|
__exportStar(require("./Conversation.js"), exports);
|
|
36
37
|
__exportStar(require("./ConversationAnalysis.js"), exports);
|
|
37
38
|
__exportStar(require("./ConversationCreatedPayload.js"), exports);
|
|
@@ -53,7 +54,10 @@ __exportStar(require("./ErrorPayload.js"), exports);
|
|
|
53
54
|
__exportStar(require("./ExternalStoragePolicy.js"), exports);
|
|
54
55
|
__exportStar(require("./ExtractionField.js"), exports);
|
|
55
56
|
__exportStar(require("./ExtractionSchema.js"), exports);
|
|
57
|
+
__exportStar(require("./GeneratedResponse.js"), exports);
|
|
58
|
+
__exportStar(require("./GeneratedToolCall.js"), exports);
|
|
56
59
|
__exportStar(require("./GenerateReplyPayload.js"), exports);
|
|
60
|
+
__exportStar(require("./GenerateResponsesResponse.js"), exports);
|
|
57
61
|
__exportStar(require("./InlineWebSocketTool.js"), exports);
|
|
58
62
|
__exportStar(require("./InputCancelledPayload.js"), exports);
|
|
59
63
|
__exportStar(require("./InputTextPayload.js"), exports);
|
|
@@ -71,6 +75,12 @@ __exportStar(require("./ReadyToStartConversationPayload.js"), exports);
|
|
|
71
75
|
__exportStar(require("./ReplayConversationItemResponse.js"), exports);
|
|
72
76
|
__exportStar(require("./ReplayToolCall.js"), exports);
|
|
73
77
|
__exportStar(require("./ResetPayload.js"), exports);
|
|
78
|
+
__exportStar(require("./ResponsesAssistantMessage.js"), exports);
|
|
79
|
+
__exportStar(require("./ResponsesInputItem.js"), exports);
|
|
80
|
+
__exportStar(require("./ResponsesToolCall.js"), exports);
|
|
81
|
+
__exportStar(require("./ResponsesToolCallOutput.js"), exports);
|
|
82
|
+
__exportStar(require("./ResponsesToolDefinition.js"), exports);
|
|
83
|
+
__exportStar(require("./ResponsesUserMessage.js"), exports);
|
|
74
84
|
__exportStar(require("./SayPayload.js"), exports);
|
|
75
85
|
__exportStar(require("./SetExternalIdPayload.js"), exports);
|
|
76
86
|
__exportStar(require("./SipCallError.js"), exports);
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.32.
|
|
1
|
+
export declare const SDK_VERSION = "0.32.21";
|
package/dist/cjs/version.js
CHANGED
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
|
|
|
6
6
|
const headers = mergeHeaders({
|
|
7
7
|
"X-Fern-Language": "JavaScript",
|
|
8
8
|
"X-Fern-SDK-Name": "phonic",
|
|
9
|
-
"X-Fern-SDK-Version": "0.32.
|
|
10
|
-
"User-Agent": "phonic/0.32.
|
|
9
|
+
"X-Fern-SDK-Version": "0.32.21",
|
|
10
|
+
"User-Agent": "phonic/0.32.21",
|
|
11
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
package/dist/esm/Client.d.mts
CHANGED
|
@@ -6,6 +6,7 @@ import { ConversationsClient } from "./api/resources/conversations/client/Client
|
|
|
6
6
|
import { ExternalStoragePoliciesClient } from "./api/resources/externalStoragePolicies/client/Client.mjs";
|
|
7
7
|
import { ExtractionSchemasClient } from "./api/resources/extractionSchemas/client/Client.mjs";
|
|
8
8
|
import { ProjectsClient } from "./api/resources/projects/client/Client.mjs";
|
|
9
|
+
import { ResponsesClient } from "./api/resources/responses/client/Client.mjs";
|
|
9
10
|
import { ToolsClient } from "./api/resources/tools/client/Client.mjs";
|
|
10
11
|
import { TtsClient } from "./api/resources/tts/client/Client.mjs";
|
|
11
12
|
import { VoicesClient } from "./api/resources/voices/client/Client.mjs";
|
|
@@ -39,6 +40,7 @@ export declare class PhonicClient {
|
|
|
39
40
|
protected _conversationItems: ConversationItemsClient | undefined;
|
|
40
41
|
protected _auth: AuthClient | undefined;
|
|
41
42
|
protected _projects: ProjectsClient | undefined;
|
|
43
|
+
protected _responses: ResponsesClient | undefined;
|
|
42
44
|
protected _workspace: WorkspaceClient | undefined;
|
|
43
45
|
protected _externalStoragePolicies: ExternalStoragePoliciesClient | undefined;
|
|
44
46
|
constructor(options?: PhonicClient.Options);
|
|
@@ -52,6 +54,7 @@ export declare class PhonicClient {
|
|
|
52
54
|
get conversationItems(): ConversationItemsClient;
|
|
53
55
|
get auth(): AuthClient;
|
|
54
56
|
get projects(): ProjectsClient;
|
|
57
|
+
get responses(): ResponsesClient;
|
|
55
58
|
get workspace(): WorkspaceClient;
|
|
56
59
|
get externalStoragePolicies(): ExternalStoragePoliciesClient;
|
|
57
60
|
/**
|
package/dist/esm/Client.mjs
CHANGED
|
@@ -16,6 +16,7 @@ import { ConversationsClient } from "./api/resources/conversations/client/Client
|
|
|
16
16
|
import { ExternalStoragePoliciesClient } from "./api/resources/externalStoragePolicies/client/Client.mjs";
|
|
17
17
|
import { ExtractionSchemasClient } from "./api/resources/extractionSchemas/client/Client.mjs";
|
|
18
18
|
import { ProjectsClient } from "./api/resources/projects/client/Client.mjs";
|
|
19
|
+
import { ResponsesClient } from "./api/resources/responses/client/Client.mjs";
|
|
19
20
|
import { ToolsClient } from "./api/resources/tools/client/Client.mjs";
|
|
20
21
|
import { TtsClient } from "./api/resources/tts/client/Client.mjs";
|
|
21
22
|
import { VoicesClient } from "./api/resources/voices/client/Client.mjs";
|
|
@@ -67,6 +68,10 @@ export class PhonicClient {
|
|
|
67
68
|
var _a;
|
|
68
69
|
return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new ProjectsClient(this._options)));
|
|
69
70
|
}
|
|
71
|
+
get responses() {
|
|
72
|
+
var _a;
|
|
73
|
+
return ((_a = this._responses) !== null && _a !== void 0 ? _a : (this._responses = new ResponsesClient(this._options)));
|
|
74
|
+
}
|
|
70
75
|
get workspace() {
|
|
71
76
|
var _a;
|
|
72
77
|
return ((_a = this._workspace) !== null && _a !== void 0 ? _a : (this._workspace = new WorkspaceClient(this._options)));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type * as core from "../../core/index.mjs";
|
|
2
|
+
import * as errors from "../../errors/index.mjs";
|
|
3
|
+
import type * as Phonic from "../index.mjs";
|
|
4
|
+
export declare class BadGatewayError extends errors.PhonicError {
|
|
5
|
+
constructor(body: Phonic.BasicError, rawResponse?: core.RawResponse);
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as errors from "../../errors/index.mjs";
|
|
3
|
+
export class BadGatewayError extends errors.PhonicError {
|
|
4
|
+
constructor(body, rawResponse) {
|
|
5
|
+
super({
|
|
6
|
+
message: "BadGatewayError",
|
|
7
|
+
statusCode: 502,
|
|
8
|
+
body: body,
|
|
9
|
+
rawResponse: rawResponse,
|
|
10
|
+
});
|
|
11
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, this.constructor);
|
|
14
|
+
}
|
|
15
|
+
this.name = this.constructor.name;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -227,6 +227,8 @@ export declare class ConversationsClient {
|
|
|
227
227
|
* @throws {@link Phonic.BadRequestError}
|
|
228
228
|
* @throws {@link Phonic.UnauthorizedError}
|
|
229
229
|
* @throws {@link Phonic.NotFoundError}
|
|
230
|
+
* @throws {@link Phonic.ConflictError}
|
|
231
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
230
232
|
* @throws {@link Phonic.InternalServerError}
|
|
231
233
|
*
|
|
232
234
|
* @example
|
|
@@ -264,6 +266,7 @@ export declare class ConversationsClient {
|
|
|
264
266
|
* @throws {@link Phonic.BadRequestError}
|
|
265
267
|
* @throws {@link Phonic.UnauthorizedError}
|
|
266
268
|
* @throws {@link Phonic.ConflictError}
|
|
269
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
267
270
|
* @throws {@link Phonic.InternalServerError}
|
|
268
271
|
*
|
|
269
272
|
* @example
|
|
@@ -704,6 +704,8 @@ export class ConversationsClient {
|
|
|
704
704
|
* @throws {@link Phonic.BadRequestError}
|
|
705
705
|
* @throws {@link Phonic.UnauthorizedError}
|
|
706
706
|
* @throws {@link Phonic.NotFoundError}
|
|
707
|
+
* @throws {@link Phonic.ConflictError}
|
|
708
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
707
709
|
* @throws {@link Phonic.InternalServerError}
|
|
708
710
|
*
|
|
709
711
|
* @example
|
|
@@ -767,6 +769,10 @@ export class ConversationsClient {
|
|
|
767
769
|
throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
768
770
|
case 404:
|
|
769
771
|
throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
|
|
772
|
+
case 409:
|
|
773
|
+
throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
|
|
774
|
+
case 429:
|
|
775
|
+
throw new Phonic.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
770
776
|
case 500:
|
|
771
777
|
throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
|
|
772
778
|
default:
|
|
@@ -789,6 +795,7 @@ export class ConversationsClient {
|
|
|
789
795
|
* @throws {@link Phonic.BadRequestError}
|
|
790
796
|
* @throws {@link Phonic.UnauthorizedError}
|
|
791
797
|
* @throws {@link Phonic.ConflictError}
|
|
798
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
792
799
|
* @throws {@link Phonic.InternalServerError}
|
|
793
800
|
*
|
|
794
801
|
* @example
|
|
@@ -840,6 +847,8 @@ export class ConversationsClient {
|
|
|
840
847
|
throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
841
848
|
case 409:
|
|
842
849
|
throw new Phonic.ConflictError(_response.error.body, _response.rawResponse);
|
|
850
|
+
case 429:
|
|
851
|
+
throw new Phonic.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
843
852
|
case 500:
|
|
844
853
|
throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
|
|
845
854
|
default:
|
|
@@ -21,6 +21,8 @@ export * from "./extractionSchemas/types/index.mjs";
|
|
|
21
21
|
export * from "./projects/client/requests/index.mjs";
|
|
22
22
|
export * as projects from "./projects/index.mjs";
|
|
23
23
|
export * from "./projects/types/index.mjs";
|
|
24
|
+
export * from "./responses/client/requests/index.mjs";
|
|
25
|
+
export * as responses from "./responses/index.mjs";
|
|
24
26
|
export * from "./tools/client/requests/index.mjs";
|
|
25
27
|
export * as tools from "./tools/index.mjs";
|
|
26
28
|
export * from "./tools/types/index.mjs";
|
|
@@ -21,6 +21,8 @@ export * from "./extractionSchemas/types/index.mjs";
|
|
|
21
21
|
export * from "./projects/client/requests/index.mjs";
|
|
22
22
|
export * as projects from "./projects/index.mjs";
|
|
23
23
|
export * from "./projects/types/index.mjs";
|
|
24
|
+
export * from "./responses/client/requests/index.mjs";
|
|
25
|
+
export * as responses from "./responses/index.mjs";
|
|
24
26
|
export * from "./tools/client/requests/index.mjs";
|
|
25
27
|
export * as tools from "./tools/index.mjs";
|
|
26
28
|
export * from "./tools/types/index.mjs";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
|
|
2
|
+
import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
3
|
+
import * as core from "../../../../core/index.mjs";
|
|
4
|
+
import * as Phonic from "../../../index.mjs";
|
|
5
|
+
export declare namespace ResponsesClient {
|
|
6
|
+
type Options = BaseClientOptions;
|
|
7
|
+
interface RequestOptions extends BaseRequestOptions {
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export declare class ResponsesClient {
|
|
11
|
+
protected readonly _options: NormalizedClientOptionsWithAuth<ResponsesClient.Options>;
|
|
12
|
+
constructor(options?: ResponsesClient.Options);
|
|
13
|
+
/**
|
|
14
|
+
* Generates one or more alternative assistant responses for a conversation
|
|
15
|
+
* you supply inline to simulate Phonic agent behavior.
|
|
16
|
+
*
|
|
17
|
+
* This endpoint is stateless, so it does not create a new conversation or
|
|
18
|
+
* store anything. The request carries the system prompt, a conversation so
|
|
19
|
+
* far as `input`, and the tools the assistant may call as
|
|
20
|
+
* `tool_definitions`.
|
|
21
|
+
*
|
|
22
|
+
* Each item in `input` is a user message, an assistant message (with
|
|
23
|
+
* optional `tool_calls`), or a `tool_call_output`. Every assistant tool
|
|
24
|
+
* call must be followed immediately by the `tool_call_output` item that
|
|
25
|
+
* carries its result.
|
|
26
|
+
*
|
|
27
|
+
* This is an experimental feature and must be enabled for your workspace;
|
|
28
|
+
* otherwise, it returns `404`. Please contact our team if you would like
|
|
29
|
+
* access.
|
|
30
|
+
*
|
|
31
|
+
* @param {Phonic.GenerateResponsesRequest} request
|
|
32
|
+
* @param {ResponsesClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
33
|
+
*
|
|
34
|
+
* @throws {@link Phonic.BadRequestError}
|
|
35
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
36
|
+
* @throws {@link Phonic.NotFoundError}
|
|
37
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
38
|
+
* @throws {@link Phonic.InternalServerError}
|
|
39
|
+
* @throws {@link Phonic.BadGatewayError}
|
|
40
|
+
* @throws {@link Phonic.ServiceUnavailableError}
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* await client.responses.create({
|
|
44
|
+
* system_prompt: "You help callers find a pizza shop. Be friendly and concise.",
|
|
45
|
+
* voice_id: "sabrina",
|
|
46
|
+
* default_language: "en",
|
|
47
|
+
* additional_languages: ["es"],
|
|
48
|
+
* input: [{
|
|
49
|
+
* role: "user",
|
|
50
|
+
* text: "Where should I get pizza near Union Square?"
|
|
51
|
+
* }],
|
|
52
|
+
* tool_definitions: [{
|
|
53
|
+
* name: "search_pizza_shop_recs",
|
|
54
|
+
* description: "Search for pizza shop recommendations.",
|
|
55
|
+
* parameters: {
|
|
56
|
+
* type: "object",
|
|
57
|
+
* properties: {
|
|
58
|
+
* "location": {
|
|
59
|
+
* "type": "string",
|
|
60
|
+
* "description": "The neighborhood to search in."
|
|
61
|
+
* }
|
|
62
|
+
* },
|
|
63
|
+
* required: ["location"],
|
|
64
|
+
* additionalProperties: false
|
|
65
|
+
* }
|
|
66
|
+
* }],
|
|
67
|
+
* num_responses: 2
|
|
68
|
+
* })
|
|
69
|
+
*/
|
|
70
|
+
create(request: Phonic.GenerateResponsesRequest, requestOptions?: ResponsesClient.RequestOptions): core.HttpResponsePromise<Phonic.GenerateResponsesResponse>;
|
|
71
|
+
private __create;
|
|
72
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.mjs";
|
|
12
|
+
import { mergeHeaders } from "../../../../core/headers.mjs";
|
|
13
|
+
import * as core from "../../../../core/index.mjs";
|
|
14
|
+
import * as environments from "../../../../environments.mjs";
|
|
15
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
|
|
16
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
17
|
+
import * as Phonic from "../../../index.mjs";
|
|
18
|
+
export class ResponsesClient {
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generates one or more alternative assistant responses for a conversation
|
|
24
|
+
* you supply inline to simulate Phonic agent behavior.
|
|
25
|
+
*
|
|
26
|
+
* This endpoint is stateless, so it does not create a new conversation or
|
|
27
|
+
* store anything. The request carries the system prompt, a conversation so
|
|
28
|
+
* far as `input`, and the tools the assistant may call as
|
|
29
|
+
* `tool_definitions`.
|
|
30
|
+
*
|
|
31
|
+
* Each item in `input` is a user message, an assistant message (with
|
|
32
|
+
* optional `tool_calls`), or a `tool_call_output`. Every assistant tool
|
|
33
|
+
* call must be followed immediately by the `tool_call_output` item that
|
|
34
|
+
* carries its result.
|
|
35
|
+
*
|
|
36
|
+
* This is an experimental feature and must be enabled for your workspace;
|
|
37
|
+
* otherwise, it returns `404`. Please contact our team if you would like
|
|
38
|
+
* access.
|
|
39
|
+
*
|
|
40
|
+
* @param {Phonic.GenerateResponsesRequest} request
|
|
41
|
+
* @param {ResponsesClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
42
|
+
*
|
|
43
|
+
* @throws {@link Phonic.BadRequestError}
|
|
44
|
+
* @throws {@link Phonic.UnauthorizedError}
|
|
45
|
+
* @throws {@link Phonic.NotFoundError}
|
|
46
|
+
* @throws {@link Phonic.TooManyRequestsError}
|
|
47
|
+
* @throws {@link Phonic.InternalServerError}
|
|
48
|
+
* @throws {@link Phonic.BadGatewayError}
|
|
49
|
+
* @throws {@link Phonic.ServiceUnavailableError}
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* await client.responses.create({
|
|
53
|
+
* system_prompt: "You help callers find a pizza shop. Be friendly and concise.",
|
|
54
|
+
* voice_id: "sabrina",
|
|
55
|
+
* default_language: "en",
|
|
56
|
+
* additional_languages: ["es"],
|
|
57
|
+
* input: [{
|
|
58
|
+
* role: "user",
|
|
59
|
+
* text: "Where should I get pizza near Union Square?"
|
|
60
|
+
* }],
|
|
61
|
+
* tool_definitions: [{
|
|
62
|
+
* name: "search_pizza_shop_recs",
|
|
63
|
+
* description: "Search for pizza shop recommendations.",
|
|
64
|
+
* parameters: {
|
|
65
|
+
* type: "object",
|
|
66
|
+
* properties: {
|
|
67
|
+
* "location": {
|
|
68
|
+
* "type": "string",
|
|
69
|
+
* "description": "The neighborhood to search in."
|
|
70
|
+
* }
|
|
71
|
+
* },
|
|
72
|
+
* required: ["location"],
|
|
73
|
+
* additionalProperties: false
|
|
74
|
+
* }
|
|
75
|
+
* }],
|
|
76
|
+
* num_responses: 2
|
|
77
|
+
* })
|
|
78
|
+
*/
|
|
79
|
+
create(request, requestOptions) {
|
|
80
|
+
return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
|
|
81
|
+
}
|
|
82
|
+
__create(request, requestOptions) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
85
|
+
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
86
|
+
const _headers = mergeHeaders(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
87
|
+
const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({
|
|
88
|
+
url: core.url.join((_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : ((_d = (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.PhonicEnvironment.Default)
|
|
89
|
+
.base, "responses"),
|
|
90
|
+
method: "POST",
|
|
91
|
+
headers: _headers,
|
|
92
|
+
contentType: "application/json",
|
|
93
|
+
queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
|
|
94
|
+
requestType: "json",
|
|
95
|
+
body: request,
|
|
96
|
+
timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000,
|
|
97
|
+
maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries,
|
|
98
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
99
|
+
fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch,
|
|
100
|
+
logging: this._options.logging,
|
|
101
|
+
});
|
|
102
|
+
if (_response.ok) {
|
|
103
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
104
|
+
}
|
|
105
|
+
if (_response.error.reason === "status-code") {
|
|
106
|
+
switch (_response.error.statusCode) {
|
|
107
|
+
case 400:
|
|
108
|
+
throw new Phonic.BadRequestError(_response.error.body, _response.rawResponse);
|
|
109
|
+
case 401:
|
|
110
|
+
throw new Phonic.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
111
|
+
case 404:
|
|
112
|
+
throw new Phonic.NotFoundError(_response.error.body, _response.rawResponse);
|
|
113
|
+
case 429:
|
|
114
|
+
throw new Phonic.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
115
|
+
case 500:
|
|
116
|
+
throw new Phonic.InternalServerError(_response.error.body, _response.rawResponse);
|
|
117
|
+
case 502:
|
|
118
|
+
throw new Phonic.BadGatewayError(_response.error.body, _response.rawResponse);
|
|
119
|
+
case 503:
|
|
120
|
+
throw new Phonic.ServiceUnavailableError(_response.error.body, _response.rawResponse);
|
|
121
|
+
default:
|
|
122
|
+
throw new errors.PhonicError({
|
|
123
|
+
statusCode: _response.error.statusCode,
|
|
124
|
+
body: _response.error.body,
|
|
125
|
+
rawResponse: _response.rawResponse,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/responses");
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|