Skip to content

Commit 682ec05

Browse files
fix: Chat API format - messages array for Claude conversation
- Updated ChatRequest to use messages[] array format - ChatInterface now sends conversation history for context - Response uses message.content from Claude API - Removed unused conversationId state Chat now works with Claude Opus 4.5! Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 93b3766 commit 682ec05

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

chat_ui/frontend/src/components/Chat/ChatInterface.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default function ChatInterface({ initialMessage, onClear }: ChatInterface
3939
const [messages, setMessages] = useState<ChatMessage[]>([]);
4040
const [input, setInput] = useState('');
4141
const [isLoading, setIsLoading] = useState(false);
42-
const [conversationId, setConversationId] = useState(() => `chat_${Date.now()}`);
4342
const messagesEndRef = useRef<HTMLDivElement>(null);
4443
const inputRef = useRef<HTMLInputElement>(null);
4544

@@ -84,19 +83,20 @@ export default function ChatInterface({ initialMessage, onClear }: ChatInterface
8483
setIsLoading(true);
8584

8685
try {
87-
const response = await sendChatMessage(text, conversationId);
86+
// Build conversation history for context
87+
const history = messages.map(m => ({
88+
role: m.role as 'user' | 'assistant',
89+
content: m.content,
90+
}));
8891

89-
// Update conversation ID if new
90-
if (response.conversationId) {
91-
setConversationId(response.conversationId);
92-
}
92+
const response = await sendChatMessage(text, history);
9393

94-
// Add assistant message
94+
// Add assistant message from Claude
9595
const assistantMessage: ChatMessage = {
9696
id: generateId(),
9797
role: 'assistant',
98-
content: response.response,
99-
timestamp: response.timestamp,
98+
content: response.message?.content || 'No response received',
99+
timestamp: new Date().toISOString(),
100100
};
101101
setMessages((prev) => [...prev, assistantMessage]);
102102
} catch (error) {
@@ -117,7 +117,6 @@ export default function ChatInterface({ initialMessage, onClear }: ChatInterface
117117

118118
const handleClear = () => {
119119
setMessages([]);
120-
setConversationId(`chat_${Date.now()}`);
121120
onClear?.();
122121
inputRef.current?.focus();
123122
};

chat_ui/frontend/src/types/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,21 @@ export interface ChatMessage {
3030
}
3131

3232
export interface ChatRequest {
33-
message: string;
34-
conversationId?: string;
33+
messages: { role: 'user' | 'assistant'; content: string }[];
34+
model?: 'claude-opus-4.5' | 'claude-sonnet-4.5' | 'claude-haiku-4.5';
35+
sessionId?: string;
3536
}
3637

3738
export interface ChatResponse {
38-
response: string;
39-
conversationId: string;
40-
timestamp: string;
39+
message: {
40+
role: 'assistant';
41+
content: string;
42+
};
43+
usage?: {
44+
input_tokens: number;
45+
output_tokens: number;
46+
};
47+
model?: string;
4148
}
4249

4350
// Work Order Types

0 commit comments

Comments
 (0)