File tree Expand file tree Collapse file tree 4 files changed +319
-46
lines changed
Expand file tree Collapse file tree 4 files changed +319
-46
lines changed Original file line number Diff line number Diff line change @@ -68,3 +68,18 @@ async def chat():
6868
6969asyncio.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+ ```
Original file line number Diff line number Diff line change 11from 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' ,
2135
2236generate = _client .generate
2337chat = _client .chat
38+ embeddings = _client .embeddings
2439pull = _client .pull
2540push = _client .push
2641create = _client .create
You can’t perform that action at this time.
0 commit comments