Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS - first api hookups. #564

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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
50 changes: 50 additions & 0 deletions packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,56 @@ export class DirectClient {
res.json({ images: imagesRes });
}
);

this.app.post(
"/fine-tune",
async (req: express.Request, res: express.Response) => {
try {
const response = await fetch('https://api.bageldb.ai/api/v1/asset', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': `${process.env.BAGEL_API_KEY}`
},
body: JSON.stringify(req.body)
});

const data = await response.json();
res.json(data);
} catch (error) {
res.status(500).json({
error: 'Failed to forward request to BagelDB',
details: error.message
});
}
}
);
this.app.get(
"/fine-tune/:assetId",
async (req: express.Request, res: express.Response) => {
const assetId = req.params.assetId;
try {
const response = await fetch(`https://api.bageldb.ai/api/v1/asset/${assetId}/download`, {
headers: {
'X-API-KEY': `${process.env.BAGEL_API_KEY}`
}
});

// Forward the content-type header
res.set('Content-Type', response.headers.get('content-type'));

// Convert ReadableStream to Buffer and send
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
res.send(buffer);
} catch (error) {
res.status(500).json({
error: 'Failed to forward request to BagelDB',
details: error.message
});
}
}
);
}

public registerAgent(runtime: AgentRuntime) {
Expand Down
Loading