From dbcfb4c77fa849cb3c98c7f3a78cbd61cdc31f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20M=C3=A9ndez=20Gort?= Date: Sun, 25 Aug 2024 12:38:03 +0200 Subject: [PATCH] storing changed configuration and avoiding null line --- CHANGELOG.md | 7 +++++++ R0b0t.Lib/Core.fs | 7 +++++-- R0b0t.Lib/ModelProvider/ServerSentEvents.fs | 13 ++++++++----- R0b0t.Lib/R0b0t.Lib.fsproj | 2 +- r0b0t/r0b0t.fsproj | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47fb37c..b25aca8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [0.1.5] - 2024-08-25 + +Fixed: + +- Storing configuration when a setting changes (provider, model, API key) +- Avoiding null string when reading server sent events + # [0.1.4] - 2024-08-24 Changed: diff --git a/R0b0t.Lib/Core.fs b/R0b0t.Lib/Core.fs index b386273..0c93787 100644 --- a/R0b0t.Lib/Core.fs +++ b/R0b0t.Lib/Core.fs @@ -111,9 +111,11 @@ let main () = model = m } mng.setConfiguration c + mng.storeConfiguration () updateTopBar () | SetProvider p -> mng.getConfiguration () |> setProvider p |> mng.setConfiguration + mng.storeConfiguration () updateTopBar () | Completion prompt when not isStreaming -> isStreaming <- true @@ -123,11 +125,12 @@ let main () = let key = s.Trim() let c = mng.getConfiguration () - let c = + let nc = { c with keys = Map.add c.provider (Key key) c.keys } - mng.setConfiguration c + mng.setConfiguration nc + mng.storeConfiguration () streamMessage producerEvent (setApiKeyMessage c.provider) diff --git a/R0b0t.Lib/ModelProvider/ServerSentEvents.fs b/R0b0t.Lib/ModelProvider/ServerSentEvents.fs index 75f5f02..2648cd2 100644 --- a/R0b0t.Lib/ModelProvider/ServerSentEvents.fs +++ b/R0b0t.Lib/ModelProvider/ServerSentEvents.fs @@ -42,12 +42,15 @@ let chooseEvents (f: EventLine -> 'a option) (stream: IO.Stream) = try let! line = rd.ReadLineAsync(tks.Token).AsTask() |> Async.AwaitTask - match parseEventLine line with - | Some e -> - match f e with - | Some x -> yield x + if line <> null then + match parseEventLine line with + | Some e -> + match f e with + | Some x -> yield x + | None -> () | None -> () - | None -> () + else + cont <- false with | :? ArgumentNullException | :? NullReferenceException diff --git a/R0b0t.Lib/R0b0t.Lib.fsproj b/R0b0t.Lib/R0b0t.Lib.fsproj index e7066a2..b2f80b4 100644 --- a/R0b0t.Lib/R0b0t.Lib.fsproj +++ b/R0b0t.Lib/R0b0t.Lib.fsproj @@ -5,7 +5,7 @@ true r0b0t.events - 0.1.4 + 0.1.5 Luis Ángel Méndez Gort AGPL-3.0-or-later R0b0t.Lib diff --git a/r0b0t/r0b0t.fsproj b/r0b0t/r0b0t.fsproj index 3ecef97..363b7ba 100644 --- a/r0b0t/r0b0t.fsproj +++ b/r0b0t/r0b0t.fsproj @@ -8,7 +8,7 @@ ./nupkg true - 0.1.4 + 0.1.5 Luis Ángel Méndez Gort AGPL-3.0-or-later r0b0t