Skip to content

Commit

Permalink
Merge pull request #55 from Portkey-AI/feat/update-feedback
Browse files Browse the repository at this point in the history
update feedback
  • Loading branch information
VisargD authored May 3, 2024
2 parents 38ab035 + c1d1417 commit 96188b6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/apiResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import type { Portkey } from "./index";
export class ApiResource {
protected client: Portkey;
protected post: Portkey["_post"]
protected put: Portkey["_put"]

constructor(client: Portkey) {
this.client = client
this.post = client._post.bind(client)
this.put = client._put.bind(client)
}
}
17 changes: 17 additions & 0 deletions src/apis/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createHeaders } from "./createHeaders";

interface FeedbackBodyBase {
traceID?: string;
feedbackID?: string;
value?: number;
weight?: number;
metadata?: Record<string, any>
Expand All @@ -17,6 +18,7 @@ type FeedbackBody = FeedbackBodyBase | Array<FeedbackBodyBase>
export interface FeedbackResponse extends APIResponseType {
status: string;
message: string;
feedback_id: Array<string>;
}

export class Feedback extends ApiResource {
Expand All @@ -33,4 +35,19 @@ export class Feedback extends ApiResource {
const response = this.post<FeedbackResponse>(FEEDBACK_API, { body, ...opts })
return response
}

update(
_body: FeedbackBodyBase,
params?: ApiClientInterface,
opts?: RequestOptions
): APIPromise<FeedbackResponse> {
const body = _body
const feedbackID = _body.feedbackID
if (params) {
const config = overrideConfig(this.client.config, params.config)
this.client.customHeaders = { ...this.client.customHeaders, ...createHeaders({ ...params, config }) }
}
const response = this.put<FeedbackResponse>(FEEDBACK_API+'/'+feedbackID , { body, ...opts })
return response
}
}
4 changes: 4 additions & 0 deletions src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ export abstract class ApiClient {
return this.methodRequest("post", path, opts);
}

_put<Rsp extends APIResponseType>(path: string, opts?: RequestOptions): APIPromise<Rsp> {
return this.methodRequest("put", path, opts);
}

protected generateError(
status: number | undefined,
errorResponse: object | undefined,
Expand Down

0 comments on commit 96188b6

Please sign in to comment.