feat(ms22-p2): add agent selector UI in WebUI (#685)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
Co-authored-by: Jason Woltje <jason@diversecanvas.com> Co-committed-by: Jason Woltje <jason@diversecanvas.com>
This commit was merged in pull request #685.
This commit is contained in:
@@ -27,6 +27,7 @@ export interface UseChatOptions {
|
||||
maxTokens?: number;
|
||||
systemPrompt?: string;
|
||||
projectId?: string | null;
|
||||
agent?: string;
|
||||
onError?: (error: Error) => void;
|
||||
}
|
||||
|
||||
@@ -63,6 +64,7 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
||||
maxTokens,
|
||||
systemPrompt,
|
||||
projectId,
|
||||
agent,
|
||||
onError,
|
||||
} = options;
|
||||
|
||||
@@ -77,6 +79,10 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
||||
const projectIdRef = useRef<string | null>(projectId ?? null);
|
||||
projectIdRef.current = projectId ?? null;
|
||||
|
||||
// Track agent in ref to prevent stale closures
|
||||
const agentRef = useRef<string | undefined>(agent);
|
||||
agentRef.current = agent;
|
||||
|
||||
// Track messages in ref to prevent stale closures during rapid sends
|
||||
const messagesRef = useRef<Message[]>(messages);
|
||||
messagesRef.current = messages;
|
||||
@@ -209,6 +215,7 @@ export function useChat(options: UseChatOptions = {}): UseChatReturn {
|
||||
...(temperature !== undefined && { temperature }),
|
||||
...(maxTokens !== undefined && { maxTokens }),
|
||||
...(systemPrompt !== undefined && { systemPrompt }),
|
||||
...(agentRef.current && { agent: agentRef.current }),
|
||||
};
|
||||
|
||||
const controller = new AbortController();
|
||||
|
||||
Reference in New Issue
Block a user