Skip to content
Merged
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
11 changes: 9 additions & 2 deletions apps/desktop/src/components/right-panel/hooks/useChatLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { commands as miscCommands } from "@hypr/plugin-misc";
import { commands as templateCommands } from "@hypr/plugin-template";
import { modelProvider, streamText, tool } from "@hypr/utils/ai";
import { useSessions } from "@hypr/utils/contexts";
import { useQueryClient } from "@tanstack/react-query";
import { z } from "zod";

import type { ActiveEntityInfo, Message } from "../types/chat-types";
Expand Down Expand Up @@ -48,6 +49,7 @@ export function useChatLogic({
const [isGenerating, setIsGenerating] = useState(false);
const sessions = useSessions((state) => state.sessions);
const { getLicense } = useLicense();
const queryClient = useQueryClient();

const handleApplyMarkdown = async (markdownContent: string) => {
if (!sessionId) {
Expand Down Expand Up @@ -300,15 +302,20 @@ export function useChatLogic({
};
setMessages((prev) => [...prev, aiMessage]);

await queryClient.invalidateQueries({ queryKey: ["llm-connection"] });
await new Promise(resolve => setTimeout(resolve, 100));

const { type } = await connectorCommands.getLlmConnection();

const { textStream } = streamText({
model,
messages: await prepareMessageHistory(messages, content, mentionedContent),
// Add tools conditionally for local LLM (same as enhance)
...(llmConnectionQuery.data?.type === "HyprLocal" && {
...(type === "HyprLocal" && {
tools: {
update_progress: tool({ inputSchema: z.any() }),
},
}),

onError: (error) => {
console.error("On Error Catch:", error);
setIsGenerating(false);
Expand Down
Loading