Skip to content

Commit

Permalink
feat: improve chat behavior
Browse files Browse the repository at this point in the history
- Make links clickable in SourceSection
- Update model selection logic in chat routes
- Remove gemini-2.0-flash-exp references from plugin
- Add enableSearchGrounding parameter to chat route

Co-Authored-By: ben <ben@prologe.io>
  • Loading branch information
1 parent be13d93 commit 42ae342
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/plugin/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class FileOrganizerSettings {
useVaultTitles = true;
showLocalLLMInChat = false;
customFolderInstructions = "";
selectedModel: "gpt-4o" | "llama3.2" | "gemini-2.0-flash-exp" = "gpt-4o";
selectedModel: "gpt-4o" | "llama3.2" = "gpt-4o";
customModelName = "llama3.2";
tagScoreThreshold = 70;
formatBehavior: "override" | "newFile" = "override";
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/views/assistant/ai-chat/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ export const ChatComponent: React.FC<ChatComponentProps> = ({
// Handle different model types
if (
!plugin.settings.showLocalLLMInChat ||
selectedModel === "gpt-4o" ||
selectedModel === "gemini-2.0-flash-exp"
selectedModel === "gpt-4o"
) {
// Use server fetch for non-local models
return fetch(url, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,14 @@ export function SourcesSection({ groundingMetadata }: SourcesSectionProps) {
</div>
<div className="flex-grow min-w-0">
<h4 className="font-medium text-sm text-gray-900 dark:text-gray-100 truncate">
{source.title || source.domain}
<a
href={source.url}
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 hover:underline"
>
{source.title || source.domain}
</a>
</h4>
<p className="text-xs text-gray-500 dark:text-gray-400 truncate">
{source.domain}
Expand Down
10 changes: 2 additions & 8 deletions packages/plugin/views/assistant/ai-chat/model-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { usePlugin } from '../provider';
const MODEL_DISPLAY_NAMES: Record<ModelType, string> = {
'gpt-4o': 'Classic',
'llama3.2': 'Local LLM',
'gemini-2.0-flash-exp': 'Internet Search',
'custom': 'Ollama Model'
} as const;

Expand Down Expand Up @@ -35,7 +34,7 @@ export const ModelSelector: React.FC<ModelSelectorProps> = ({
return;
}
onModelSelect(model);
if (model === "gpt-4o" || model === "llama3.2" || model === "gemini-2.0-flash-exp") {
if (model === "gpt-4o" || model === "llama3.2") {
plugin.settings.selectedModel = model;
}
await plugin.saveSettings();
Expand Down Expand Up @@ -85,12 +84,7 @@ export const ModelSelector: React.FC<ModelSelectorProps> = ({
>
{getDisplayName("gpt-4o")}
</div>
<div
onClick={() => handleModelSelect("gemini-2.0-flash-exp")}
className="cursor-pointer block w-full text-left px-4 py-2 text-sm text-[--text-normal] hover:bg-[--background-modifier-hover]"
>
{getDisplayName("gemini-2.0-flash-exp")}
</div>

{isCustomizing ? (
<div className="px-4 py-2">
<input
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/views/assistant/ai-chat/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type ModelType = "gpt-4o" | "llama3.2" | "gemini-2.0-flash-exp" | string;
export type ModelType = "gpt-4o" | "llama3.2" | string;
12 changes: 11 additions & 1 deletion packages/web/app/api/(newai)/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ export async function POST(req: NextRequest) {
currentDatetime,
unifiedContext: oldUnifiedContext,
model: bodyModel,
enableSearchGrounding = false,
} = await req.json();

const chosenModelName = bodyModel;
let chosenModelName;
if (enableSearchGrounding) {
if (process.env.GOOGLE_API_KEY || process.env.GOOGLE_GENERATIVE_AI_API_KEY) {
chosenModelName = "gemini-2.0-flash-exp";
} else {
chosenModelName = "gpt-4o";
}
} else {
chosenModelName = "gpt-4o-mini";
}
console.log("Chat using model:", chosenModelName);
const model = getModel(chosenModelName);

Expand Down

0 comments on commit 42ae342

Please sign in to comment.