-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from CapgeminiInventUK/feat/feedback
feat/feedback
- Loading branch information
Showing
25 changed files
with
215 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export interface CreateFeedback { | ||
id: string; | ||
run_id: string; | ||
key: string; | ||
score?: number | boolean; | ||
value?: string; | ||
comment?: string; | ||
|
||
[key: string]: unknown; | ||
} | ||
|
||
export interface UpdateFeedback { | ||
score?: number | boolean; | ||
value?: string; | ||
correction?: { [key: string]: unknown }; | ||
comment?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Router, Request as ExpressRequest, Response as ExpressResponse } from 'express'; | ||
import { LangchainToLangtraceService } from '../../services/langchain_to_langtrace_service'; | ||
import { CreateFeedback, UpdateFeedback } from '../../models/requests/feedback_request'; | ||
|
||
export const langchainFeedbackRouter = Router(); | ||
const langchainService = new LangchainToLangtraceService(); | ||
|
||
langchainFeedbackRouter.post('/', async (req: ExpressRequest, res: ExpressResponse) => { | ||
console.debug('POST /api/feedback'); | ||
try { | ||
const runData = req.body as CreateFeedback; | ||
await langchainService.createFeedback(runData); | ||
|
||
console.debug(`Created feedback with id ${runData.id} in run ${runData.run_id}`); | ||
|
||
res.status(201).json( | ||
{ feedback_id: runData.id } | ||
); | ||
} catch (error: unknown) { | ||
console.error(error); | ||
if (error instanceof Error) { | ||
return res.status(400).json({ message: error.message }); | ||
} else { | ||
return res.status(400).json({ message: 'Unknown error' }); | ||
} | ||
} | ||
}); | ||
|
||
langchainFeedbackRouter.patch('/:feedbackId', async (req: ExpressRequest, res: ExpressResponse) => { | ||
console.debug('PATCH /api/feedback/:feedbackId'); | ||
const feedbackId = req.params.feedbackId; | ||
const updateData = req.body as UpdateFeedback; | ||
|
||
const success = await langchainService.updateFeedback(feedbackId, updateData); | ||
if (!success) { | ||
return res.status(404).json({ message: 'Feedback not found or update failed' }); | ||
} | ||
return res.status(204).send(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.