[GH-ISSUE #603] Considering graphql instead of classic http #62305

Closed
opened 2026-05-03 08:09:30 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @FairyTail2000 on GitHub (Sep 26, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/603

I won't explain here what graphql is.

How does this project benefit from graphql vs classical http?

With graphql you can get more info / less info per http call. Why is this relevant? Third party integration.

Example with my own frontend:

  • I want to get all models (1 call)
  • I want to inspect all models (x calls)
    I have right now 20 - 30 models and those I would make models + 1 call to the backend. Depending on the network conditions this would significantly impact loading time of the third party integration. Also I would always fetch all info, which isn't always wanted. Also I would always fetch "modified_at" for the all models, and for the model inspection I would always fetch "modelfile", "parameters" and "template". This increases the network payload size significantly

How does graphql help with this?
With graphql I can request a list of all models and related fields in a single field. Example:

query getAllModels {
 models {
  name
  size
  details {
    license
  }
 }
}

With this I can make a single http request and can get all the info I need and want.

Another plus is that there is a code generator available for many languages and framework.

For the ollama cli client this api doesn't make much sense.

This is a fundamental decision for the project and thus requires much thought before making a decision.

I'm looking forward to feedback on this

Originally created by @FairyTail2000 on GitHub (Sep 26, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/603 I won't explain here what [graphql](https://graphql.org) is. ## How does this project benefit from graphql vs classical http? With graphql you can get more info / less info per http call. Why is this relevant? Third party integration. Example with my own frontend: - I want to get all models (1 call) - I want to inspect all models (x calls) I have right now 20 - 30 models and those I would make models + 1 call to the backend. Depending on the network conditions this would significantly impact loading time of the third party integration. Also I would always fetch all info, which isn't always wanted. Also I would always fetch "modified_at" for the all models, and for the model inspection I would always fetch "modelfile", "parameters" and "template". This increases the network payload size significantly How does graphql help with this? With graphql I can request a list of all models and related fields in a single field. Example: ```graphql query getAllModels { models { name size details { license } } } ``` With this I can make a single http request and can get all the info I need and want. Another plus is that there is a code generator available for many languages and framework. For the ollama cli client this api doesn't make much sense. This is a fundamental decision for the project and thus requires much thought before making a decision. I'm looking forward to feedback on this
Author
Owner

@reustle commented on GitHub (Sep 30, 2023):

I think this is a cool idea, but it probably makes sense as a separate tool / library?

Simple HTTP / REST calls are very easy for nearly every tool to interface, and introducing GraphQL essentially requires you to start using an additional library to interface with it. Seeing that the data produced by the Ollama isn't very complex or diverse, just returning simple JSON seems to be more than sufficient.

Just my 0.02

<!-- gh-comment-id:1741670897 --> @reustle commented on GitHub (Sep 30, 2023): I think this is a cool idea, but it probably makes sense as a separate tool / library? Simple HTTP / REST calls are very easy for nearly every tool to interface, and introducing GraphQL essentially requires you to start using an additional library to interface with it. Seeing that the data produced by the Ollama isn't very complex or diverse, just returning simple JSON seems to be more than sufficient. Just my 0.02
Author
Owner

@mchiang0610 commented on GitHub (Sep 30, 2023):

@FairyTail2000 Thank you for suggesting this. This actually sounds cool. For Ollama, we'd like to focus on the REST API -- otherwise, it's just too much for all the maintainers to chew on.

Would love it if you want to take a stab at building it as a separate project. Happy to work together.

Thanks! @reustle for the feedback too. Appreciate it!

<!-- gh-comment-id:1741680485 --> @mchiang0610 commented on GitHub (Sep 30, 2023): @FairyTail2000 Thank you for suggesting this. This actually sounds cool. For Ollama, we'd like to focus on the REST API -- otherwise, it's just too much for all the maintainers to chew on. Would love it if you want to take a stab at building it as a separate project. Happy to work together. Thanks! @reustle for the feedback too. Appreciate it!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#62305