@singlestore/ai
Advanced tools
Comparing version 0.0.4 to 0.0.5
import { OpenAI } from 'openai'; | ||
import { EmbeddingCreateParams } from 'openai/resources/embeddings'; | ||
import { ChatCompletionMessageParam, ChatCompletionCreateParams } from 'openai/resources/chat/completions'; | ||
import { ChatModel } from 'openai/resources/index.mjs'; | ||
@@ -16,3 +17,4 @@ type Embedder<T = any> = (input: string | string[], options?: T) => Promise<number[][]>; | ||
type ChatCompletionMessage = ChatCompletionMessageParam; | ||
type ChatCompletionOptions = { | ||
type ChatCompletionOptions<T = any> = { | ||
model: T; | ||
systemRole: string; | ||
@@ -23,2 +25,3 @@ stream: boolean; | ||
interface LLM { | ||
getModels(): Promise<string[]>; | ||
createChatCompletion<T extends Partial<ChatCompletionOptions> & { | ||
@@ -32,6 +35,7 @@ [K: string]: any; | ||
type CreateChatCompletionOptions = Partial<ChatCompletionOptions> & Partial<Omit<ChatCompletionCreateParams, "input" | keyof ChatCompletionOptions>>; | ||
type CreateChatCompletionOptions = Partial<ChatCompletionOptions<ChatModel> & Omit<ChatCompletionCreateParams, keyof ChatCompletionOptions>>; | ||
declare class OpenAILLM implements LLM { | ||
private _openai; | ||
constructor(_openai: OpenAI); | ||
getModels(): Promise<ChatModel[]>; | ||
createChatCompletion<T extends CreateChatCompletionOptions, _ReturnType = T extends { | ||
@@ -38,0 +42,0 @@ stream: true; |
@@ -113,2 +113,3 @@ "use strict"; | ||
// src/llm/openai.ts | ||
var import_models = require("openai/resources/models.mjs"); | ||
var OpenAILLM = class { | ||
@@ -118,2 +119,9 @@ constructor(_openai) { | ||
} | ||
getModels() { | ||
return __async(this, null, function* () { | ||
const models = new import_models.Models(this._openai); | ||
const list = yield models.list(); | ||
return list.data.map((model) => model.id); | ||
}); | ||
} | ||
createChatCompletion(prompt, options) { | ||
@@ -120,0 +128,0 @@ return __async(this, null, function* () { |
{ | ||
"name": "@singlestore/ai", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33064
430