Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions langchain/src/experimental/openai_assistant/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { type ClientOptions, OpenAIClient } from "@langchain/openai";
import {
type ClientOptions,
type OpenAIChatModelId,
OpenAIClient,
} from "@langchain/openai";
import { StructuredTool } from "@langchain/core/tools";
import { Runnable, RunnableConfig } from "@langchain/core/runnables";
import { formatToOpenAIAssistantTool } from "@langchain/openai";
Expand Down Expand Up @@ -62,7 +66,7 @@ export class OpenAIAssistantRunnable<
pollIntervalMs,
fileIds,
}: Omit<OpenAIAssistantRunnableInput<AsAgent>, "assistantId"> & {
model: string;
model: OpenAIChatModelId;
name?: string;
instructions?: string;
tools?: OpenAIToolType | Array<StructuredTool>;
Expand Down Expand Up @@ -178,7 +182,7 @@ export class OpenAIAssistantRunnable<
instructions,
fileIds,
}: Omit<OpenAIAssistantRunnableInput<AsAgent>, "assistantId" | "tools"> & {
model?: string;
model?: OpenAIChatModelId;
name?: string;
instructions?: string;
fileIds?: string[];
Expand Down
11 changes: 9 additions & 2 deletions libs/langchain-anthropic/src/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ function isBuiltinTool(tool: unknown): tool is AnthropicBuiltInToolUnion {
);
}

/**
* @see https://docs.anthropic.com/claude/docs/models-overview
*/
export type AnthropicMessagesModelId =
| Anthropic.Model
| (string & NonNullable<unknown>);

/**
* Input to AnthropicChat class.
*/
Expand Down Expand Up @@ -170,9 +177,9 @@ export interface AnthropicInput {
anthropicApiUrl?: string;

/** @deprecated Use "model" instead */
modelName?: string;
modelName?: AnthropicMessagesModelId;
/** Model name to use */
model?: string;
model?: AnthropicMessagesModelId;

/** Overridable Anthropic ClientOptions */
clientOptions?: ClientOptions;
Expand Down
4 changes: 4 additions & 0 deletions libs/langchain-community/src/embeddings/fireworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export interface FireworksEmbeddingsParams extends EmbeddingsParams {
* @deprecated Use `model` instead.
*/
modelName: string;

/**
* Model name to use.
*/
model: string;

/**
Expand Down
11 changes: 9 additions & 2 deletions libs/langchain-openai/src/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import { OpenAICoreRequestOptions } from "./types.js";
import { getEndpoint, OpenAIEndpointConfig } from "./utils/azure.js";
import { wrapOpenAIClientError } from "./utils/openai.js";

/**
* @see https://platform.openai.com/docs/guides/embeddings#embedding-models
*/
export type OpenAIEmbeddingModelId =
| OpenAIClient.EmbeddingModel
| (string & NonNullable<unknown>);

/**
* Interface for OpenAIEmbeddings parameters. Extends EmbeddingsParams and
* defines additional parameters specific to the OpenAIEmbeddings class.
Expand All @@ -16,9 +23,9 @@ export interface OpenAIEmbeddingsParams extends EmbeddingsParams {
* Alias for `model`
* @deprecated Use "model" instead.
*/
modelName: string;
modelName: OpenAIEmbeddingModelId;
/** Model name to use */
model: string;
model: OpenAIEmbeddingModelId;

/**
* The number of dimensions the resulting output embeddings should have.
Expand Down
12 changes: 10 additions & 2 deletions libs/langchain-openai/src/tools/dalle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import {
MessageContentImageUrl,
} from "@langchain/core/messages";

/**
* @see https://platform.openai.com/docs/api-reference/images/create
*/
export type OpenAIImageModelId =
| OpenAIClient.ImageModel
| (string & NonNullable<unknown>);

/**
* An interface for the Dall-E API Wrapper.
*/
Expand All @@ -25,14 +32,15 @@ export interface DallEAPIWrapperParams extends ToolParams {
* Alias for `model`
* @params "dall-e-2" | "dall-e-3"
* @default "dall-e-3"
* @deprecated Use `model` instead.
*/
modelName?: string;
modelName?: OpenAIImageModelId;
/**
* The model to use.
* @params "dall-e-2" | "dall-e-3"
* @default "dall-e-3"
*/
model?: string;
model?: OpenAIImageModelId;
/**
* The style of the generated images. Must be one of vivid or natural.
* Vivid causes the model to lean towards generating hyper-real and dramatic images.
Expand Down
9 changes: 8 additions & 1 deletion libs/langchain-openai/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ import { InteropZodObject } from "@langchain/core/utils/types";
// also makes it easier for folks to import this type without digging around into the dependent packages
export type { TiktokenModel };

/**
* @see https://platform.openai.com/docs/models
*/
export type OpenAIChatModelId =
| OpenAIClient.ChatModel
| (string & NonNullable<unknown>);

export declare interface OpenAIBaseInput {
/** Sampling temperature to use */
temperature: number;
Expand Down Expand Up @@ -65,7 +72,7 @@ export declare interface OpenAIBaseInput {
modelName: string;

/** Model name to use */
model: string;
model: OpenAIChatModelId;

/** Holds any additional parameters that are valid to pass to {@link
* https://platform.openai.com/docs/api-reference/completions/create |
Expand Down
Loading