Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion genkit/.idx/dev.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# see: https://developers.google.com/idx/guides/customize-idx-env
{ pkgs, ... }: {
# Which nixpkgs channel to use.
channel = "stable-24.05"; # or "unstable"
channel = "stable-25.05"; # or "unstable"
# Use https://search.nixos.org/packages to find packages
packages = [
pkgs.nodejs_20
Expand All @@ -13,6 +13,7 @@
env = {
#TODO Get a API key from https://g.co/ai/idxGetGeminiKey
GOOGLE_GENAI_API_KEY = "TODO";
CLOUDSDK_CORE_DISABLE_PROMPTS = "1";
};
idx = {
# Search for the extensions you want on https://open-vsx.org/ and use "publisher.id"
Expand All @@ -34,5 +35,14 @@
run-server = "npm run dev";
};
};
previews = {
enable = true;
previews = {
web = {
command = ["sh" "-c" "GENKIT_ENV=dev genkit start --port $PORT -- npx tsx --watch index.ts"];
manager = "web";
};
};
};
};
}
8 changes: 5 additions & 3 deletions genkit/idx-template.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ idx-template \
cp -f ${./package.json} "$out/package.json"
cp -f ${./package-lock.json} "$out/package-lock.json"
cp -f ${./index.ts} "$out/index.ts"
cp -f ${./schema.ts} "$out/schema.ts"
cp -f ${./tools.ts} "$out/tools.ts"
cp -f ${./.gitignore} "$out/.gitignore"
cp ${./README.md} "$out"/README.md
${if language == "go" then "env -C \"$out\" go mod init genkit" else "" }

chmod -R u+w "$out"
cp ${./.idx/airules.md} "$out/.idx/airules.md"
cp ${./.idx/airules.md} "$out/GEMINI.md"
chmod -R u+w "$out"

'';
}
}
15 changes: 1 addition & 14 deletions genkit/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { genkit } from 'genkit/beta';
import { googleAI, gemini20Flash } from '@genkit-ai/googleai';
import { createInterface } from "node:readline/promises";
import { createWeatherTool, createHackerNewsTool, createHackerNewsSummaryTool } from './tools'

export const ai = genkit({
Expand All @@ -18,20 +17,8 @@ const hackerNewsSummaryTool = createHackerNewsSummaryTool({

// New! Genkit gives you persistent chat sessions.
// You can still call ai.definePrompt() to create an executable prompt
const chat = ai.chat({
export const chat = ai.chat({
model: gemini20Flash,
system: `You are a helpful assistant. If the user asks you what you can do, respond with your tools and creative uses.`,
tools: [weatherTool, hackerNewsSummaryTool],
});

async function main() {
console.log("You're chatting with Gemini. Ctrl-C to quit.\n");
const readline = createInterface(process.stdin, process.stdout);
while (true) {
const userInput = await readline.question("> ");
const result = await chat.send(userInput)
console.log(result.text);
}
}

main();
Loading