Skip to content

Commit

Permalink
storing changed configuration and avoiding null line
Browse files Browse the repository at this point in the history
  • Loading branch information
lamg committed Aug 25, 2024
1 parent 6dacae9 commit dbcfb4c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions R0b0t.Lib/Core.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
13 changes: 8 additions & 5 deletions R0b0t.Lib/ModelProvider/ServerSentEvents.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R0b0t.Lib/R0b0t.Lib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RootNamespace>r0b0t.events</RootNamespace>

<Version>0.1.4</Version>
<Version>0.1.5</Version>
<Authors>Luis Ángel Méndez Gort</Authors>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
<AssemblyName>R0b0t.Lib</AssemblyName>
Expand Down
2 changes: 1 addition & 1 deletion r0b0t/r0b0t.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<PackageOutputPath>./nupkg</PackageOutputPath>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

<Version>0.1.4</Version>
<Version>0.1.5</Version>
<Authors>Luis Ángel Méndez Gort</Authors>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
<AssemblyName>r0b0t</AssemblyName>
Expand Down

0 comments on commit dbcfb4c

Please sign in to comment.