Skip to content

Commit e55b798

Browse files
sainthiagoGAllen98
andauthored
Add history api to make-agent chat component (#67)
Co-authored-by: Guilherme Allen <[email protected]>
1 parent 5d25b01 commit e55b798

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/commands/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function findAvailablePort(startPort: number): Promise<number> {
3737

3838
const API_CONFIG: ApiConfig = {
3939
key: process.env.BITTE_API_KEY!,
40-
url: process.env.BITTE_API_URL || "https://wallet.bitte.ai/api/v1/chat",
40+
url: process.env.BITTE_API_URL || "https://wallet.bitte.ai/api/v1",
4141
serverPort: DEFAULT_PORT,
4242
};
4343

src/playground/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ const Main: React.FC = (): JSX.Element => {
7676
},
7777
}}
7878
apiUrl={config.bitteApiUrl}
79+
historyApiUrl="/api/history"
7980
apiKey={config.bitteApiKey}
8081
colors={{
8182
generalBackground: "#18181A",

src/services/server.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,34 @@ export async function startUIServer(
7979
spec: agentSpec,
8080
},
8181
bitteApiKey: apiConfig.key,
82-
bitteApiUrl: apiConfig.url,
82+
bitteApiUrl: `${apiConfig.url}/chat`,
8383
};
8484
res.json(serverConfig);
8585
} catch (error) {
8686
res.status(500).json({ error: "Failed to fetch AI plugin spec" });
8787
}
8888
});
8989

90+
app.get("/api/history", async (req, res) => {
91+
try {
92+
const id = req.query.id;
93+
if (!id) {
94+
throw new Error("No history id on request.");
95+
}
96+
const url = `${apiConfig.url}/history?id=${id}`;
97+
98+
const response = await fetch(url, {
99+
headers: {
100+
Authorization: `Bearer ${apiConfig.key}`,
101+
},
102+
});
103+
const result = await response.json();
104+
res.json(result);
105+
} catch (err) {
106+
res.status(500).json({ error: `Failed to fetch chat history: ${err}` });
107+
}
108+
});
109+
90110
// Serve index.html for all routes
91111
app.get("*", async (req, res) => {
92112
console.log(req.path);

0 commit comments

Comments
 (0)