Skip to content

Feedback

(llm.feedback)

Overview

Available Operations

createFeedback

Submit user feedback for a specific chat completion response to track satisfaction and gather insights. Provide the chat completion request ID (chatcmpl-xxx) returned from the original completion, along with an optional rating ('thumbs_up' or 'thumbs_down') and optional detailed feedback text. Feedback is permanently associated with the completion record for analytics, quality monitoring, and model performance tracking. Each completion can only receive feedback once; attempting to create duplicate feedback returns a 409 conflict error.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.feedback.createFeedback({
    id: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFeedbackCreateFeedback } from "@meetkai/mka1/funcs/llmFeedbackCreateFeedback.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmFeedbackCreateFeedback(sdk, {
    id: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmFeedbackCreateFeedback failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useLlmFeedbackCreateFeedbackMutation
} from "@meetkai/mka1/react-query/llmFeedbackCreateFeedback.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateFeedbackRequestBody✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CreateFeedbackResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

getFeedbackById

Retrieve feedback for a specific chat completion by its request ID. Returns the thumbs up/down rating and detailed feedback description if they were provided. Returns 404 if the completion doesn't exist or if no feedback has been submitted yet. Use this to display user feedback, analyze satisfaction patterns, or integrate feedback into your application's UI.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.feedback.getFeedbackById({
    id: "<id>",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFeedbackGetFeedbackById } from "@meetkai/mka1/funcs/llmFeedbackGetFeedbackById.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmFeedbackGetFeedbackById(sdk, {
    id: "<id>",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmFeedbackGetFeedbackById failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Query hooks for fetching data.
  useLlmFeedbackGetFeedbackById,
  useLlmFeedbackGetFeedbackByIdSuspense,

  // Utility for prefetching data during server-side rendering and in React
  // Server Components that will be immediately available to client components
  // using the hooks.
  prefetchLlmFeedbackGetFeedbackById,
  
  // Utilities to invalidate the query cache for this query in response to
  // mutations and other user actions.
  invalidateLlmFeedbackGetFeedbackById,
  invalidateAllLlmFeedbackGetFeedbackById,
} from "@meetkai/mka1/react-query/llmFeedbackGetFeedbackById.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.GetFeedbackByIdRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.GetFeedbackByIdResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*

updateFeedback

Update or modify existing feedback for a chat completion. Change the rating from thumbs up to thumbs down (or vice versa), update the feedback description, or clear either field by passing null. All fields are optional in the request body: omit a field to keep its current value, provide a new value to update it, or pass null to clear it. Useful for allowing users to revise their feedback or add additional comments after initial submission.

Example Usage

typescript
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.feedback.updateFeedback({
    id: "<id>",
    requestBody: {},
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

typescript
import { SDKCore } from "@meetkai/mka1/core.js";
import { llmFeedbackUpdateFeedback } from "@meetkai/mka1/funcs/llmFeedbackUpdateFeedback.js";

// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const res = await llmFeedbackUpdateFeedback(sdk, {
    id: "<id>",
    requestBody: {},
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("llmFeedbackUpdateFeedback failed:", res.error);
  }
}

run();

React hooks and utilities

This method can be used in React components through the following hooks and associated utilities.

Check out this guide for information about each of the utilities below and how to get started using React hooks.

tsx
import {
  // Mutation hook for triggering the API call.
  useLlmFeedbackUpdateFeedbackMutation
} from "@meetkai/mka1/react-query/llmFeedbackUpdateFeedback.js";

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateFeedbackRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateFeedbackResponseBody>

Errors

Error TypeStatus CodeContent Type
errors.APIError4XX, 5XX*/*