first commit
This commit is contained in:
30
src/routes/ollama.ts
Executable file
30
src/routes/ollama.ts
Executable file
@@ -0,0 +1,30 @@
|
||||
import { FastifyInstance, FastifyPluginAsync } from 'fastify';
|
||||
import { forwardChatRequest } from '../proxy/forward';
|
||||
import { logger } from '../utils/logger';
|
||||
|
||||
const ollamaRoutes: FastifyPluginAsync = async (server: FastifyInstance) => {
|
||||
server.post('/api/chat', async (request, reply) => {
|
||||
try {
|
||||
const body = request.body as any;
|
||||
|
||||
// Currently only supporting non-streaming requests in this proxy MVP
|
||||
if (body?.stream === true) {
|
||||
// As per requirements: return clear error or pass through without rewriting
|
||||
// We'll return a clear error for now, because stream parsing is out of scope for MVP
|
||||
reply.status(400).send({
|
||||
error: "Streaming is not supported by this proxy MVP. Please set stream=false."
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await forwardChatRequest(body);
|
||||
|
||||
reply.status(200).send(response);
|
||||
} catch (error: any) {
|
||||
logger.error('Error handling /api/chat:', error.message);
|
||||
reply.status(500).send({ error: error.message });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default ollamaRoutes;
|
||||
Reference in New Issue
Block a user