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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Now you can open the browser of your choice and open `http://127.0.0.1:8000`.

- OpenAI
- Anthropic
- Google (Gemini, PaLM2)
- Google Gemini
- DeepSeek
- HuggingFace (Inference and Endpoints)
- Together.ai
Expand Down
756 changes: 143 additions & 613 deletions chainforge/react-server/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions chainforge/react-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@fontsource/geist-mono": "^5.0.1",
"@google-ai/generativelanguage": "^0.2.0",
"@google/generative-ai": "^0.21.0",
"@google/genai": "^1.19.0",
"@mantine/core": "^6.0.9",
"@mantine/dates": "^6.0.13",
"@mantine/dropzone": "^6.0.19",
Expand Down Expand Up @@ -66,7 +65,7 @@
"lz-string": "^1.5.0",
"mantine-contextmenu": "^6.1.0",
"mantine-react-table": "^1.3.4",
"markdown-it": "^13.0.1",
"markdown-it": "^13.0.2",
"mathjs": "^11.8.2",
"mdast-util-from-markdown": "^2.0.0",
"net": "^1.0.2",
Expand Down Expand Up @@ -136,6 +135,7 @@
"devDependencies": {
"@craco/craco": "^7.1.0",
"@types/lodash": "^4.17.0",
"@types/markdown-it": "^14.1.2",
"@types/papaparse": "^5.3.14",
"@types/react-beautiful-dnd": "^13.1.8",
"@types/react-edit-text": "^5.0.4",
Expand Down
15 changes: 8 additions & 7 deletions chainforge/react-server/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,26 +106,27 @@ import {
// Device / Browser detection
import {
isMobile,
isTablet,
isChrome,
isFirefox,
isEdgeChromium,
isChromium,
isMobileSafari,
} from "react-device-detect";
import MultiEvalNode from "./MultiEvalNode";
import FlowSidebar from "./FlowSidebar";
import NestedMenu, { NestedMenuItemProps } from "./NestedMenu";
import RequestClarificationModal, {
RequestClarificationModalProps,
} from "./RequestClarificationModal";
import { xorBy } from "lodash";

const IS_ACCEPTED_BROWSER =
(isChrome ||
isChromium ||
isEdgeChromium ||
isFirefox ||
(navigator as any)?.brave !== undefined) &&
!isMobile;
(!isMobile || (isTablet && !isMobileSafari));

// Whether we are running on localhost or not, and hence whether
// we have access to the Flask backend for, e.g., Python code evaluation.
Expand Down Expand Up @@ -185,13 +186,13 @@ const INITIAL_LLM = () => {
// Prefer OpenAI for majority of local users.
const chatgpt = {
key: uuid(),
name: "GPT3.5",
name: "GPT-4o-mini",
emoji: "🤖",
model: "gpt-3.5-turbo",
base_model: "gpt-3.5-turbo",
model: "gpt-4o-mini",
base_model: "gpt-4",
temp: 1.0,
settings: getDefaultModelSettings("gpt-3.5-turbo"),
formData: getDefaultModelFormData("gpt-3.5-turbo"),
settings: getDefaultModelSettings("gpt-4"),
formData: getDefaultModelFormData("gpt-4"),
} satisfies LLMSpec;
chatgpt.formData.shortname = chatgpt.name;
chatgpt.formData.model = chatgpt.model;
Expand Down
2 changes: 1 addition & 1 deletion chainforge/react-server/src/GlobalSettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ const GlobalSettingsModal = forwardRef<GlobalSettingsModalRef, object>(
<br />
<TextInput
label="Google AI API Key (Gemini)"
placeholder="Paste your Google Gemini/PaLM API key here"
placeholder="Paste your Google Gemini API key here"
{...form.getInputProps("Google")}
/>
<br />
Expand Down
65 changes: 32 additions & 33 deletions chainforge/react-server/src/ModelSettingSchemas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ChatGPTSettings: ModelSettingsDict = {
"text-davinci-002",
"code-davinci-002",
],
default: "gpt-3.5-turbo",
default: "gpt-4o-mini",
},
system_msg: {
type: "string",
Expand Down Expand Up @@ -318,18 +318,18 @@ const GPT4Settings: ModelSettingsDict = {
title: "Nickname",
description:
"Unique identifier to appear in ChainForge. Keep it short.",
default: "GPT-4o",
default: "GPT-4o-mini",
},
model: {
...ChatGPTSettings.schema.properties.model,
default: "gpt-4o",
default: "gpt-4o-mini",
},
},
},
uiSchema: {
...ChatGPTSettings.uiSchema,
model: {
"ui:help": "Defaults to gpt-4o.",
"ui:help": "Defaults to gpt-4o-mini.",
"ui:widget": "datalist",
},
},
Expand Down Expand Up @@ -833,7 +833,7 @@ const ClaudeSettings: ModelSettingsDict = {
},
};

const PaLM2Settings: ModelSettingsDict = {
const Gemini25Settings: ModelSettingsDict = {
fullName: "Google AI Models (Gemini)",
schema: {
type: "object",
Expand All @@ -850,30 +850,29 @@ const PaLM2Settings: ModelSettingsDict = {
type: "string",
title: "Model",
description:
"Select a PaLM model to query. For more details on the differences, see the Google PaLM API documentation.",
"Select a Gemini model to query. For more details on the differences, see the Google Gemini API documentation.",
enum: [
"gemini-2.5-pro-preview-03-25",
"gemini-2.5-pro",
"gemini-2.5-flash",
"gemini-2.5-flash-lite",
"gemini-2.0-flash",
"gemini-2.0-flash-lite",
"gemini-1.5-flash",
"gemini-1.5-flash-8b",
"gemini-1.5-pro",
"gemini-1.0-pro",
"gemini-pro",
"text-bison-001",
"chat-bison-001",
"gemini-embedding-001",
"text-embedding-005",
"text-embedding-004",
"text-multilingual-embedding-002",
],
default: "gemini-1.5-flash",
default: "gemini-2.5-flash",
shortname_map: {
"text-bison-001": "PaLM2-text",
"chat-bison-001": "PaLM2-chat",
"gemini-pro": "Gemini 1.0",
"gemini-2.5-pro-preview-03-25": "Gemini 2.5",
"gemini-2.5-pro": "Gemini 2.5 Pro",
"gemini-2.5-flash": "Gemini 2.5 Flash",
"gemini-2.5-flash-lite": "Gemini 2.5 Flash Lite",
"gemini-2.0-flash": "Gemini 2.0 Flash",
"gemini-1.5-pro": "Gemini 1.5",
"gemini-1.0-pro": "Gemini 1.0",
"gemini-1.5-flash": "Gemini Flash",
"gemini-1.5-flash-8b": "Gemini Flash 8B",
"gemini-2.0-flash-lite": "Gemini 2.0 Flash Lite",
"gemini-embedding-001": "gemini-embedding-001",
"text-embedding-005": "text-embedding-005",
"text-embedding-004": "text-embedding-004",
"text-multilingual-embedding-002": "text-multilingual-embedding-002",
},
},
system_msg: {
Expand All @@ -887,25 +886,25 @@ const PaLM2Settings: ModelSettingsDict = {
type: "number",
title: "temperature",
description:
"Controls the randomness of the output. Must be positive. Typical values are in the range: [0.0, 1.0]. Higher values produce a more random and varied response. A temperature of zero will be deterministic. (ChainForge only allows a max 1.0 temperature for PaLM).",
default: 0.5,
"Controls the randomness of the output. Must be positive. Typical values are in the range: [0.0, 1.0]. Higher values produce a more random and varied response. A temperature of zero will be deterministic.",
default: 0.7,
minimum: 0,
maximum: 1,
maximum: 2,
multipleOf: 0.01,
},
top_k: {
type: "integer",
title: "top_k",
description:
"Sets the maximum number of tokens to sample from on each step. (The PaLM API uses combined nucleus and top-k sampling.) Set to -1 to use the default value.",
"Sets the maximum number of tokens to sample from on each step. (The Gemini API uses combined nucleus and top-k sampling.) Set to -1 to use the default value.",
minimum: -1,
default: -1,
},
top_p: {
type: "number",
title: "top_p",
description:
"Sets the maximum cumulative probability of tokens to sample from. (The PaLM API uses combined nucleus and top-k sampling.) Set to -1 to use the default value.",
"Sets the maximum cumulative probability of tokens to sample from. (The Gemini API uses combined nucleus and top-k sampling.) Set to -1 to use the default value.",
default: -1,
minimum: -1,
maximum: 1,
Expand Down Expand Up @@ -935,14 +934,14 @@ const PaLM2Settings: ModelSettingsDict = {
"ui:autofocus": true,
},
model: {
"ui:help": "Defaults to gemini-pro.",
"ui:help": "Defaults to gemini-2.5-flash.",
"ui:widget": "datalist",
},
system_msg: {
"ui:widget": "textarea",
},
temperature: {
"ui:help": "Defaults to 0.5.",
"ui:help": "Defaults to 0.7.",
"ui:widget": "range",
},
max_output_tokens: {
Expand Down Expand Up @@ -2481,7 +2480,7 @@ export const ModelSettings: Dict<ModelSettingsDict> = {
"dall-e": DalleSettings,
"gpt-image-1": GPTImage1Settings,
"claude-v1": ClaudeSettings,
"palm2-bison": PaLM2Settings,
"gemini-2.5": Gemini25Settings,
"azure-openai": AzureOpenAISettings,
hf: HuggingFaceTextInferenceSettings,
"luminous-base": AlephAlphaLuminousSettings,
Expand All @@ -2508,7 +2507,7 @@ export function baseModelToProvider(base_model: string): LLMProvider {
"dall-e": LLMProvider.OpenAI,
"gpt-image-1": LLMProvider.OpenAI,
"claude-v1": LLMProvider.Anthropic,
"palm2-bison": LLMProvider.Google,
"gemini-2.5": LLMProvider.Google,
"azure-openai": LLMProvider.Azure_OpenAI,
hf: LLMProvider.HuggingFace,
"luminous-base": LLMProvider.Aleph_Alpha,
Expand Down Expand Up @@ -2537,7 +2536,7 @@ export function getSettingsSchemaForLLM(
} = {
[LLMProvider.OpenAI]: GPT4Settings,
[LLMProvider.Anthropic]: ClaudeSettings,
[LLMProvider.Google]: PaLM2Settings,
[LLMProvider.Google]: Gemini25Settings,
[LLMProvider.Azure_OpenAI]: AzureOpenAISettings,
[LLMProvider.HuggingFace]: HuggingFaceTextInferenceSettings,
[LLMProvider.Aleph_Alpha]: AlephAlphaLuminousSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test("call three LLMs with a single prompt", async () => {
const llms = [
NativeLLM.OpenAI_ChatGPT,
NativeLLM.Claude_v1,
NativeLLM.PaLM2_Chat_Bison,
NativeLLM.GEMINI_v2_5_flash,
];
const n = 1;
const progress_listener = (progress: { [key: symbol]: any }) => {
Expand Down
4 changes: 2 additions & 2 deletions chainforge/react-server/src/backend/__test__/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ test("basic prompt pipeline with anthropic", async () => {
await prompt_model(NativeLLM.Claude_v1, LLMProvider.Anthropic);
}, 40000);

test("basic prompt pipeline with google palm2", async () => {
await prompt_model(NativeLLM.PaLM2_Chat_Bison, LLMProvider.Google);
test("basic prompt pipeline with google gemini 2.5 flash", async () => {
await prompt_model(NativeLLM.GEMINI_v2_5_flash, LLMProvider.Google);
}, 40000);
44 changes: 0 additions & 44 deletions chainforge/react-server/src/backend/__test__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
call_alephalpha,
call_anthropic,
call_chatgpt,
call_google_palm,
extract_responses,
merge_response_objs,
} from "../utils";
Expand Down Expand Up @@ -116,48 +115,6 @@ test("anthropic models", async () => {
expect(typeof resps[0]).toBe("string");
}, 20000);

test("google palm2 models", async () => {
// Call Google's PaLM Chat API with a basic question
let [query, response] = await call_google_palm(
"Who invented modern playing cards?",
NativeLLM.PaLM2_Chat_Bison,
3,
0.7,
);
expect(response.candidates).toHaveLength(3);
expect(query).toHaveProperty("candidateCount");

// Extract responses, check their type
let resps = extract_responses(
response,
NativeLLM.PaLM2_Chat_Bison,
LLMProvider.Google,
);
expect(resps).toHaveLength(3);
expect(typeof resps[0]).toBe("string");
console.log(JSON.stringify(resps));

// Call Google's PaLM Text Completions API with a basic question
[query, response] = await call_google_palm(
"Who invented modern playing cards? The answer ",
NativeLLM.PaLM2_Text_Bison,
3,
0.7,
);
expect(response.candidates).toHaveLength(3);
expect(query).toHaveProperty("maxOutputTokens");

// Extract responses, check their type
resps = extract_responses(
response,
NativeLLM.PaLM2_Chat_Bison,
LLMProvider.Google,
);
expect(resps).toHaveLength(3);
expect(typeof resps[0]).toBe("string");
console.log(JSON.stringify(resps));
}, 40000);

test("aleph alpha model", async () => {
let [query, response] = await call_alephalpha(
"Who invented modern playing cards?",
Expand All @@ -177,7 +134,6 @@ test("aleph alpha model", async () => {
expect(typeof resps[0]).toBe("string");
console.log(JSON.stringify(resps));

// Call Google's PaLM Text Completions API with a basic question
// eslint-disable-next-line
[query, response] = await call_alephalpha(
"Who invented modern playing cards? The answer ",
Expand Down
17 changes: 7 additions & 10 deletions chainforge/react-server/src/backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,14 @@ export enum NativeLLM {
Claude_v1_instant = "claude-instant-v1",

// Google models
PaLM2_Text_Bison = "text-bison-001", // it's really models/text-bison-001, but that's confusing
PaLM2_Chat_Bison = "chat-bison-001",
GEMINI_PRO = "gemini-pro",
GEMINI_v2_5_pro_prev = "gemini-2.5-pro-preview-03-25",
GEMINI_v2_5_pro = "gemini-2.5-pro",
GEMINI_v2_5_flash = "gemini-2.5-flash",
GEMINI_v2_5_flash_lite = "gemini-2.5-flash-lite",
GEMINI_v2_flash = "gemini-2.0-flash",
GEMINI_v2_flash_lite = "gemini-2.0-flash-lite",
GEMINI_v1_5_flash = "gemini-1.5-flash",
GEMINI_v1_5_flash_8B = "gemini-1.5-flash-8b",
GEMINI_v1_5_pro = "gemini-1.5-pro",
GEMINI_v1_pro = "gemini-1.0-pro",

// DeepSeek
DeepSeek_Chat = "deepseek-chat",
Expand Down Expand Up @@ -253,8 +251,7 @@ export function getProvider(llm: LLM): LLMProvider | undefined {
const llm_name = getEnumName(NativeLLM, llm.toString());
if (llm_name?.startsWith("OpenAI")) return LLMProvider.OpenAI;
else if (llm_name?.startsWith("Azure")) return LLMProvider.Azure_OpenAI;
else if (llm_name?.startsWith("PaLM2") || llm_name?.startsWith("GEMINI"))
return LLMProvider.Google;
else if (llm_name?.startsWith("GEMINI")) return LLMProvider.Google;
else if (llm_name?.startsWith("HF_")) return LLMProvider.HuggingFace;
else if (llm.toString().startsWith("claude")) return LLMProvider.Anthropic;
else if (llm_name?.startsWith("Aleph_Alpha")) return LLMProvider.Aleph_Alpha;
Expand Down Expand Up @@ -290,9 +287,9 @@ export const RATE_LIMIT_BY_MODEL: { [key in LLM]?: number } = {
[NativeLLM.OpenAI_DallE_2]: 10, // Should be 5 images per minute (1 img per every 10 seconds); here, we've been a bit lenient with it.
[NativeLLM.OpenAI_DallE_3]: 10, // This differs per tier, see https://platform.openai.com/docs/guides/rate-limits/usage-tiers?context=tier-one
[NativeLLM.Azure_OpenAI]: 500, // conservative
[NativeLLM.PaLM2_Text_Bison]: 60, // max 60 requests per minute as of Mar 2023
[NativeLLM.PaLM2_Chat_Bison]: 60,
[NativeLLM.GEMINI_PRO]: 60,
[NativeLLM.GEMINI_v2_5_pro]: 150,
[NativeLLM.GEMINI_v2_5_flash]: 1000,
[NativeLLM.GEMINI_v2_5_flash_lite]: 4000,
[NativeLLM.Bedrock_Jurassic_Mid]: 400,
[NativeLLM.Bedrock_Jurassic_Ultra]: 25,
[NativeLLM.Bedrock_Titan_Light]: 800,
Expand Down
Loading
Loading