Last active
July 23, 2023 07:40
-
-
Save tarasglek/4bb9010e2a3585c852900df489688c0b to your computer and use it in GitHub Desktop.
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
/** | |
* Example Function Module. Each function needs you to define 4 things: | |
*/ | |
/* 1. Name of your function (must be unique) */ | |
export const name = "runClickhouseQuery"; | |
/* 2. Description of function, used to describe what it does to an LLM */ | |
export const description = "This function executes clickhouse queries"; | |
/** | |
* 3. A JSON Schema defining the function's parameters. See: | |
* | |
* - https://platform.openai.com/docs/guides/gpt/function-calling | |
* - https://json-schema.org/learn/getting-started-step-by-step | |
*/ | |
export const parameters = { | |
type: "object", | |
properties: { | |
value: { | |
type: "string", | |
description: "Valid clickhouse sql", | |
}, | |
}, | |
required: ["value"], | |
}; | |
/** | |
* 4. The function itself. Accepts an Object matching the schema | |
* defined in params, returning a Promise<string> (i.e., should be | |
* an async function). | |
*/ | |
export default async function (value) { | |
console.log(value) | |
return fetch("https://play.clickhouse.com/?user=play", { | |
method: "POST", | |
body: `${value.value} FORMAT Markdown`, | |
}).then(x=>x.text()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment