Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompt Render Response #53

Merged
merged 6 commits into from
May 3, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 49 additions & 2 deletions src/apis/generations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,72 @@ 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 = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream seems to be missing from this type

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response_format is also missing

success: boolean;
data: {
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;

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
Loading