Skip to content

Instantly share code, notes, and snippets.

View peterfriese's full-sized avatar
🔥

Peter Friese peterfriese

🔥
View GitHub Profile
@peterfriese
peterfriese / Publisher+handleEvents.swift
Last active March 23, 2022 16:26
Make it easier to perform side effects (such as toggling a progress view) in a Combine pipeline. See this Twitter conversation for context: https://twitter.com/DonnyWals/status/1506330967941820423
extension Publisher {
/// Performs the specified closures when publisher events occur.
///
/// This is an overloaded version of ``Publisher/handleEvents(receiveSubscription:receiveOutput:receiveCompletion:receiveCancel:receiveRequest:)``
/// that only accepts a closure for the `receiveOutput` events. Use it to inspect events as they pass through the pipeline.
///
/// - Parameters:
/// - receiveOutput: A closure that executes when the publisher receives a value from the upstream publisher.
/// - Returns: A publisher that performs the specified closures when publisher events occur.
import {defineTool, generate} from '@genkit-ai/ai';
import {configureGenkit} from '@genkit-ai/core';
import {gemini15ProPreview} from '@genkit-ai/vertexai';
import * as z from 'zod';
import {vertexAI} from '@genkit-ai/vertexai';
configureGenkit({
plugins: [
vertexAI({location: 'us-central1'}),
],
@peterfriese
peterfriese / index.ts
Last active November 26, 2024 20:56
Talk to a PDF with Genkit
import {gemini15Flash, googleAI} from '@genkit-ai/googleai';
import {genkit, z} from 'genkit';
import {createInterface} from "node:readline/promises";
import pdf from "pdf-parse";
const ai = genkit({
plugins: [googleAI()],
model: gemini15Flash,
});