diff --git a/core/context/retrieval.ts b/core/context/retrieval.ts index 57be93ac2..4ffc583cc 100644 --- a/core/context/retrieval.ts +++ b/core/context/retrieval.ts @@ -1,13 +1,8 @@ -import { - Chunk, - ContextItem, - ContextProviderExtras, - ILLM, - ModelProvider, -} from ".."; +import { Chunk, ContextItem, ContextProviderExtras, ILLM } from ".."; import { FullTextSearchCodebaseIndex } from "../indexing/FullTextSearch"; import { ChunkCodebaseIndex } from "../indexing/chunk/ChunkCodebaseIndex"; import { IndexTag } from "../indexing/types"; +import { llmCanGenerateInParallel } from "../llm"; import { getBasename } from "../util"; const RERANK_PROMPT = ( @@ -50,28 +45,6 @@ ${document} Relevant: `; -const PARALLEL_PROVIDERS: ModelProvider[] = [ - "anthropic", - "bedrock", - "deepinfra", - "gemini", - "google-palm", - "huggingface-inference-api", - "huggingface-tgi", - "mistral", - "free-trial", - "replicate", - "together", -]; - -function llmCanGenerateInParallel(llm: ILLM): boolean { - if (llm.providerName === "openai") { - return llm.model.includes("gpt"); - } - - return PARALLEL_PROVIDERS.includes(llm.providerName); -} - async function scoreChunk( chunk: Chunk, llm: ILLM, diff --git a/core/llm/index.ts b/core/llm/index.ts index b883bf196..3dcb6a2d5 100644 --- a/core/llm/index.ts +++ b/core/llm/index.ts @@ -88,6 +88,27 @@ export function modelSupportsImages( return false; } +const PARALLEL_PROVIDERS: ModelProvider[] = [ + "anthropic", + "bedrock", + "deepinfra", + "gemini", + "google-palm", + "huggingface-inference-api", + "huggingface-tgi", + "mistral", + "free-trial", + "replicate", + "together", +]; + +export function llmCanGenerateInParallel(llm: ILLM): boolean { + if (llm.providerName === "openai") { + return llm.model.includes("gpt"); + } + + return PARALLEL_PROVIDERS.includes(llm.providerName); +} function autodetectTemplateType(model: string): TemplateType | undefined { const lower = model.toLowerCase(); diff --git a/gui/src/hooks/useHistory.tsx b/gui/src/hooks/useHistory.tsx index f19f4b736..a6b9edfca 100644 --- a/gui/src/hooks/useHistory.tsx +++ b/gui/src/hooks/useHistory.tsx @@ -1,6 +1,7 @@ import { Dispatch } from "@reduxjs/toolkit"; import { PersistedSessionInfo, SessionInfo } from "core"; import { ideRequest } from "core/ide/messaging"; +import { llmCanGenerateInParallel } from "core/llm"; import { stripImages } from "core/llm/countTokens"; import { useSelector } from "react-redux"; import { defaultModelSelector } from "../redux/selectors/modelSelectors"; @@ -36,7 +37,7 @@ function useHistory(dispatch: Dispatch) { stripImages(stateCopy.history[0].message.content), 50 ); - if (!disableSessionTitles) { + if (!disableSessionTitles && llmCanGenerateInParallel(defaultModel)) { let { content } = await defaultModel.chat( [ ...stateCopy.history.map((item) => item.message),