Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type overloads for chat() method in _client.py #132

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

simonottenhauskenbun
Copy link

This PR adds two type overloads in _client.py to reduce type warnings.
The PR should only affect typing and no logic.

Before PR:

import ollama
response = ollama.chat(model='llama2', messages=[
  {
    'role': 'user',
    'content': 'Why is the sky blue?',
  },
])
# before PR: response is now Union[Mapping[str, Any], Iterator[Mapping[str, Any]]]
print(response['message']['content'])

New behaviour:

response = ollama.chat(model='llama2', stream=False, ...)
# response is of type Mapping[str, Any]

response = ollama.chat(model='llama2', stream=True, ...)
# response is of type Iterator[Mapping[str, Any]]

response = ollama.chat(model='llama2', ...)
# response is also of type Mapping[str, Any], since stream=False is the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant