A simple Bluesky bot to make sense of the noise, with responses powered by Gemini, similar to Grok.
1import type { FunctionCall } from "@google/genai";
2import * as search_posts from "./search_posts";
3import type { infer as z_infer } from "zod";
4
5const validation_mappings = {
6 "search_posts": search_posts.validator,
7} as const;
8
9export const declarations = [
10 { urlContext: {} },
11 { googleSearch: {} },
12 /*
13 {
14 functionDeclarations: [
15 search_posts.definition,
16 ],
17 },
18 */
19];
20
21type ToolName = keyof typeof validation_mappings;
22export async function handler(call: FunctionCall & { name: ToolName }) {
23 const parsedArgs = validation_mappings[call.name].parse(call.args);
24
25 switch (call.name) {
26 case "search_posts":
27 return await search_posts.handler(
28 parsedArgs as z_infer<typeof search_posts.validator>,
29 );
30 }
31}