Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core[minor]: Unified model params for LS #5427

Merged
merged 12 commits into from
May 17, 2024
Prev Previous commit
Next Next commit
cohere fireworks ollama
bracesproul committed May 16, 2024
commit c6a7ccf55e18c5ebf456bdb09d3ed173f1f6fdd8
10 changes: 10 additions & 0 deletions libs/langchain-cohere/src/chat_models.ts
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
import {
type BaseChatModelParams,
BaseChatModel,
LangSmithParams,
} from "@langchain/core/language_models/chat_models";
import {
ChatGeneration,
@@ -145,6 +146,15 @@ export class ChatCohere<
this.streaming = fields?.streaming ?? this.streaming;
}

protected _getLsParams(_: this["ParsedCallOptions"]): LangSmithParams {
return {
ls_provider: "cohere",
ls_model_name: this.model,
ls_model_type: "chat",
ls_temperature: this.temperature ?? undefined,
};
}

_llmType() {
return "cohere";
}
11 changes: 10 additions & 1 deletion libs/langchain-community/src/chat_models/fireworks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { BaseChatModelParams } from "@langchain/core/language_models/chat_models";
import type {
BaseChatModelParams,
LangSmithParams,
} from "@langchain/core/language_models/chat_models";
import {
type OpenAIClient,
type ChatOpenAICallOptions,
@@ -101,6 +104,12 @@ export class ChatFireworks extends ChatOpenAI<ChatFireworksCallOptions> {
this.apiKey = fireworksApiKey;
}

protected _getLsParams(options: this["ParsedCallOptions"]): LangSmithParams {
const params = super._getLsParams(options);
params.ls_provider = "fireworks";
return params;
}

toJSON() {
const result = super.toJSON();

11 changes: 11 additions & 0 deletions libs/langchain-community/src/chat_models/ollama.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import type { BaseLanguageModelCallOptions } from "@langchain/core/language_mode
import {
SimpleChatModel,
type BaseChatModelParams,
LangSmithParams,
} from "@langchain/core/language_models/chat_models";
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
import {
@@ -176,6 +177,16 @@ export class ChatOllama
this.format = fields.format;
}

protected _getLsParams(_: this["ParsedCallOptions"]): LangSmithParams {
return {
ls_provider: "ollama",
ls_model_name: this.model,
ls_model_type: "chat",
ls_temperature: this.temperature ?? undefined,
ls_stop: this.stop,
};
}

_llmType() {
return "ollama";
}
Loading