-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refector functions to a provider that can inject the functions supported
- Loading branch information
1 parent
1778c72
commit d9c4f87
Showing
4 changed files
with
115 additions
and
59 deletions.
There are no files selected for viewing
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,70 @@ | ||
const downloadHtmlToMarkdown = require('./downloadHtmlToMarkdown'); | ||
const searchGoogle = require('./searchGoogle'); | ||
|
||
//async function functionProvider() { | ||
// return { | ||
const functionProvider = { | ||
getFunctionDefinition: async () => { | ||
return [ | ||
{ | ||
type: "function", | ||
function: { | ||
name: "downloadHtmlToMarkdown", | ||
description: "Download the contents of a web page URL", | ||
parameters: { | ||
type: "object", | ||
properties: { | ||
url: { | ||
type: "string", | ||
description: "The web page URL of the page to download, e.g. https://build5nines.com/category/page" | ||
} | ||
} | ||
}, | ||
required: ["url"] | ||
} | ||
}, | ||
{ | ||
type: "function", | ||
function: { | ||
name: "searchGoogle", | ||
description: "Search Google for information", | ||
parameters: { | ||
type: "object", | ||
properties: { | ||
query: { | ||
type: "string", | ||
description: "The search query to use, e.g. Azure Functions" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
]; | ||
}, | ||
executeFunction: async (functionName, arguments) => { | ||
let functionResult = null; | ||
|
||
switch (functionName) { | ||
case "downloadHtmlToMarkdown": | ||
const { url } = JSON.parse(arguments); | ||
|
||
// Call the downloadHtmlToMarkdown function and get the result | ||
functionResult = await downloadHtmlToMarkdown(url); | ||
break; | ||
|
||
case "searchGoogle": | ||
const { query } = JSON.parse(arguments); | ||
|
||
// Call the searchGoogle function and get the result | ||
functionResult = await searchGoogle(query); | ||
break; | ||
|
||
default: | ||
console.error("Unsupported Function Call:", functionName); | ||
} | ||
|
||
return functionResult; | ||
} | ||
}; | ||
|
||
module.exports = functionProvider; |
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