Added Feedback in SDK (#2393)

This commit is contained in:
Saket Aryan
2025-03-19 21:41:45 +05:30
committed by GitHub
parent 2ffe9922f3
commit 6c2b131d6e
7 changed files with 112 additions and 2 deletions

View File

@@ -23,6 +23,8 @@ export type {
Message,
AllUsers,
User,
FeedbackPayload,
Feedback,
} from "./mem0.types";
// Export telemetry types

View File

@@ -12,6 +12,7 @@ import {
Webhook,
WebhookPayload,
Message,
FeedbackPayload,
} from "./mem0.types";
import { captureClientEvent, generateHash } from "./telemetry";
@@ -560,6 +561,18 @@ export default class MemoryClient {
);
return response;
}
async feedback(data: FeedbackPayload): Promise<{ message: string }> {
const response = await this._fetchWithErrorHandling(
`${this.host}/v1/feedback/`,
{
method: "POST",
headers: this.headers,
body: JSON.stringify(data),
},
);
return response;
}
}
export { MemoryClient };

View File

@@ -31,6 +31,12 @@ export enum API_VERSION {
V2 = "v2",
}
export enum Feedback {
POSITIVE = "POSITIVE",
NEGATIVE = "NEGATIVE",
VERY_NEGATIVE = "VERY_NEGATIVE",
}
export interface MultiModalMessages {
type: "image_url";
image_url: {
@@ -164,3 +170,9 @@ export interface WebhookPayload {
name: string;
url: string;
}
export interface FeedbackPayload {
memory_id: string;
feedback?: Feedback | null;
feedback_reason?: string | null;
}