[PR #7935] [MERGED] Update the /api/create endpoint to use JSON #43811

Closed
opened 2026-04-24 23:23:42 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7935
Author: @pdevine
Created: 12/5/2024
Status: Merged
Merged: 1/1/2025
Merged by: @pdevine

Base: mainHead: pdevine/create-api


📝 Commits (10+)

📊 Changes

17 files changed (+1520 additions, -1091 deletions)

View changed files

📝 api/types.go (+14 -3)
📝 cmd/cmd.go (+36 -191)
📝 cmd/interactive.go (+12 -31)
📝 cmd/interactive_test.go (+0 -56)
parser/expandpath_test.go (+57 -0)
📝 parser/parser.go (+267 -4)
📝 parser/parser_test.go (+153 -0)
server/create.go (+667 -0)
📝 server/images.go (+1 -326)
📝 server/model.go (+0 -145)
📝 server/model_test.go (+0 -84)
📝 server/routes.go (+0 -72)
📝 server/routes_create_test.go (+166 -72)
📝 server/routes_delete_test.go (+6 -5)
📝 server/routes_generate_test.go (+77 -70)
📝 server/routes_list_test.go (+4 -3)
📝 server/routes_test.go (+60 -29)

📄 Description

This PR changes the way the POST /api/create endpoint works by changing the way the various options/parameters get serialized and passed to the server. Currently the create endpoint requires a Modelfile, which is a reasonable on-disk abstraction, but falls down for serializing things such as files and passing them to the server.

Also changed in this PR is that the client no longer has to zip each of the files before passing them to the server. This made repeated calls to the /api/create endpoint very inefficient when updating a template or other parameters because the weights would be zipped and pushed every time /api/create is called.

I've kept the POST /api/blobs/:digest endpoint the same here which instead of being used to pass the Zip file is instead used to pass each of the files individually. The hope is we can parallelize the process in a future PR in order to optimize it for speed.

For reviewing the code, I recommend starting in server/create.go which breaks out the endpoint.

NOTE: This is a pretty large change and not all of the unit tests have been fixed.


🔄 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/7935 **Author:** [@pdevine](https://github.com/pdevine) **Created:** 12/5/2024 **Status:** ✅ Merged **Merged:** 1/1/2025 **Merged by:** [@pdevine](https://github.com/pdevine) **Base:** `main` ← **Head:** `pdevine/create-api` --- ### 📝 Commits (10+) - [`52d49d5`](https://github.com/ollama/ollama/commit/52d49d5b5b6667e35d459a54a489e6a7339c8534) update the /api/create endpoint - [`481106c`](https://github.com/ollama/ollama/commit/481106c2ab76d8ce6542dcda63c09f2881c28a78) remove tempZipFiles() - [`d95852b`](https://github.com/ollama/ollama/commit/d95852b7a02085cda8e59ed268c9b13a9a6440c2) more unittest fixes - [`da6a915`](https://github.com/ollama/ollama/commit/da6a9151bb8992e9ac6be6ef04315921e75f3f7c) fix parameters and from "model" in the cli - [`6a5b592`](https://github.com/ollama/ollama/commit/6a5b592d3ad358553f671de0844d688c92732f46) fix unit tests - [`a9aec1b`](https://github.com/ollama/ollama/commit/a9aec1b3804dc6985618b5024e349e238db8f572) remove realpath - [`d56a929`](https://github.com/ollama/ollama/commit/d56a929dddc9b6b80195e4fe01c1ed8d24827aca) gofumpt the code - [`7ac810a`](https://github.com/ollama/ollama/commit/7ac810ae2fb53d50c751654002b107d56d61e042) don't fail when you can't remove a layer - [`7108e2e`](https://github.com/ollama/ollama/commit/7108e2e4aa639ad5e351ba3b71a29ade9fb8690f) more comments - [`2461b4f`](https://github.com/ollama/ollama/commit/2461b4f2954cc07d3a9084e21b0093768a2f90b0) change the FROM api semantics ### 📊 Changes **17 files changed** (+1520 additions, -1091 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+14 -3) 📝 `cmd/cmd.go` (+36 -191) 📝 `cmd/interactive.go` (+12 -31) 📝 `cmd/interactive_test.go` (+0 -56) ➕ `parser/expandpath_test.go` (+57 -0) 📝 `parser/parser.go` (+267 -4) 📝 `parser/parser_test.go` (+153 -0) ➕ `server/create.go` (+667 -0) 📝 `server/images.go` (+1 -326) 📝 `server/model.go` (+0 -145) 📝 `server/model_test.go` (+0 -84) 📝 `server/routes.go` (+0 -72) 📝 `server/routes_create_test.go` (+166 -72) 📝 `server/routes_delete_test.go` (+6 -5) 📝 `server/routes_generate_test.go` (+77 -70) 📝 `server/routes_list_test.go` (+4 -3) 📝 `server/routes_test.go` (+60 -29) </details> ### 📄 Description This PR changes the way the POST `/api/create` endpoint works by changing the way the various options/parameters get serialized and passed to the server. Currently the create endpoint requires a `Modelfile`, which is a reasonable on-disk abstraction, but falls down for serializing things such as files and passing them to the server. Also changed in this PR is that the client no longer has to `zip` each of the files before passing them to the server. This made repeated calls to the `/api/create` endpoint very inefficient when updating a template or other parameters because the weights would be zipped and pushed every time `/api/create` is called. I've kept the POST `/api/blobs/:digest` endpoint the same here which instead of being used to pass the Zip file is instead used to pass each of the files individually. The hope is we can parallelize the process in a future PR in order to optimize it for speed. For reviewing the code, I recommend starting in `server/create.go` which breaks out the endpoint. NOTE: This is a pretty large change and not all of the unit tests have been fixed. --- <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-24 23:23:43 -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#43811