Skip to content

Could you add the with-as syntax #614

@Freakwill

Description

@Freakwill

It is better to add with-syntax

with ollama.Client() as c: pass
...
Traceback (most recent call last):
File "", line 1, in
TypeError: 'Client' object does not support the context manager protocol

My approach is (for MacOS)

    def __enter__(self, *args, **kwargs):
        import sh
        sh.brew.services.start.ollama()
        return self

    def __exit__(self, *args, **kwargs):
        import sh
        sh.brew.services.stop.ollama()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions