mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-27 12:29:41 +02:00
Test stream + Update Copy (#2317)
* update copy + conditional ordering * answer stream checks * update * add basic tests for chat streams * slightly simplify * fix typing * quick typing updates + nits
This commit is contained in:
@@ -24,7 +24,10 @@ export interface EmbeddingDetails {
|
||||
import { EmbeddingIcon } from "@/components/icons/icons";
|
||||
|
||||
import Link from "next/link";
|
||||
import { SavedSearchSettings } from "../../embeddings/interfaces";
|
||||
import {
|
||||
getCurrentModelCopy,
|
||||
SavedSearchSettings,
|
||||
} from "../../embeddings/interfaces";
|
||||
import UpgradingPage from "./UpgradingPage";
|
||||
import { useContext } from "react";
|
||||
import { SettingsContext } from "@/components/settings/SettingsProvider";
|
||||
@@ -75,20 +78,6 @@ function Main() {
|
||||
}
|
||||
|
||||
const currentModelName = currentEmeddingModel?.model_name;
|
||||
const AVAILABLE_CLOUD_PROVIDERS_FLATTENED = AVAILABLE_CLOUD_PROVIDERS.flatMap(
|
||||
(provider) =>
|
||||
provider.embedding_models.map((model) => ({
|
||||
...model,
|
||||
provider_type: provider.provider_type,
|
||||
model_name: model.model_name, // Ensure model_name is set for consistency
|
||||
}))
|
||||
);
|
||||
|
||||
const currentModel: CloudEmbeddingModel | HostedEmbeddingModel =
|
||||
AVAILABLE_MODELS.find((model) => model.model_name === currentModelName) ||
|
||||
AVAILABLE_CLOUD_PROVIDERS_FLATTENED.find(
|
||||
(model) => model.model_name === currentEmeddingModel.model_name
|
||||
)!;
|
||||
|
||||
return (
|
||||
<div className="h-screen">
|
||||
@@ -102,8 +91,8 @@ function Main() {
|
||||
)}
|
||||
<Title className="mb-6 mt-8 !text-2xl">Embedding Model</Title>
|
||||
|
||||
{currentModel ? (
|
||||
<ModelPreview model={currentModel} display />
|
||||
{currentEmeddingModel ? (
|
||||
<ModelPreview model={currentEmeddingModel} display />
|
||||
) : (
|
||||
<Title className="mt-8 mb-4">Choose your Embedding Model</Title>
|
||||
)}
|
||||
|
@@ -1,4 +1,10 @@
|
||||
import { EmbeddingProvider } from "@/components/embedding/interfaces";
|
||||
import {
|
||||
AVAILABLE_CLOUD_PROVIDERS,
|
||||
AVAILABLE_MODELS,
|
||||
CloudEmbeddingModel,
|
||||
EmbeddingProvider,
|
||||
HostedEmbeddingModel,
|
||||
} from "@/components/embedding/interfaces";
|
||||
|
||||
// This is a slightly differnte interface than used in the backend
|
||||
// but is always used in conjunction with `AdvancedSearchConfiguration`
|
||||
@@ -92,3 +98,24 @@ export const rerankingModels: RerankingModel[] = [
|
||||
link: "https://docs.cohere.com/docs/rerank",
|
||||
},
|
||||
];
|
||||
|
||||
export const getCurrentModelCopy = (
|
||||
currentModelName: string
|
||||
): CloudEmbeddingModel | HostedEmbeddingModel | null => {
|
||||
const AVAILABLE_CLOUD_PROVIDERS_FLATTENED = AVAILABLE_CLOUD_PROVIDERS.flatMap(
|
||||
(provider) =>
|
||||
provider.embedding_models.map((model) => ({
|
||||
...model,
|
||||
provider_type: provider.provider_type,
|
||||
model_name: model.model_name,
|
||||
}))
|
||||
);
|
||||
|
||||
return (
|
||||
AVAILABLE_MODELS.find((model) => model.model_name === currentModelName) ||
|
||||
AVAILABLE_CLOUD_PROVIDERS_FLATTENED.find(
|
||||
(model) => model.model_name === currentModelName
|
||||
) ||
|
||||
null
|
||||
);
|
||||
};
|
||||
|
@@ -1,15 +1,13 @@
|
||||
import { getCurrentModelCopy } from "@/app/admin/embeddings/interfaces";
|
||||
import {
|
||||
MicrosoftIcon,
|
||||
NomicIcon,
|
||||
OpenSourceIcon,
|
||||
} from "@/components/icons/icons";
|
||||
import {
|
||||
AVAILABLE_CLOUD_PROVIDERS,
|
||||
AVAILABLE_MODELS,
|
||||
EmbeddingModelDescriptor,
|
||||
getIconForRerankType,
|
||||
getTitleForRerankType,
|
||||
HostedEmbeddingModel,
|
||||
} from "./interfaces";
|
||||
import { FiExternalLink, FiStar } from "react-icons/fi";
|
||||
import { FiExternalLink } from "react-icons/fi";
|
||||
|
||||
export function ModelPreview({
|
||||
model,
|
||||
@@ -18,15 +16,17 @@ export function ModelPreview({
|
||||
model: EmbeddingModelDescriptor;
|
||||
display?: boolean;
|
||||
}) {
|
||||
const currentModelCopy = getCurrentModelCopy(model.model_name);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`border border-border rounded shadow-md ${display ? "bg-inverted rounded-lg p-4" : "bg-hover-light p-2"} w-96 flex flex-col`}
|
||||
>
|
||||
<div className="font-bold text-lg flex">{model.model_name}</div>
|
||||
<div className="text-sm mt-1 mx-1">
|
||||
{model.description
|
||||
? model.description
|
||||
: "Custom model—no description is available."}
|
||||
{model.description ||
|
||||
currentModelCopy?.description ||
|
||||
"Custom model—no description is available."}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -41,6 +41,8 @@ export function ModelOption({
|
||||
onSelect?: (model: HostedEmbeddingModel) => void;
|
||||
selected: boolean;
|
||||
}) {
|
||||
const currentModelCopy = getCurrentModelCopy(model.model_name);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`p-4 w-96 border rounded-lg transition-all duration-200 ${
|
||||
@@ -65,7 +67,9 @@ export function ModelOption({
|
||||
)}
|
||||
</div>
|
||||
<p className="text-sm k text-gray-600 text-left mb-2">
|
||||
{model.description || "Custom model—no description is available."}
|
||||
{model.description ||
|
||||
currentModelCopy?.description ||
|
||||
"Custom model—no description is available."}
|
||||
</p>
|
||||
<div className="text-xs text-gray-500">
|
||||
{model.isDefault ? "Default" : "Self-hosted"}
|
||||
|
Reference in New Issue
Block a user