Class: Ollama::Client::Doc
- Inherits:
-
Object
- Object
- Ollama::Client::Doc
- Includes:
- Term::ANSIColor
- Defined in:
- lib/ollama/client/doc.rb
Overview
A class that generates documentation links for Ollama API commands.
This class is responsible for creating human-readable documentation references for various Ollama API endpoints. It maps command names to their corresponding documentation URLs, providing easy access to API documentation for developers working with the Ollama client.
Instance Method Summary collapse
-
#initialize(name) ⇒ Doc
constructor
A new instance of Doc.
-
#to_s ⇒ String
The to_s method converts the documentation object to a string representation.
Constructor Details
#initialize(name) ⇒ Doc
Returns a new instance of Doc.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ollama/client/doc.rb', line 16 def initialize(name) @name = name @url = Hash.new('https://github.com/ollama/ollama/blob/main/docs/api.md').merge( generate: 'https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-completion', chat: 'https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion', create: 'https://github.com/ollama/ollama/blob/main/docs/api.md#create-a-model', tags: 'https://github.com/ollama/ollama/blob/main/docs/api.md#list-local-models', show: 'https://github.com/ollama/ollama/blob/main/docs/api.md#show-model-information', copy: 'https://github.com/ollama/ollama/blob/main/docs/api.md#copy-a-model', delete: 'https://github.com/ollama/ollama/blob/main/docs/api.md#delete-a-model', pull: 'https://github.com/ollama/ollama/blob/main/docs/api.md#pull-a-model', push: 'https://github.com/ollama/ollama/blob/main/docs/api.md#push-a-model', embeddings: 'https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings', # superseded by /api/embed embed: 'https://github.com/ollama/ollama/blob/main/docs/api.md#generate-embeddings', ps: 'https://github.com/ollama/ollama/blob/main/docs/api.md#list-running-models', version: 'https://github.com/ollama/ollama/blob/main/docs/api.md#version', )[name] end |
Instance Method Details
#to_s ⇒ String
The to_s method converts the documentation object to a string representation.
This method generates a human-readable string that includes a hyperlink to the corresponding Ollama API documentation for the command, if a URL is available. The resulting string can be used for display purposes or logging.
43 44 45 |
# File 'lib/ollama/client/doc.rb', line 43 def to_s (hyperlink(@url) { @name } if @url).to_s end |