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

Crash on empty message #18

Closed
suhr opened this issue Dec 16, 2023 · 1 comment · Fixed by #19
Closed

Crash on empty message #18

suhr opened this issue Dec 16, 2023 · 1 comment · Fixed by #19

Comments

@suhr
Copy link
Contributor

suhr commented Dec 16, 2023

To reproduce just post an empty message.

[suhr@nixos:~/oterm]$ oterm
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /nix/store/39akrbfw5pyriz81qfn7i21g0d805vj7-python3.11-oterm-0.1.16/lib/python3.11/site-packages/oterm/app/chat.py:93 in on_submit                                                                                                                          │
│                                                                                                                                                                                                                                                             │
│    90 │   │   message_container.scroll_end()                                                   ╭────────────────────── locals ───────────────────────╮                                                                                                      │
│    91 │   │                                                                                    │         chat_item = ChatItem()                      │                                                                                                      │
│    92 │   │   response = ""                                                                    │             event = Submitted()                     │                                                                                                      │
│ ❱  93 │   │   async for text in self.ollama.stream(message):                                   │             input = FlexibleInput(id='prompt')      │                                                                                                      │
│    94 │   │   │   response = text                                                              │           loading = LoadingIndicator()              │                                                                                                      │
│    95 │   │   │   chat_item.text = text                                                        │           message = ''                              │                                                                                                      │
│    96 │   │   │   message_container.scroll_end()                                               │ message_container = Vertical(id='messageContainer') │                                                                                                      │
│                                                                                                │          response = ''                              │                                                                                                      │
│                                                                                                │              self = ChatContainer()                 │                                                                                                      │
│                                                                                                │              text = ''                              │                                                                                                      │
│                                                                                                ╰─────────────────────────────────────────────────────╯                                                                                                      │
│                                                                                                                                                                                                                                                             │
│ /nix/store/39akrbfw5pyriz81qfn7i21g0d805vj7-python3.11-oterm-0.1.16/lib/python3.11/site-packages/oterm/ollama.py:43 in stream                                                                                                                               │
│                                                                                                                                                                                                                                                             │
│    40 │   async def stream(self, prompt) -> AsyncGenerator[str, Any]:                          ╭────────────────────────── locals ───────────────────────────╮                                                                                              │
│    41 │   │   context = []                                                                     │ context = []                                                │                                                                                              │
│    42 │   │                                                                                    │     ctx = []                                                │                                                                                              │
│ ❱  43 │   │   async for text, ctx in self._agenerate(                                          │  prompt = ''                                                │                                                                                              │
│    44 │   │   │   prompt=prompt,                                                               │    self = <oterm.ollama.OllamaLLM object at 0x7fffee5ac390> │                                                                                              │
│    45 │   │   │   context=self.context,                                                        │    text = ''                                                │                                                                                              │
│    46 │   │   ):                                                                               ╰─────────────────────────────────────────────────────────────╯                                                                                              │
│                                                                                                                                                                                                                                                             │
│ /nix/store/39akrbfw5pyriz81qfn7i21g0d805vj7-python3.11-oterm-0.1.16/lib/python3.11/site-packages/oterm/ollama.py:82 in _agenerate                                                                                                                           │
│                                                                                                                                                                                                                                                             │
│    79 │   │   │   │   │   raise OllamaError(body["error"])                                     ╭──────────────────────────────────────────────────────── locals ────────────────────────────────────────────────────────╮                                   │
│    80 │   │   │   │                                                                            │     body = {'model': 'mixtral:instruct', 'created_at': '2023-12-16T03:57:13.174105644Z', 'response': '', 'done': True} │                                   │
│    81 │   │   │   │   if body.get("done", False):                                              │   client = <httpx.AsyncClient object at 0x7fffee391b90>                                                                │                                   │
│ ❱  82 │   │   │   │   │   yield res, body["context"]                                           │  context = []                                                                                                          │                                   │
│    83                                                                                          │      jsn = {'model': 'mixtral:instruct', 'prompt': '', 'context': []}                                                  │                                   │
│    84                                                                                          │     line = '{"model":"mixtral:instruct","created_at":"2023-12-16T03:57:13.174105644Z","respo'+20                       │                                   │
│    85 class OllamaAPI:                                                                         │   prompt = ''                                                                                                          │                                   │
│                                                                                                │      res = ''                                                                                                          │                                   │
│                                                                                                │ response = <Response [200 OK]>                                                                                         │                                   │
│                                                                                                │     self = <oterm.ollama.OllamaLLM object at 0x7fffee5ac390>                                                           │                                   │
│                                                                                                ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯                                   │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ggozad added a commit that referenced this issue Dec 16, 2023
@ggozad ggozad linked a pull request Dec 16, 2023 that will close this issue
ggozad added a commit that referenced this issue Dec 16, 2023
ggozad added a commit that referenced this issue Dec 16, 2023
@ggozad
Copy link
Owner

ggozad commented Dec 16, 2023

Thank you!

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 a pull request may close this issue.

2 participants