Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions amplify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ frontend:
- npm ci
build:
commands:
- nvm use 20
- cd frontend/chat-ui
- npm run build
- BACKEND_URL=$BACKEND_URL node ../federationStatusCLI.js
artifacts:
Expand Down
9 changes: 2 additions & 7 deletions frontend/chat-ui/src/components/ChatWindow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import React, { useEffect, useRef } from 'react';
import { useStore } from '../store';
import MessageBubble from './MessageBubble.jsx';
import { API_BASE_URL } from '../api';
import { stream } from '../api';

export default function ChatWindow() {
const { state, dispatch } = useStore();
Expand All @@ -23,12 +23,7 @@ export default function ChatWindow() {

useEffect(() => {
if (!state.currentConversation) return;
const url = new URL(`${API_BASE_URL}/stream/${state.currentConversation.id}`);
const apiKey = import.meta.env.VITE_API_KEY;
if (apiKey) {
url.searchParams.set('api_key', apiKey);
}
const events = new EventSource(url.toString());
const events = stream(`/stream/${state.currentConversation.id}`);

const handleToken = (e) => {
try {
Expand Down
4 changes: 3 additions & 1 deletion frontend/chat-ui/src/components/InputBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export default function InputBox() {
if (!state.currentConversation || (!text && !file) || pending) return;
setPending(true);
try {
const id = crypto.randomUUID ? crypto.randomUUID() : Date.now().toString();
const payload = {
id,
from: 'user',
to: 'assistant',
content: text,
Expand All @@ -29,7 +31,7 @@ export default function InputBox() {
};
}
await post(`/messages/${state.currentConversation.id}`, payload);
dispatch({ type: 'ADD_MESSAGE', message: { id: Date.now().toString(), ...payload } });
dispatch({ type: 'ADD_MESSAGE', message: payload });
setText('');
setFile(null);
setFileData('');
Expand Down