use claude-3-5-sonnet-latest everywhere
This commit is contained in:
parent
80ad763531
commit
0ff3e6f402
10 changed files with 234 additions and 577 deletions
|
|
@ -6,7 +6,7 @@ import {
|
|||
} from "../";
|
||||
|
||||
export const DEFAULT_CHAT_MODEL_CONFIG: ModelDescription = {
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
provider: "anthropic",
|
||||
apiKey: "",
|
||||
title: "Claude 3.5 Sonnet",
|
||||
|
|
@ -23,7 +23,7 @@ export const FREE_TRIAL_MODELS: ModelDescription[] = [
|
|||
{
|
||||
title: "Claude 3.5 Sonnet (Free Trial)",
|
||||
provider: "free-trial",
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
systemMessage:
|
||||
"You are an expert software developer. You give helpful and concise responses.",
|
||||
},
|
||||
|
|
|
|||
|
|
@ -648,6 +648,7 @@ declare global {
|
|||
| "gemma-7b-it"
|
||||
| "gemma2-9b-it"
|
||||
// Anthropic
|
||||
| "claude-3-5-sonnet-latest"
|
||||
| "claude-3-5-sonnet-20240620"
|
||||
| "claude-3-opus-20240229"
|
||||
| "claude-3-sonnet-20240229"
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -710,6 +710,7 @@ export type ModelName =
|
|||
| "gemma-7b-it"
|
||||
| "gemma2-9b-it"
|
||||
// Anthropic
|
||||
| "claude-3-5-sonnet-latest"
|
||||
| "claude-3-5-sonnet-20240620"
|
||||
| "claude-3-opus-20240229"
|
||||
| "claude-3-sonnet-20240229"
|
||||
|
|
|
|||
|
|
@ -11,16 +11,17 @@ import { streamSse } from "../stream.js";
|
|||
class Anthropic extends BaseLLM {
|
||||
static providerName: ModelProvider = "anthropic";
|
||||
static defaultOptions: Partial<LLMOptions> = {
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
contextLength: 200_000,
|
||||
completionOptions: {
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
maxTokens: 4096,
|
||||
},
|
||||
apiBase: "https://api.anthropic.com/v1/",
|
||||
};
|
||||
|
||||
public convertArgs(options: CompletionOptions) { // should be public for use within VertexAI
|
||||
public convertArgs(options: CompletionOptions) {
|
||||
// should be public for use within VertexAI
|
||||
const finalOptions = {
|
||||
top_k: options.topK,
|
||||
top_p: options.topP,
|
||||
|
|
@ -34,53 +35,61 @@ class Anthropic extends BaseLLM {
|
|||
return finalOptions;
|
||||
}
|
||||
|
||||
public convertMessages(msgs: ChatMessage[]): any[] { // should be public for use within VertexAI
|
||||
const filteredmessages = msgs.filter((m) => m.role !== "system")
|
||||
const lastTwoUserMsgIndices = filteredmessages
|
||||
public convertMessages(msgs: ChatMessage[]): any[] {
|
||||
// should be public for use within VertexAI
|
||||
const filteredmessages = msgs.filter((m) => m.role !== "system");
|
||||
const lastTwoUserMsgIndices = filteredmessages
|
||||
.map((msg, index) => (msg.role === "user" ? index : -1))
|
||||
.filter((index) => index !== -1).slice(-2);
|
||||
.filter((index) => index !== -1)
|
||||
.slice(-2);
|
||||
|
||||
const messages = filteredmessages.map((message, filteredMsgIdx) => {
|
||||
// Add cache_control parameter to the last two user messages
|
||||
// The second-to-last because it retrieves potentially already cached contents,
|
||||
// The last one because we want it cached for later retrieval.
|
||||
// See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
||||
const addCaching = this.cacheBehavior?.cacheConversation && lastTwoUserMsgIndices.includes(filteredMsgIdx);
|
||||
// Add cache_control parameter to the last two user messages
|
||||
// The second-to-last because it retrieves potentially already cached contents,
|
||||
// The last one because we want it cached for later retrieval.
|
||||
// See: https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
|
||||
const addCaching =
|
||||
this.cacheBehavior?.cacheConversation &&
|
||||
lastTwoUserMsgIndices.includes(filteredMsgIdx);
|
||||
|
||||
if (typeof message.content === "string") {
|
||||
var chatMessage = {
|
||||
...message,
|
||||
content: [{
|
||||
type: "text",
|
||||
text: message.content,
|
||||
...(addCaching? { cache_control: { type: "ephemeral" } } : {})
|
||||
}]
|
||||
};
|
||||
return chatMessage;
|
||||
}
|
||||
|
||||
return {
|
||||
if (typeof message.content === "string") {
|
||||
var chatMessage = {
|
||||
...message,
|
||||
content: message.content.map((part, contentIdx) => {
|
||||
if (part.type === "text") {
|
||||
const newpart = {
|
||||
...part,
|
||||
// If multiple text parts, only add cache_control to the last one
|
||||
...((addCaching && contentIdx == message.content.length - 1) ? { cache_control: { type: "ephemeral" } } : {})
|
||||
};
|
||||
return newpart;
|
||||
}
|
||||
return {
|
||||
type: "image",
|
||||
source: {
|
||||
type: "base64",
|
||||
media_type: "image/jpeg",
|
||||
data: part.imageUrl?.url.split(",")[1],
|
||||
},
|
||||
};
|
||||
}),
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: message.content,
|
||||
...(addCaching ? { cache_control: { type: "ephemeral" } } : {}),
|
||||
},
|
||||
],
|
||||
};
|
||||
});
|
||||
return chatMessage;
|
||||
}
|
||||
|
||||
return {
|
||||
...message,
|
||||
content: message.content.map((part, contentIdx) => {
|
||||
if (part.type === "text") {
|
||||
const newpart = {
|
||||
...part,
|
||||
// If multiple text parts, only add cache_control to the last one
|
||||
...(addCaching && contentIdx == message.content.length - 1
|
||||
? { cache_control: { type: "ephemeral" } }
|
||||
: {}),
|
||||
};
|
||||
return newpart;
|
||||
}
|
||||
return {
|
||||
type: "image",
|
||||
source: {
|
||||
type: "base64",
|
||||
media_type: "image/jpeg",
|
||||
data: part.imageUrl?.url.split(",")[1],
|
||||
},
|
||||
};
|
||||
}),
|
||||
};
|
||||
});
|
||||
return messages;
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +107,8 @@ class Anthropic extends BaseLLM {
|
|||
messages: ChatMessage[],
|
||||
options: CompletionOptions,
|
||||
): AsyncGenerator<ChatMessage> {
|
||||
const shouldCacheSystemMessage = !!this.systemMessage && this.cacheBehavior?.cacheSystemMessage;
|
||||
const shouldCacheSystemMessage =
|
||||
!!this.systemMessage && this.cacheBehavior?.cacheSystemMessage;
|
||||
const systemMessage: string = stripImages(
|
||||
messages.filter((m) => m.role === "system")[0]?.content,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ class FreeTrial extends BaseLLM {
|
|||
async listModels(): Promise<string[]> {
|
||||
return [
|
||||
"codestral-latest",
|
||||
"claude-3-5-sonnet-20240620",
|
||||
"claude-3-5-sonnet-latest",
|
||||
"llama3.1-405b",
|
||||
"llama3.1-70b",
|
||||
"gpt-4o",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ Our current top recommendation is Claude Sonnet 3.5 from [Anthropic](../customiz
|
|||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"apiKey": "[ANTHROPIC_API_KEY]"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ We recommend configuring **Claude 3.5 Sonnet** as your chat model.
|
|||
{
|
||||
"title": "Claude 3.5 Sonnet",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
|
|
@ -61,7 +61,7 @@ To enable caching of the system message and the turn-by-turn conversation, updat
|
|||
},
|
||||
"title": "Anthropic",
|
||||
"provider": "anthropic",
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"apiKey": "[API_KEY]"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const val DEFAULT_CONFIG =
|
|||
{
|
||||
"models": [
|
||||
{
|
||||
"model": "claude-3-5-sonnet-20240620",
|
||||
"model": "claude-3-5-sonnet-latest",
|
||||
"provider": "anthropic",
|
||||
"apiKey": "",
|
||||
"title": "Claude 3.5 Sonnet"
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
import { ILLM, ModelProvider } from "core";
|
||||
import { InputDescriptor } from "./providers";
|
||||
import { ModelProviderTags } from "../../../components/modelSelection/utils";
|
||||
import { InputDescriptor } from "./providers";
|
||||
|
||||
// A dimension is like parameter count - 7b, 13b, 34b, etc.
|
||||
// You would set options to the field that should be changed for that option in the params field of ModelPackage
|
||||
|
|
@ -752,7 +752,7 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
description:
|
||||
"Anthropic's most intelligent model, but much less expensive than Claude 3 Opus",
|
||||
params: {
|
||||
model: "claude-3-5-sonnet-20240620",
|
||||
model: "claude-3-5-sonnet-latest",
|
||||
contextLength: 200_000,
|
||||
title: "Claude 3.5 Sonnet",
|
||||
apiKey: "",
|
||||
|
|
@ -870,27 +870,29 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
},
|
||||
granite3Instruct8b: {
|
||||
title: "Granite 3.0 8b Instruct",
|
||||
description: "The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
|
||||
description:
|
||||
"The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
|
||||
params: {
|
||||
model: "ibm/granite-3-8b-instruct",
|
||||
contextLength: 8_000,
|
||||
title: "Granite 3.0 8b Instruct"
|
||||
title: "Granite 3.0 8b Instruct",
|
||||
},
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "WatsonX.png",
|
||||
isOpenSource: false
|
||||
isOpenSource: false,
|
||||
},
|
||||
granite3Instruct2b: {
|
||||
title: "Granite 3.0 2b Instruct",
|
||||
description: "The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
|
||||
description:
|
||||
"The Granite model series is a family of IBM-trained, dense decoder-only models, which are particularly well-suited for generative tasks.",
|
||||
params: {
|
||||
model: "ibm/granite-3-2b-instruct",
|
||||
contextLength: 2_000,
|
||||
title: "Granite 3.0 2b Instruct"
|
||||
title: "Granite 3.0 2b Instruct",
|
||||
},
|
||||
providerOptions: ["watsonx"],
|
||||
icon: "WatsonX.png",
|
||||
isOpenSource: false
|
||||
isOpenSource: false,
|
||||
},
|
||||
MistralLarge: {
|
||||
title: "Mistral Large",
|
||||
|
|
@ -973,8 +975,6 @@ export const models: { [key: string]: ModelPackage } = {
|
|||
isOpenSource: false,
|
||||
},
|
||||
|
||||
|
||||
|
||||
gpt4gov: {
|
||||
title: "GPT-4 gov",
|
||||
description:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue