Embeddings CLI
This commit is contained in:
1 parent
6ead08af22
commit
f54aaa6e95
5 files changed
+280
-7
No files matched your search
@@ -16,7 +16,7 @@ import Control.Monad.Catch (MonadCatch, MonadThrow)
|
||||
import Control.Monad.Reader (MonadIO, MonadReader, ReaderT, local, runReaderT)
|
||||
import Control.Monad.Trans.Control (MonadBaseControl)
|
||||
import Creds
|
||||
import Data.HashMap.Strict qualified as HM
|
||||
|
||||
import GHC.Generics (Generic)
|
||||
import HTTP (HTTPMetric (HTTPMetric))
|
||||
import Katip qualified as K
|
||||
@@ -37,6 +37,7 @@ data S = S
|
||||
_sCreds :: Creds,
|
||||
_sWallabagMetrics :: HTTPMetric,
|
||||
_sOpenrouterMetrics :: HTTPMetric,
|
||||
_sEmbeddingMetrics :: HTTPMetric,
|
||||
_sKatipTracer :: KatipTracer,
|
||||
_sMetricsStore :: EKG.Store,
|
||||
_sSession :: Wreq.Session
|
||||
@@ -92,6 +93,11 @@ initialS credsPath severity f = do
|
||||
<$> EKG.createDistribution "openrouter.requests" store
|
||||
<*> EKG.createCounter "openrouter.retries" store
|
||||
<*> EKG.createCounter "openrouter.failures" store
|
||||
emMetrics <-
|
||||
HTTPMetric
|
||||
<$> EKG.createDistribution "embeddings.requests" store
|
||||
<*> EKG.createCounter "embeddings.retries" store
|
||||
<*> EKG.createCounter "embeddings.failures" store
|
||||
c <- maybe getDefaultCreds readCreds credsPath
|
||||
handleScribe <- K.mkHandleScribe K.ColorIfTerminal stdout (K.permitItem severity) K.V2
|
||||
let makeLogEnv = K.registerScribe "stdout" handleScribe K.defaultScribeSettings =<< K.initLogEnv "wallabag" "production"
|
||||
@@ -99,7 +105,5 @@ initialS credsPath severity f = do
|
||||
let kTrace = mkKatipTrace le ns
|
||||
ns = "main"
|
||||
cache <- newTVarIO Unauthenticated
|
||||
f (S cache ns le mempty c wbMetrics orMetrics kTrace store wsession)
|
||||
-- TODO: This is just for debug purposes
|
||||
EKG.sampleAll store >>= mapM_ print . HM.toList
|
||||
f (S cache ns le mempty c wbMetrics orMetrics emMetrics kTrace store wsession)
|
||||
pure res
|
||||
Reference in new issue
Block a user