summaryrefslogtreecommitdiff
path: root/frontend/src/api.js
diff options
context:
space:
mode:
authorkarpathy <andrej.karpathy@gmail.com>2025-11-22 14:27:53 -0800
committerkarpathy <andrej.karpathy@gmail.com>2025-11-22 14:27:53 -0800
commiteb0eb26f4cefa4880c895ff017f312e8674f9b73 (patch)
treeea20b736519a5b4149b0356fec93447eef950e6b /frontend/src/api.js
v0
Diffstat (limited to 'frontend/src/api.js')
-rw-r--r--frontend/src/api.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/frontend/src/api.js b/frontend/src/api.js
new file mode 100644
index 0000000..479f0ef
--- /dev/null
+++ b/frontend/src/api.js
@@ -0,0 +1,68 @@
+/**
+ * API client for the LLM Council backend.
+ */
+
+const API_BASE = 'http://localhost:8001';
+
+export const api = {
+ /**
+ * List all conversations.
+ */
+ async listConversations() {
+ const response = await fetch(`${API_BASE}/api/conversations`);
+ if (!response.ok) {
+ throw new Error('Failed to list conversations');
+ }
+ return response.json();
+ },
+
+ /**
+ * Create a new conversation.
+ */
+ async createConversation() {
+ const response = await fetch(`${API_BASE}/api/conversations`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({}),
+ });
+ if (!response.ok) {
+ throw new Error('Failed to create conversation');
+ }
+ return response.json();
+ },
+
+ /**
+ * Get a specific conversation.
+ */
+ async getConversation(conversationId) {
+ const response = await fetch(
+ `${API_BASE}/api/conversations/${conversationId}`
+ );
+ if (!response.ok) {
+ throw new Error('Failed to get conversation');
+ }
+ return response.json();
+ },
+
+ /**
+ * Send a message in a conversation.
+ */
+ async sendMessage(conversationId, content) {
+ const response = await fetch(
+ `${API_BASE}/api/conversations/${conversationId}/message`,
+ {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ content }),
+ }
+ );
+ if (!response.ok) {
+ throw new Error('Failed to send message');
+ }
+ return response.json();
+ },
+};