A Temporal workflow application that creates a human-in-the-loop interaction to generate fun facts about user-provided words using Google's Genkit framework for AI integration.
- Interactive CLI workflow that prompts users for input
- Generates fun facts using Ollama and Gemma3:1b model
- Loops until user types "exit"
- Uses Temporal for workflow orchestration
- Structured logging with slog
- Leverages Genkit's advanced AI capabilities:
- Type-safe AI flows with Go structs and JSON schema validation
- Unified model interface supporting Google AI, Vertex AI, OpenAI, Ollama, and more
- Tool calling, RAG, and multimodal support
- Rich local development tools with a standalone CLI binary and Developer UI
- AI coding assistant integration
- Go 1.21 or later
- Temporal server running locally
- Ollama with Gemma3:1b model installed
-
Install Temporal CLI and start server:
# Install Temporal CLI curl -sSf https://temporal.download/cli.sh | sh # Start Temporal server temporal server start-dev
-
Install Ollama and model:
# Install Ollama curl -fsSL https://ollama.ai/install.sh | sh # Pull the Gemma3:1b model ollama pull gemma3:1b
-
Install Genkit CLI:
curl -sL cli.genkit.dev | bash -
Clone and setup the project:
git clone https://github.com/AlexSKuznetsov/temporal-genkit.git cd temp-genai go mod tidy
-
Ensure Temporal server is running in one terminal:
temporal server start-dev
-
In another terminal, start Ollama:
ollama serve
-
Run the application:
genkit start -- go run .
The application will start the workflow and begin prompting for user input.
-
Workflow Execution:
- The
FunFactWorkflowstarts and enters a loop - Executes
PromptActivityto display the prompt - Executes
ReadInputActivityto read user input - If input is "exit", workflow completes
- Otherwise, executes
GenAIActivityto generate a fun fact - Logs the fun fact and loops back
- The
-
Activities:
PromptActivity: Displays the user promptReadInputActivity: Reads input from stdinGenAIActivity: Uses Ollama to generate AI responses
-
Logging:
- Uses slog with info level to suppress debug logs
- Fun facts are logged at info level
.
├── main.go # Worker setup and main function
├── workflow.go # FunFactWorkflow definition
├── activity.go # Activity definitions
├── go.mod # Go module file
├── go.sum # Go dependencies
└── README.md # This file
- Temporal Task Queue:
fun-fact-tasks - Workflow ID:
fun-fact-workflow - Ollama Server:
http://127.0.0.1:11434 - Model:
gemma3:1b
$ go run .
Started workflow WorkflowID fun-fact-workflow RunID ...
Enter a word to discover a fun fact, or type 'exit' to quit: apple
INFO Fun fact: Did you know that the average apple contains about 5-10 seeds, and if you plant them, you might grow a tree that produces fruit different from the parent apple?
Enter a word to discover a fun fact, or type 'exit' to quit: ocean
INFO Fun fact: The ocean covers about 71% of Earth's surface and contains 97% of Earth's water.
Enter a word to discover a fun fact, or type 'exit' to quit: exit
Workflow completed
- Temporal UI - Monitor workflows and activities
- Genkit UI - View AI model interactions and debugging
- Temporal server not running: Ensure
temporal server start-devis executed - Ollama not running: Run
ollama servein a separate terminal - Model not found: Run
ollama pull gemma3:1b - Port conflicts: Ensure ports 7233 (Temporal) and 11434 (Ollama) are available
This project uses Genkit, Google's open-source framework for building AI-powered apps. Genkit provides a unified interface for integrating various AI models and services, making it easy to add AI capabilities to applications.
Key features used in this project:
- Model abstraction for easy switching between AI providers
- Plugin system for Ollama integration
- Structured prompts and response handling
For more information and documentation, visit Genkit for Go.
go.temporal.io/sdk: Temporal Go SDKgithub.com/firebase/genkit/go: Genkit for AI integrationgithub.com/firebase/genkit/go/plugins/ollama: Ollama plugin for Genkit