From 51cb61f60a35cb83daf7ce842de8a3bb30e359a3 Mon Sep 17 00:00:00 2001 From: vinodkiran Date: Fri, 1 Dec 2023 10:30:56 +0530 Subject: [PATCH] LS Prompt hub: adding credentials to the filtering logic --- packages/server/src/index.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/server/src/index.ts b/packages/server/src/index.ts index 92b32b59..35139bf0 100644 --- a/packages/server/src/index.ts +++ b/packages/server/src/index.ts @@ -1121,9 +1121,21 @@ export class App { this.app.post('/api/v1/prompts-list', async (req: Request, res: Response) => { try { + const credential = await this.AppDataSource.getRepository(Credential).findOneBy({ + id: req.body.credential + }) + + if (!credential) return res.status(404).json({ error: `Credential ${req.body.credential} not found` }) + // Decrypt credentialData + const decryptedCredentialData = await decryptCredentialData(credential.encryptedData, credential.credentialName, undefined) + + const headers = {} + // @ts-ignore + headers['x-api-key'] = decryptedCredentialData.langsmithApiKey + const tags = req.body.tags ? `tags=${req.body.tags}` : '' const url = `https://web.hub.langchain.com/repos/?${tags}offset=0&limit=20&has_commits=true&sort_field=num_likes&sort_direction=desc&is_archived=false` - axios.get(url).then((response) => { + axios.get(url, headers).then((response) => { if (response.data.repos) { return res.json({ status: 'OK', repos: response.data.repos }) }