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
6 changes: 4 additions & 2 deletions chainforge/react-server/src/LLMListComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ import { deepcopy, ensureUniqueName } from "./backend/utils";
import NestedMenu, { NestedMenuItemProps } from "./NestedMenu";

// The LLM(s) to include by default on a PromptNode whenever one is created.
// Defaults to ChatGPT (GPT3.5) when running locally, and HF-hosted falcon-7b for online version since it's free.
const DEFAULT_INIT_LLMS = [initLLMProviders[0]];
// Defaults to a cheap non-reasoning OpenAI model.
const DEFAULT_INIT_LLMS = [
initLLMProviders.find((m) => m.model === "gpt-4o-mini")!,
];

// Helper funcs
/** Get position CSS style below and left-aligned to the input element */
Expand Down
27 changes: 24 additions & 3 deletions chainforge/react-server/src/ModelSettingSchemas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ const ChatGPTSettings: ModelSettingsDict = {
description:
"Select an OpenAI model to query. For more details on the differences, see the OpenAI API documentation.",
enum: [
"gpt-5",
"gpt-5-mini",
"gpt-5-nano",
"gpt-5-chat-latest",
"o3",
"o3-mini",
"gpt-4.1",
"gpt-4.1-mini",
"gpt-4.1-nano",
Expand All @@ -64,7 +70,6 @@ const ChatGPTSettings: ModelSettingsDict = {
"o1",
"o1-mini",
"o1-pro",
"o3-mini",
"gpt-4.5-preview",
"gpt-3.5-turbo",
"gpt-4o-2024-05-13",
Expand Down Expand Up @@ -105,12 +110,28 @@ const ChatGPTSettings: ModelSettingsDict = {
type: "number",
title: "temperature",
description:
"What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
"What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. NOTE: GPT-5 models will ignore this parameter.",
default: 1,
minimum: 0,
maximum: 2,
multipleOf: 0.01,
},
reasoning_effort: {
type: "string",
title: "reasoning.effort",
description:
"A parameter specific to o1+ and GPT-5+ models that controls the amount of reasoning effort the model expends when generating a response. NOTE: Currently, only GPT-5 supports the 'minimal' option.",
enum: ["minimal", "low", "medium", "high"],
default: "medium", // TODO: Add reasoning.summary option to visualize reasoning tokens in UI.
},
verbosity: {
type: "string",
title: "verbosity",
description:
"A parameter specific to GPT-5+ models that determines how many output tokens are generated. Lowering the number of tokens reduces overall latency.",
enum: ["low", "medium", "high"],
default: "medium",
},
response_format: {
type: "string",
title: "response_format",
Expand Down Expand Up @@ -547,7 +568,7 @@ const GPTImage1Settings: ModelSettingsDict = {
title: "Model Version",
description:
"Select an OpenAI image model to query in the GPT Image series.",
enum: ["gpt-image-1"],
enum: ["gpt-image-1", "gpt-image-1-mini"],
default: "gpt-image-1",
},
size: {
Expand Down
1 change: 0 additions & 1 deletion chainforge/react-server/src/RequestClarificationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const RequestClarificationModal: React.FC<RequestClarificationModalProps> = ({
withCloseButton={false}
title={title}
centered
style={{ position: "relative", left: "-4%" }}
>
<form onSubmit={form.onSubmit(handleSubmit)}>
<TextInput
Expand Down
6 changes: 6 additions & 0 deletions chainforge/react-server/src/backend/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ export enum NativeLLM {
OpenAI_GPT4_1 = "gpt-4.1",
OpenAI_GPT4_1_mini = "gpt-4.1-mini",
OpenAI_GPT4_1_nano = "gpt-4.1-nano",
OpenAI_o3 = "o3",
OpenAI_GPT5 = "gpt-5",
OpenAI_GPT5_mini = "gpt-5-mini",
OpenAI_GPT5_nano = "gpt-5-nano",
OpenAI_GPT5_Chat = "gpt-5-chat-latest",

// OpenAI Text Completions (deprecated)
OpenAI_Davinci003 = "text-davinci-003",
Expand All @@ -47,6 +52,7 @@ export enum NativeLLM {
OpenAI_DallE_2 = "dall-e-2",
OpenAI_DallE_3 = "dall-e-3",
OpenAI_GPT_Image_1 = "gpt-image-1",
OpenAI_GPT_Image_1_mini = "gpt-image-1-mini",

// Azure OpenAI Endpoints
Azure_OpenAI = "azure-openai",
Expand Down
31 changes: 31 additions & 0 deletions chainforge/react-server/src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,19 @@ export async function call_chatgpt(
if (params?.tools === undefined && params?.parallel_tool_calls !== undefined)
delete params?.parallel_tool_calls;

// Pass in o3 and GPT-5+ only parameters, removing them if the
// model name does not correspond to those models:
// NOTE: Chat Completions passes reasoning_effort instead of a dictionary for 'reasoning'.
if (params?.reasoning_effort !== undefined) {
if (!(modelname.startsWith("o3") || modelname.startsWith("gpt-5")))
delete params?.reasoning_effort;
}
if (params?.verbosity !== undefined) {
// Only pass verbosity for o3 and GPT-5+ models
if (!(modelname.startsWith("o3") || modelname.startsWith("gpt-5")))
delete params?.verbosity;
}

if (!BASE_URL)
console.log(`Querying OpenAI model '${model}' with prompt '${prompt}'...`);

Expand Down Expand Up @@ -1012,6 +1025,8 @@ export async function call_google_ai(
}
}

let num_retries = 0;
const max_retries = 3;
while (responses.length < n) {
if (should_cancel && should_cancel()) throw new UserForcedPrematureExit();

Expand All @@ -1023,6 +1038,21 @@ export async function call_google_ai(

const chat_response = await chat.sendMessage({ message: prompt_parts });

// NOTE: Sometimes, Google's API returns empty responses.
// I'm not sure why this happens. In this case, we just retry until we get a non-empty response.
if (!chat_response?.text) {
if (num_retries >= max_retries) {
throw new Error(
"Maximum retries reached: Google Gemini is returning empty text responses. This happens occasionally due to ongoing issues with Google's API and the fix is unknown.",
);
}
num_retries += 1;
console.warn(
"Received empty response from Google Gemini; retrying once more...",
);
continue;
}

responses.push({
text: chat_response.text,
candidates: chat_response.candidates,
Expand Down Expand Up @@ -1782,6 +1812,7 @@ function _extract_google_ai_responses(
* Extracts the text part of a 'EnhancedGenerateContentResponse' object from Google Gemini `sendChat` or `chat`.
*/
function _extract_gemini_responses(completions: Array<Dict>): Array<string> {
console.log("Extracting Gemini responses from: ", completions);
return completions.map((c: Dict) => c.text);
}

Expand Down
32 changes: 30 additions & 2 deletions chainforge/react-server/src/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,27 @@ export const initLLMProviderMenu: (LLMSpec | LLMGroup)[] = [
group: "OpenAI",
emoji: "🤖",
items: [
{
name: "GPT-5",
emoji: "🚀",
model: "gpt-5",
base_model: "gpt-4",
temp: 1.0,
},
{
name: "GPT-5-mini",
emoji: "🔬",
model: "gpt-5-mini",
base_model: "gpt-4",
temp: 1.0,
},
{
name: "GPT-5-nano",
emoji: "🪲",
model: "gpt-5-nano",
base_model: "gpt-4",
temp: 1.0,
},
{
name: "GPT-4o-mini",
emoji: "🔬",
Expand Down Expand Up @@ -130,9 +151,9 @@ export const initLLMProviderMenu: (LLMSpec | LLMGroup)[] = [
temp: 1.0,
},
{
name: "o1",
name: "o3",
emoji: "⭕",
model: "o1",
model: "o3",
base_model: "gpt-4",
temp: 1.0,
},
Expand All @@ -143,6 +164,13 @@ export const initLLMProviderMenu: (LLMSpec | LLMGroup)[] = [
base_model: "gpt-4",
temp: 1.0,
},
{
name: "o1",
emoji: "⭕",
model: "o1",
base_model: "gpt-4",
temp: 1.0,
},
{
name: "GPT-3.5",
emoji: "🤖",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def readme():

setup(
name="chainforge",
version="0.3.6.3",
version="0.3.6.4",
packages=find_packages(),
author="Ian Arawjo",
description="A Visual Programming Environment for Prompt Engineering",
Expand Down