Skip to content

Instantly share code, notes, and snippets.

@tarasglek
Last active July 23, 2023 07:40
Show Gist options
  • Save tarasglek/4bb9010e2a3585c852900df489688c0b to your computer and use it in GitHub Desktop.
Save tarasglek/4bb9010e2a3585c852900df489688c0b to your computer and use it in GitHub Desktop.
/**
* 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