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: 1 addition & 1 deletion src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function findAvailablePort(startPort: number): Promise<number> {

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,
};

Expand Down
1 change: 1 addition & 0 deletions src/playground/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const Main: React.FC = (): JSX.Element => {
},
}}
apiUrl={config.bitteApiUrl}
historyApiUrl="/api/history"
apiKey={config.bitteApiKey}
colors={{
generalBackground: "#18181A",
Expand Down
22 changes: 21 additions & 1 deletion src/services/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,34 @@ export async function startUIServer(
spec: agentSpec,
},
bitteApiKey: apiConfig.key,
bitteApiUrl: apiConfig.url,
bitteApiUrl: `${apiConfig.url}/chat`,
};
res.json(serverConfig);
} catch (error) {
res.status(500).json({ error: "Failed to fetch AI plugin spec" });
}
});

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);
Expand Down