Skip to content

Commit

Permalink
Merge branch 'main' into gabriella/IsString
Browse files Browse the repository at this point in the history
  • Loading branch information
nickhs committed Mar 23, 2024
2 parents 3b682eb + b534c50 commit aa66c0f
Show file tree
Hide file tree
Showing 10 changed files with 934 additions and 329 deletions.
33 changes: 25 additions & 8 deletions openai-hs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,27 @@ import OpenAI.Client
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import System.Environment (getEnv)
import qualified Data.Vector as V
import qualified Data.Text as T

request :: ChatCompletionRequest
request = ChatCompletionRequest
{ chcrModel = ModelId "gpt-3.5-turbo"
, chcrMessages =
[ChatMessage { chmContent = "Write a hello world program in Haskell"
, chmRole = "user"
}
]
, chcrTemperature = Nothing
, chcrTopP = Nothing
, chcrN = Nothing
, chcrStream = Nothing
, chcrStop = Nothing
, chcrMaxTokens = Nothing
, chcrPresencePenalty = Nothing
, chcrFrequencyPenalty = Nothing
, chcrLogitBias = Nothing
, chcrUser = Nothing
}

main :: IO ()
main =
Expand All @@ -30,13 +50,10 @@ main =
-- create a openai client that automatically retries up to 4 times on network
-- errors
let client = makeOpenAIClient apiKey manager 4
result <-
searchDocuments cli (eId firstEngine) $
SearchResultCreate
{ sccrDocuments = V.fromList ["pool", "gym", "night club"]
, sccrQuery = "swimmer"
}
print result
result <- completeChat client request
case result of
Left failure -> print failure
Right success -> print $ chrChoices success
```

## Features
Expand Down
10 changes: 6 additions & 4 deletions openai-hs/openai-hs.cabal
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.34.4.
-- This file has been generated from package.yaml by hpack version 0.35.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: 8760d75e39a4a6db941c2503a8e8519a3c82b52bad91dcf39594cdd9258c7f4b
-- hash: d37104a564e8bdbce4dfdc276b621def2716ecaad3d474f0646934fd1b1f034b

name: openai-hs
version: 0.2.2.0
version: 0.3.0.1
synopsis: Unofficial OpenAI client
description: Unofficial OpenAI client
category: Web
homepage: https://github.com/agrafix/openai-hs#readme
bug-reports: https://github.com/agrafix/openai-hs/issues
author: Alexander Thiemann <[email protected]>
maintainer: Alexander Thiemann <[email protected]>
copyright: 2021-2022 Alexander Thiemann <[email protected]>
copyright: 2021-2023 Alexander Thiemann <[email protected]>
license: BSD3
license-file: LICENSE
build-type: Simple
Expand Down Expand Up @@ -58,6 +58,7 @@ library
, http-types
, openai-servant >=0.2.1
, servant
, servant-auth-client
, servant-client
, servant-multipart-client
, text
Expand Down Expand Up @@ -100,6 +101,7 @@ test-suite openai-hs-test
, openai-hs
, openai-servant >=0.2.1
, servant
, servant-auth-client
, servant-client
, servant-client-core
, servant-multipart-client
Expand Down
5 changes: 3 additions & 2 deletions openai-hs/package.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: openai-hs
version: 0.2.2.0
version: 0.3.0.1
github: "agrafix/openai-hs"
license: BSD3
author: "Alexander Thiemann <[email protected]>"
maintainer: "Alexander Thiemann <[email protected]>"
copyright: "2021-2022 Alexander Thiemann <[email protected]>"
copyright: "2021-2023 Alexander Thiemann <[email protected]>"

extra-source-files:
- README.md
Expand All @@ -21,6 +21,7 @@ dependencies:
- casing
- text
- servant
- servant-auth-client
- servant-client
- servant-multipart-client
- http-client
Expand Down
Loading

0 comments on commit aa66c0f

Please sign in to comment.