Files
log10ts/docs/sdks/completions/README.md
2024-05-24 17:16:47 -07:00

16 KiB
Raw Permalink Blame History

Completions

(completions)

Overview

Completions

Available Operations

  • create - Create a completion
  • update - Update completion by id.
  • listUngraded - List ungraded completions i.e. completions that have not been associated with feedback but matches task selector.

create

Create a completion

Example Usage

import { Log10 } from "log10ts";
import { ChatCompletionRequestAssistantMessageRole, CreateChatCompletionRequestType, Two } from "log10ts/models/components";

const log10 = new Log10({
  log10Token: "<YOUR_API_KEY_HERE>",
  xLog10Organization: "<value>",
});

async function run() {
  const result = await log10.completions.create({
    organizationId: "<value>",
    request: {
      messages: [
          {
            role: ChatCompletionRequestAssistantMessageRole.Assistant,
          },
      ],
    model: Two.Gpt4Turbo,
      n: 1,
      responseFormat: {
        type: CreateChatCompletionRequestType.JsonObject,
      },
      temperature: 1,
      topP: 1,
      user: "user-1234",
    },
  }, "<value>");

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
completion components.Completion ✔️ N/A
xLog10Organization string N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options 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.

Response

Promise<operations.CreateResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

update

Update completion by id.

Example Usage

import { Log10 } from "log10ts";
import { ChatCompletionRequestFunctionMessageRole, CreateChatCompletionRequestType, Two } from "log10ts/models/components";

const log10 = new Log10({
  log10Token: "<YOUR_API_KEY_HERE>",
  xLog10Organization: "<value>",
});

async function run() {
  const result = await log10.completions.update("<value>", {
    organizationId: "<value>",
    request: {
      messages: [
          {
            role: ChatCompletionRequestFunctionMessageRole.Function,
            content: "<value>",
            name: "<value>",
          },
      ],
    model: Two.Gpt4Turbo,
      n: 1,
      responseFormat: {
        type: CreateChatCompletionRequestType.JsonObject,
      },
      temperature: 1,
      topP: 1,
      user: "user-1234",
    },
  }, "<value>");

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
completionId string ✔️ The completion id to update.
completion components.Completion ✔️ N/A
xLog10Organization string N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options 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.

Response

Promise<operations.UpdateResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /

listUngraded

List ungraded completions i.e. completions that have not been associated with feedback but matches task selector.

Example Usage

import { Log10 } from "log10ts";

const log10 = new Log10({
  log10Token: "<YOUR_API_KEY_HERE>",
  xLog10Organization: "<value>",
});

async function run() {
  const result = await log10.completions.listUngraded("<value>");

  // Handle the result
  console.log(result)
}

run();

Parameters

Parameter Type Required Description
xLog10Organization string N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options 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.

Response

Promise<operations.ListUngradedResponse>

Errors

Error Object Status Code Content Type
errors.SDKError 4xx-5xx /