⚡️ don't generate session titles ever if parallel generation not supported

This commit is contained in:
Nate Sesti 2024-01-30 18:53:50 -08:00
parent dd52cac4aa
commit 057111ceb9
3 changed files with 25 additions and 30 deletions

View file

@ -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,

View file

@ -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();

View file

@ -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),