Skip to content

Commit

Permalink
Use QueryStrings in the API to capture all query parameters
Browse files Browse the repository at this point in the history
The Custom GPT doesn't understand this, yet, but it is still a net
improvement to before.
  • Loading branch information
fendor committed Sep 10, 2024
1 parent 706465d commit 8a307ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
30 changes: 7 additions & 23 deletions lib/haskell/web-service/src/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ instance (HasOpenApi sub) => HasOpenApi (QueryString :> sub) where
& addParam param
& addDefaultResponse400 tname
where
tname = "params"
tname = "mycoolnewparams"
backendParam =
mempty
& name .~ "backend"
Expand Down Expand Up @@ -137,25 +137,14 @@ instance ToSchema ResponseWithReason
-- 'ToJSON Reasoning' instance yet.
instance ToSchema Reasoning

-- This is correct, since we don't overwrite the
-- 'ToJSON Reasoning' instance yet.
instance ToSchema ReasoningTree

-- where
-- declareNamedSchema p = do
-- defSchema <- genericDeclareNamedSchema defaultSchemaOptions p
-- pure defSchema

-- This is correct, since we don't overwrite the
-- 'ToJSON Reasoning' instance yet.
instance ToSchema ReasonNode

-- where
-- declareNamedSchema p = do
-- defSchema <- genericDeclareNamedSchema defaultSchemaOptions p
-- pure $
-- defSchema
-- & schema . required
-- .~ [ "reasoningNodeExampleCode"
-- , "reasoningNodeExplanation"
-- ]

instance ToSchema Function where
declareNamedSchema _ = do
textRef <- declareSchemaRef (Proxy @Text.Text)
Expand Down Expand Up @@ -222,7 +211,7 @@ instance ToSchema Parameter where
instance ToParamSchema FnLiteral where
toParamSchema _ =
mempty
& title ?~ "Function argument"
& title ?~ "Argument"
-- Even though this is strictly speaking not *only* a string, custom GPT seem
-- to need this, otherwise they will fail to send any requests to any endpoint with
-- this query parameter.
Expand All @@ -235,11 +224,6 @@ instance ToSchema FnLiteral where
pure $
NamedSchema (Just "Literal") $
toParamSchema p
-- We overwrite this, as the schema itself may be one of
-- string, int, double or bool... And I don't think we can express that
-- here?
-- Schema validation doesn't like this set to 'OpenApiString', likely for good reason.
& type_ .~ Nothing

instance ToSchema EvalBackends where
declareNamedSchema p = do
Expand All @@ -251,7 +235,7 @@ instance ToParamSchema EvalBackends where
toParamSchema _ =
mempty
& type_ ?~ OpenApiString
& title ?~ "Backend to use for function evaluation"
& title ?~ "Evaluation Backends"
& example ?~ Aeson.String "simala"
& default_ ?~ Aeson.String "simala"
& enum_ ?~ [Aeson.String "simala", Aeson.String "gml"]
Expand Down
2 changes: 0 additions & 2 deletions lib/haskell/web-service/src/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ import System.Timeout (timeout)
import Backend.Api
import Backend.Explainable (genericMathLangEvaluator)
import Backend.Simala (simalaEvaluator)
import Data.Function (on)
import Data.Map (Map)

-- ----------------------------------------------------------------------------
-- Servant API
Expand Down

0 comments on commit 8a307ab

Please sign in to comment.