From ec693910adf794717d26f6bb70c5e58a86595195 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Mon, 1 Apr 2024 20:29:32 +0530 Subject: [PATCH 1/5] fix: prompt render response --- src/apis/generations.ts | 53 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/src/apis/generations.ts b/src/apis/generations.ts index c43601c..92361ac 100644 --- a/src/apis/generations.ts +++ b/src/apis/generations.ts @@ -41,10 +41,59 @@ export interface PromptsCreateNonStreaming extends PromptBodyBase { stream?: false; } +export interface Functions { + name?: Optional; + description?: Optional; + parameters?: Optional; +} + +export interface Tool{ + function?: Optional; + type?: Optional; +} + +export interface Messages { + content?: Optional; + role?: Optional; +} + export type PromptsCreateParams = PromptsCreateNonStreaming | PromptsCreateStreaming type PromptsResponse = Record & APIResponseType; +type Optional = T | null | undefined; + +type PromptRenderResponse = { + success: boolean; + data: { + messages?: Optional; + prompt?: Optional; + model?: Optional; + suffix?: Optional; + max_tokens?: Optional; + temperature?: Optional; + top_k?: Optional; + top_p?: Optional; + n?: Optional; + stop_sequences?: Optional; + timeout?: Optional; + functions?: Optional; + function_call?: Optional; + logprobs?: Optional; + top_logprobs?: Optional; + echo?: Optional; + stop?: Optional; + presence_penalty?: Optional; + frequency_penalty?: Optional; + best_of?: Optional; + logit_bias?: Optional<{ [key: string]: number }>; + user?: Optional; + organization?: Optional; + tool_choice?: Optional; + tools?: Optional; + }; + } & APIResponseType; + export class Prompt extends ApiResource { completions: PromptCompletions = new PromptCompletions(this.client); @@ -52,14 +101,14 @@ export class Prompt extends ApiResource { _body: PromptsCreateParams, params?: ApiClientInterface, opts?: RequestOptions - ): APIPromise { + ): APIPromise { const body = _body const promptId = _body.promptID if (params) { this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) } } - const response = this.post(`/prompts/${promptId}/render`, { body, ...opts }) + const response = this.post(`/prompts/${promptId}/render`, { body, ...opts }) return response } } From 4d5386a4047a3ffc1cc84ee212b75f2967dcfe21 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Fri, 5 Apr 2024 16:09:15 +0530 Subject: [PATCH 2/5] fix: optional interface removed from generation --- src/apis/generations.ts | 66 ++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/apis/generations.ts b/src/apis/generations.ts index 92361ac..a0d86be 100644 --- a/src/apis/generations.ts +++ b/src/apis/generations.ts @@ -42,55 +42,53 @@ export interface PromptsCreateNonStreaming extends PromptBodyBase { } export interface Functions { - name?: Optional; - description?: Optional; - parameters?: Optional; + name?: string; + description?: string; + parameters?: object; } export interface Tool{ - function?: Optional; - type?: Optional; + function?: Functions; + type?: string; } export interface Messages { - content?: Optional; - role?: Optional; + content?: string; + role?: string; } export type PromptsCreateParams = PromptsCreateNonStreaming | PromptsCreateStreaming type PromptsResponse = Record & APIResponseType; -type Optional = T | null | undefined; - type PromptRenderResponse = { success: boolean; data: { - messages?: Optional; - prompt?: Optional; - model?: Optional; - suffix?: Optional; - max_tokens?: Optional; - temperature?: Optional; - top_k?: Optional; - top_p?: Optional; - n?: Optional; - stop_sequences?: Optional; - timeout?: Optional; - functions?: Optional; - function_call?: Optional; - logprobs?: Optional; - top_logprobs?: Optional; - echo?: Optional; - stop?: Optional; - presence_penalty?: Optional; - frequency_penalty?: Optional; - best_of?: Optional; - logit_bias?: Optional<{ [key: string]: number }>; - user?: Optional; - organization?: Optional; - tool_choice?: Optional; - tools?: Optional; + messages?: Messages[]; + prompt?: string; + model?: string; + suffix?: string; + max_tokens?: number; + temperature?: number; + top_k?: number; + top_p?: number; + n?: number; + stop_sequences?: string[]; + timeout?: number; + functions?: Functions[]; + function_call?: string | Functions; + logprobs?: boolean; + top_logprobs?: number; + echo?: boolean; + stop?: string | string[]; + presence_penalty?: number; + frequency_penalty?: number; + best_of?: number; + logit_bias?: { [key: string]: number }; + user?: string; + organization?: string; + tool_choice?: string; + tools?: Tool[]; }; } & APIResponseType; From d8c1809f4b7d30826825bb31a6b7d04a98304fae Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Sat, 20 Apr 2024 15:38:59 +0530 Subject: [PATCH 3/5] fix: added stream as type --- src/apis/generations.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apis/generations.ts b/src/apis/generations.ts index a0d86be..bd2a462 100644 --- a/src/apis/generations.ts +++ b/src/apis/generations.ts @@ -67,6 +67,7 @@ type PromptRenderResponse = { messages?: Messages[]; prompt?: string; model?: string; + stream?: boolean; suffix?: string; max_tokens?: number; temperature?: number; From 19a2cb2b2630fd8a35364c86de2b758e1c465955 Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Sat, 20 Apr 2024 15:45:59 +0530 Subject: [PATCH 4/5] fix: added missing fields in promptrender response type --- src/apis/generations.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/apis/generations.ts b/src/apis/generations.ts index bd2a462..3dad288 100644 --- a/src/apis/generations.ts +++ b/src/apis/generations.ts @@ -90,6 +90,8 @@ type PromptRenderResponse = { organization?: string; tool_choice?: string; tools?: Tool[]; + response_format?: object; + seed?: number; }; } & APIResponseType; From 2750f5d7d5325537c9cec80ab55f0c77457a9ebb Mon Sep 17 00:00:00 2001 From: csgulati09 Date: Sat, 20 Apr 2024 16:07:20 +0530 Subject: [PATCH 5/5] fix: removed timout from promptrender response type --- src/apis/generations.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/apis/generations.ts b/src/apis/generations.ts index 3dad288..f089a9d 100644 --- a/src/apis/generations.ts +++ b/src/apis/generations.ts @@ -75,7 +75,6 @@ type PromptRenderResponse = { top_p?: number; n?: number; stop_sequences?: string[]; - timeout?: number; functions?: Functions[]; function_call?: string | Functions; logprobs?: boolean;