Skip to content

Commit efc7ea3

Browse files
authored
Merge pull request #5 from jmorganca/mxyng
Mxyng
2 parents 0f9211d + 1f68bae commit efc7ea3

File tree

4 files changed

+319
-46
lines changed

4 files changed

+319
-46
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,18 @@ async def chat():
6868

6969
asyncio.run(chat())
7070
```
71+
72+
## Handling Errors
73+
74+
Errors are raised if requests return an error status or if an error is detected while streaming.
75+
76+
```python
77+
model = 'does-not-yet-exist'
78+
79+
try:
80+
ollama.chat(model)
81+
except ollama.ResponseError as e:
82+
print('Error:', e.content)
83+
if e.status_code == 404:
84+
ollama.pull(model)
85+
```

ollama/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
from ollama._client import Client, AsyncClient
2-
from ollama._types import Message, Options
2+
from ollama._types import (
3+
GenerateResponse,
4+
ChatResponse,
5+
ProgressResponse,
6+
Message,
7+
Options,
8+
RequestError,
9+
ResponseError,
10+
)
311

412
__all__ = [
513
'Client',
614
'AsyncClient',
15+
'GenerateResponse',
16+
'ChatResponse',
17+
'ProgressResponse',
718
'Message',
819
'Options',
20+
'RequestError',
21+
'ResponseError',
922
'generate',
1023
'chat',
24+
'embeddings',
1125
'pull',
1226
'push',
1327
'create',
@@ -21,6 +35,7 @@
2135

2236
generate = _client.generate
2337
chat = _client.chat
38+
embeddings = _client.embeddings
2439
pull = _client.pull
2540
push = _client.push
2641
create = _client.create

0 commit comments

Comments
 (0)