Skip to content

Commit

Permalink
Merge pull request #53 from Portkey-AI/fix/promptResponse
Browse files Browse the repository at this point in the history
Prompt Render Response
  • Loading branch information
VisargD authored May 3, 2024
2 parents 17cbdd3 + 2750f5d commit 38ab035
Showing 1 changed file with 51 additions and 2 deletions.
53 changes: 51 additions & 2 deletions src/apis/generations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,74 @@ export interface PromptsCreateNonStreaming extends PromptBodyBase {
stream?: false;
}

export interface Functions {
name?: string;
description?: string;
parameters?: object;
}

export interface Tool{
function?: Functions;
type?: string;
}

export interface Messages {
content?: string;
role?: string;
}

export type PromptsCreateParams = PromptsCreateNonStreaming | PromptsCreateStreaming

type PromptsResponse = Record<string, any> & APIResponseType;

type PromptRenderResponse = {
success: boolean;
data: {
messages?: Messages[];
prompt?: string;
model?: string;
stream?: boolean;
suffix?: string;
max_tokens?: number;
temperature?: number;
top_k?: number;
top_p?: number;
n?: number;
stop_sequences?: string[];
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[];
response_format?: object;
seed?: number;
};
} & APIResponseType;

export class Prompt extends ApiResource {
completions: PromptCompletions = new PromptCompletions(this.client);

render(
_body: PromptsCreateParams,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<PromptsResponse> {
): APIPromise<PromptRenderResponse> {
const body = _body
const promptId = _body.promptID

if (params) {
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params }) }
}
const response = this.post<PromptsResponse>(`/prompts/${promptId}/render`, { body, ...opts })
const response = this.post<PromptRenderResponse>(`/prompts/${promptId}/render`, { body, ...opts })
return response
}
}
Expand Down

0 comments on commit 38ab035

Please sign in to comment.