[PR #12075] rfc: refactor nullable types with types.Null[T] #13702

Open
opened 2026-04-13 00:33:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/12075
Author: @mxyng
Created: 8/25/2025
Status: 🔄 Open

Base: mainHead: mxyng/types-null


📝 Commits (3)

📊 Changes

11 files changed (+190 additions, -94 deletions)

View changed files

📝 api/types.go (+17 -16)
📝 openai/openai.go (+3 -2)
📝 server/create.go (+1 -1)
📝 server/routes.go (+5 -10)
📝 server/routes_create_test.go (+19 -21)
📝 server/routes_debug_test.go (+5 -6)
📝 server/routes_generate_test.go (+18 -21)
📝 server/routes_harmony_streaming_test.go (+6 -12)
📝 server/routes_test.go (+10 -5)
types/null.go (+53 -0)
types/null_test.go (+53 -0)

📄 Description

there's a common pattern where request fields may need to differentiate between an unset value and a value set to the type's zero value. this is commonly used to apply a different default value, e.g. stream, or to omit a field entirely, e.g. think.

similar to sql.Null[T], types.Null[T] simplifies this by providing utilities to quickly and easily apply this pattern to any type using generics.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/12075 **Author:** [@mxyng](https://github.com/mxyng) **Created:** 8/25/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `mxyng/types-null` --- ### 📝 Commits (3) - [`e914477`](https://github.com/ollama/ollama/commit/e914477bb67f195121b18cbd8c73f2f15dea7294) types: add types.Null[T] - [`c457628`](https://github.com/ollama/ollama/commit/c457628090267f59eadfb2349f1353d0391f9f4b) null stream - [`d05fc26`](https://github.com/ollama/ollama/commit/d05fc2657048655323b56219b00881db3e458938) null truncate ### 📊 Changes **11 files changed** (+190 additions, -94 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+17 -16) 📝 `openai/openai.go` (+3 -2) 📝 `server/create.go` (+1 -1) 📝 `server/routes.go` (+5 -10) 📝 `server/routes_create_test.go` (+19 -21) 📝 `server/routes_debug_test.go` (+5 -6) 📝 `server/routes_generate_test.go` (+18 -21) 📝 `server/routes_harmony_streaming_test.go` (+6 -12) 📝 `server/routes_test.go` (+10 -5) ➕ `types/null.go` (+53 -0) ➕ `types/null_test.go` (+53 -0) </details> ### 📄 Description there's a common pattern where request fields may need to differentiate between an unset value and a value set to the type's zero value. this is commonly used to apply a different default value, e.g. stream, or to omit a field entirely, e.g. think. similar to sql.Null[T], types.Null[T] simplifies this by providing utilities to quickly and easily apply this pattern to any type using generics. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 00:33:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#13702