diff --git a/src/commands/dev.ts b/src/commands/dev.ts index a671882..94bf7c8 100644 --- a/src/commands/dev.ts +++ b/src/commands/dev.ts @@ -37,7 +37,7 @@ async function findAvailablePort(startPort: number): Promise { const API_CONFIG: ApiConfig = { key: process.env.BITTE_API_KEY!, - url: process.env.BITTE_API_URL || "https://wallet.bitte.ai/api/v1/chat", + url: process.env.BITTE_API_URL || "https://wallet.bitte.ai/api/v1", serverPort: DEFAULT_PORT, }; diff --git a/src/playground/src/App.tsx b/src/playground/src/App.tsx index ab110e2..366806b 100644 --- a/src/playground/src/App.tsx +++ b/src/playground/src/App.tsx @@ -76,6 +76,7 @@ const Main: React.FC = (): JSX.Element => { }, }} apiUrl={config.bitteApiUrl} + historyApiUrl="/api/history" apiKey={config.bitteApiKey} colors={{ generalBackground: "#18181A", diff --git a/src/services/server.ts b/src/services/server.ts index 244a079..206ba26 100644 --- a/src/services/server.ts +++ b/src/services/server.ts @@ -79,7 +79,7 @@ export async function startUIServer( spec: agentSpec, }, bitteApiKey: apiConfig.key, - bitteApiUrl: apiConfig.url, + bitteApiUrl: `${apiConfig.url}/chat`, }; res.json(serverConfig); } catch (error) { @@ -87,6 +87,26 @@ export async function startUIServer( } }); + app.get("/api/history", async (req, res) => { + try { + const id = req.query.id; + if (!id) { + throw new Error("No history id on request."); + } + const url = `${apiConfig.url}/history?id=${id}`; + + const response = await fetch(url, { + headers: { + Authorization: `Bearer ${apiConfig.key}`, + }, + }); + const result = await response.json(); + res.json(result); + } catch (err) { + res.status(500).json({ error: `Failed to fetch chat history: ${err}` }); + } + }); + // Serve index.html for all routes app.get("*", async (req, res) => { console.log(req.path);