Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wenbinf committed Jun 14, 2023
1 parent b70d0d3 commit 1a4f230
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 80 deletions.
12 changes: 4 additions & 8 deletions edge-src/common/ListenApiManager.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import ResponseBuilder from "./ResponseBuilder";

const { ClientForWorkers } = require('podcast-api');

export default class ListenApiManager {
Expand All @@ -6,18 +8,12 @@ export default class ListenApiManager {
this.client = ClientForWorkers({
apiKey: env.LISTEN_API_KEY || null,
})
}

_getResponse(resultJson) {
return new Response(JSON.stringify(resultJson), {
headers: {
'content-type': 'application/json;charset=UTF-8',
},
})
this.responseBuilder = new ResponseBuilder(context)
}

async justListen(transformResultFunc) {
const res = await this.client.justListen()
return this._getResponse(transformResultFunc(res.data))
return this.responseBuilder.getJsonResponse(transformResultFunc(res.data))
}
}
12 changes: 12 additions & 0 deletions edge-src/common/ResponseBuilder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default class ResponseBuilder {
constructor() {
}

getJsonResponse(resultJson) {
return new Response(JSON.stringify(resultJson), {
headers: {
'content-type': 'application/json;charset=UTF-8',
},
})
}
}
29 changes: 29 additions & 0 deletions functions/.well-known/ai-plugin.json/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import ResponseBuilder from "../../../edge-src/common/ResponseBuilder";

const pluginSpec = {
"schema_version": "v1",
"name_for_human": "Listen Notes",
"name_for_model": "PodcastDatabase",
"description_for_human": "The best podcast search engine and database. Search 160+ million podcast episodes by topic or people",
"description_for_model": "Plugin for searching podcasts and episodes. Always use listennotes_url from the response data for the link of a podcast or an episode. Don't make up your own link.",
"auth": {
"type": "service_http",
"authorization_type": "bearer",
"verification_tokens": {
"openai": "2af42ffda4fa46718bbcb21562234c38"
}
},
"api": {
"type": "openapi",
"url": "https://ai.listennotes.com/chatgpt-plugin/openapi.json"
},
"logo_url": "https://ai.listennotes.com/assets/android-chrome-512x512.png",
"contact_email": "hello@listennotes.com",
"legal_info_url": "https://ai.listennotes.com/legal.txt"
}

export async function onRequestGet(context) {
const responseBuilder = new ResponseBuilder(context)

return responseBuilder.getJsonResponse(pluginSpec)
}
11 changes: 11 additions & 0 deletions functions/chatgpt-plugin/openapi.json/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import ResponseBuilder from "../../../edge-src/common/ResponseBuilder";

const openapiSpec = {
info: 'hello'
}

export async function onRequestGet(context) {
const responseBuilder = new ResponseBuilder(context)

return responseBuilder.getJsonResponse(openapiSpec)
}
21 changes: 0 additions & 21 deletions public/.well-known/ai-plugin.json

This file was deleted.

51 changes: 0 additions & 51 deletions public/chatgpt-plugin/openapi.yaml

This file was deleted.

0 comments on commit 1a4f230

Please sign in to comment.