Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.6.0 Release - last one before API authentication and Agent enablement #46

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
56c2a29
Added adapter for hyperbolic-sd
bohdan-titan Dec 11, 2024
0769ac6
added default parameters
bohdan-titan Dec 11, 2024
a23a5e5
Renaming
bohdan-titan Dec 11, 2024
e0b2f30
changed param name
bohdan-titan Dec 11, 2024
333db5d
Added to UI
bohdan-titan Dec 11, 2024
3c5d61d
Changed example
bohdan-titan Dec 11, 2024
7e5e65c
added optional params for model
bohdan-titan Dec 13, 2024
9bec0a7
Fixed issue with lost id
bohdan-titan Dec 13, 2024
32d8ead
Removed logs
bohdan-titan Dec 16, 2024
c969e53
Merge pull request #356 from Lumerin-protocol/feature/hyperbolic-sd
bohdan-titan Dec 16, 2024
3b8a76c
updated package and fix warnings
bohdan-titan Dec 18, 2024
b156a6d
.
bohdan-titan Dec 18, 2024
c1d9029
refactor: logging
alex-sandrk Dec 18, 2024
fe18d10
update env example
alex-sandrk Dec 18, 2024
7904f62
Merge pull request #357 from Lumerin-protocol/feature/routing-package
bohdan-titan Dec 18, 2024
1f0c40e
Merge pull request #358 from Lumerin-protocol/feature/improve-logging
alex-sandrk Dec 18, 2024
1ac3301
added --no-webui and updated llama version to b4354 for releases
Dec 18, 2024
7a89d00
fix: fallback to public nodes on DELETE ethNode
shev-titan Jan 2, 2025
d50a0a4
Merge pull request #362 from Lumerin-protocol/fix/remove-ethnode-api
shev-titan Jan 2, 2025
6e70d02
feat: http auth
alex-sandrk Jan 6, 2025
7818f88
Merge pull request #364 from Lumerin-protocol/dev
alex-sandrk Jan 6, 2025
0c9b33d
Fixed parsing issue
bohdan-titan Jan 6, 2025
27985d5
Merge pull request #366 from Lumerin-protocol/fix/parsing-error
bohdan-titan Jan 6, 2025
8f8ff97
Merge pull request #359 from Lumerin-protocol/fix/llamadefaults
abs2023 Jan 6, 2025
0dac345
Merge pull request #365 from Lumerin-protocol/http-auth
alex-sandrk Jan 7, 2025
d330d41
Merge pull request #367 from Lumerin-protocol/dev
abs2023 Jan 7, 2025
68a425b
Revert "feat: http auth"
alex-sandrk Jan 7, 2025
02d3330
Merge pull request #368 from Lumerin-protocol/revert-365-http-auth
alex-sandrk Jan 7, 2025
7d99c33
Added call to clean wallet
bohdan-titan Jan 5, 2025
915d5c6
feat: handle v2 prodia for image; depricate v1 api
alex-sandrk Jan 8, 2025
cce5891
Merge pull request #371 from Lumerin-protocol/pretest
abs2023 Jan 9, 2025
3bc1366
handle remote prompt for prodia v2 image
alex-sandrk Jan 9, 2025
65fea64
wait 3s before run UI to wain proxy
alex-sandrk Jan 9, 2025
4c4fa3d
wait 3s before run UI to wain proxy
alex-sandrk Jan 9, 2025
c6aa90e
Merge pull request #374 from Lumerin-protocol/pretest
abs2023 Jan 9, 2025
227afd7
Revert "Pretest update 2"
abs2023 Jan 9, 2025
8ef221b
Merge pull request #375 from Lumerin-protocol/revert-374-pretest
abs2023 Jan 9, 2025
9f77a07
handle remote prompt for prodia v2 image
alex-sandrk Jan 9, 2025
d58bba0
wait 3s before run UI to wain proxy
alex-sandrk Jan 9, 2025
eae780f
removed auth related changes from cherry-pick
Jan 9, 2025
6d11b36
Merge pull request #376 from Lumerin-protocol/pretest2
abs2023 Jan 9, 2025
7ac394d
Merge pull request #378 from Lumerin-protocol/test
abs2023 Jan 10, 2025
8484bd8
feat: add claudeai support; fix text models
alex-sandrk Jan 10, 2025
d53f991
Merge pull request #379 from Lumerin-protocol/pretest3
abs2023 Jan 10, 2025
783b00a
Merge pull request #380 from Lumerin-protocol/test
abs2023 Jan 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ jobs:
echo "VFULL: $VFULL"
ARTIFACT="mor-launch-$TAG_NAME-ubuntu-x64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-ubuntu-x64.zip
LLAMACPP=llama-b4354-bin-ubuntu-x64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b4354/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP build/bin/llama-server
echo '{"run":["./llama-server -m ./'"$MODEL"'","./proxy-router","./morpheus-ui-'"$VFULL"'-x86_64-linux.AppImage"]}' > mor-launch.json
echo '{"run":["./llama-server --no-webui -m ./'"$MODEL"'","./proxy-router","./morpheus-ui-'"$VFULL"'-x86_64-linux.AppImage"]}' > mor-launch.json
echo "Contents of mor-launch.json: "
cat mor-launch.json
mv ./cli/mor-cli mor-cli
Expand Down Expand Up @@ -235,12 +235,12 @@ jobs:
run: |
ARTIFACT="mor-launch-$TAG_NAME-macos-x64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-macos-x64.zip
LLAMACPP=llama-b4354-bin-macos-x64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b4354/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP build/bin/llama-server
echo '{"run":["./llama-server -m ./'$MODEL'","./proxy-router","./MorpheusUI.app/Contents/MacOS/MorpheusUI"]}' > mor-launch.json
echo '{"run":["./llama-server --no-webui -m ./'$MODEL'","./proxy-router","./MorpheusUI.app/Contents/MacOS/MorpheusUI"]}' > mor-launch.json
echo "Contents of mor-launch.json: "
cat mor-launch.json
mv ./cli/mor-cli mor-cli
Expand Down Expand Up @@ -316,12 +316,12 @@ jobs:
run: |
ARTIFACT="mor-launch-$TAG_NAME-macos-arm64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-macos-arm64.zip
LLAMACPP=llama-b4354-bin-macos-arm64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b4354/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP build/bin/llama-server
echo '{"run":["./llama-server -m ./'$MODEL'","./proxy-router","./MorpheusUI.app/Contents/MacOS/MorpheusUI"]}' > mor-launch.json
echo '{"run":["./llama-server --no-webui -m ./'$MODEL'","./proxy-router","./MorpheusUI.app/Contents/MacOS/MorpheusUI"]}' > mor-launch.json
echo "Contents of mor-launch.json: "
cat mor-launch.json
mv ./cli/mor-cli mor-cli
Expand Down Expand Up @@ -403,12 +403,12 @@ jobs:
echo "VFULL: $VFULL"
ARTIFACT="mor-launch-$TAG_NAME-win-x64.zip"
echo "Artifact: $ARTIFACT"
LLAMACPP=llama-b3256-bin-win-avx2-x64.zip
LLAMACPP=llama-b4354-bin-win-avx2-x64.zip
MODEL=tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b3256/$LLAMACPP
wget -nv https://github.com/ggerganov/llama.cpp/releases/download/b4354/$LLAMACPP
wget -nv https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/$MODEL
unzip -o -j $LLAMACPP llama-server.exe llama.dll ggml.dll
echo '{"run":["./llama-server.exe -m ./'"$MODEL"'","./proxy-router.exe","./morpheus-ui-'"$VFULL"'-x64-win.exe"]}' > mor-launch.json
echo '{"run":["./llama-server.exe --no-webui -m ./'"$MODEL"'","./proxy-router.exe","./morpheus-ui-'"$VFULL"'-x64-win.exe"]}' > mor-launch.json
echo "Contents of mor-launch.json: "
cat mor-launch.json
mv .env .env.tmp
Expand Down
9 changes: 3 additions & 6 deletions docs/proxy-router.all.env
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ LOG_IS_PROD=false
LOG_JSON=false
# Log levels for various components (one of debug info warn error dpanic panic fatal)
LOG_LEVEL_APP=debug
LOG_LEVEL_CONNECTION=info
LOG_LEVEL_PROXY=info
LOG_LEVEL_SCHEDULER=info
LOG_LEVEL_CONTRACT=debug
LOG_LEVEL_RPC=info
LOG_LEVEL_BADGER=info
LOG_LEVEL_TCP=info
LOG_LEVEL_ETH_RPC=info
LOG_LEVEL_STORAGE=info

# Proxy Configurations
# Address for the proxy (default is "0.0.0.0:3333" if not set)
Expand Down
66 changes: 26 additions & 40 deletions proxy-router/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,42 +98,28 @@ func start() error {

appLog := log.Named("APP")

proxyLog, err := lib.NewLogger(cfg.Log.LevelProxy, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
tcpLog, err := lib.NewLogger(cfg.Log.LevelTCP, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
if err != nil {
return err
}

connLog, err := lib.NewLogger(cfg.Log.LevelConnection, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
if err != nil {
return err
}

schedulerLogFactory := func(remoteAddr string) (lib.ILogger, error) {
fp := ""
if logFolderPath != "" {
fp = filepath.Join(logFolderPath, fmt.Sprintf("scheduler-%s.log", lib.SanitizeFilename(remoteAddr)))
}
return lib.NewLogger(cfg.Log.LevelScheduler, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, fp)
}

contractLogStorage := lib.NewCollection[*interfaces.LogStorage]()

rpcLog, err := lib.NewLogger(cfg.Log.LevelRPC, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
rpcLog, err := lib.NewLogger(cfg.Log.LevelEthRPC, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
if err != nil {
return err
}

badgerLog, err := lib.NewLogger(cfg.Log.LevelBadger, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
storageLog, err := lib.NewLogger(cfg.Log.LevelStorage, cfg.Log.Color, cfg.Log.IsProd, cfg.Log.JSON, mainLogFilePath)
if err != nil {
return err
}

defer func() {
_ = connLog.Close()
_ = proxyLog.Close()
_ = tcpLog.Close()
_ = log.Close()
_ = rpcLog.Close()
_ = badgerLog.Close()
_ = storageLog.Close()
}()

appLog.Infof("proxy-router %s", config.BuildVersion)
Expand Down Expand Up @@ -198,7 +184,7 @@ func start() error {
appLog.Info("Wallet deleted")
}

ethNodeStorage := ethclient.NewRPCClientStoreKeychain(keychainStorage, nil, log)
ethNodeStorage := ethclient.NewRPCClientStoreKeychain(keychainStorage, nil, rpcLog.Named("RPC"))
err = ethNodeStorage.RemoveURLs()
if err != nil {
appLog.Warnf("Failed to remove eth node urls\n%s", err)
Expand Down Expand Up @@ -227,16 +213,16 @@ func start() error {
}
appLog.Infof("connected to ethereum node: %s, chainID: %d", cfg.Blockchain.EthNodeAddress, chainID)

storage := storages.NewStorage(badgerLog, cfg.Proxy.StoragePath)
storage := storages.NewStorage(storageLog, cfg.Proxy.StoragePath)
sessionStorage := storages.NewSessionStorage(storage)

var wallet interfaces.Wallet
if len(*cfg.Marketplace.WalletPrivateKey) > 0 {
wallet = wlt.NewEnvWallet(*cfg.Marketplace.WalletPrivateKey)
log.Warnf("Using env wallet. Private key persistance unavailable")
appLog.Warnf("Using env wallet. Private key persistance unavailable")
} else {
wallet = wlt.NewKeychainWallet(keychainStorage)
log.Infof("Using keychain wallet")
appLog.Infof("Using keychain wallet")
}

var logWatcher contracts.LogWatcher
Expand All @@ -248,7 +234,7 @@ func start() error {
appLog.Infof("using polling for blockchain events")
}

scorer, err := config.LoadRating(cfg.Proxy.RatingConfigPath, log)
scorer, err := config.LoadRating(cfg.Proxy.RatingConfigPath, appLog)
if err != nil {
return err
}
Expand All @@ -257,35 +243,35 @@ func start() error {
chatStorage := chatstorage.NewChatStorage(chatStoragePath)

multicallBackend := multicall.NewMulticall3Custom(ethClient, *cfg.Blockchain.Multicall3Addr)
sessionRouter := registries.NewSessionRouter(*cfg.Marketplace.DiamondContractAddress, ethClient, multicallBackend, log)
marketplace := registries.NewMarketplace(*cfg.Marketplace.DiamondContractAddress, ethClient, multicallBackend, log)
sessionRouter := registries.NewSessionRouter(*cfg.Marketplace.DiamondContractAddress, ethClient, multicallBackend, rpcLog)
marketplace := registries.NewMarketplace(*cfg.Marketplace.DiamondContractAddress, ethClient, multicallBackend, rpcLog)
sessionRepo := sessionrepo.NewSessionRepositoryCached(sessionStorage, sessionRouter, marketplace)
proxyRouterApi := proxyapi.NewProxySender(chainID, wallet, contractLogStorage, sessionStorage, sessionRepo, log)
proxyRouterApi := proxyapi.NewProxySender(chainID, wallet, contractLogStorage, sessionStorage, sessionRepo, appLog)
explorer := blockchainapi.NewExplorerClient(cfg.Blockchain.ExplorerApiUrl, *cfg.Marketplace.MorTokenAddress, cfg.Blockchain.ExplorerRetryDelay, cfg.Blockchain.ExplorerMaxRetries)
blockchainApi := blockchainapi.NewBlockchainService(ethClient, multicallBackend, *cfg.Marketplace.DiamondContractAddress, *cfg.Marketplace.MorTokenAddress, explorer, wallet, proxyRouterApi, sessionRepo, scorer, proxyLog, cfg.Blockchain.EthLegacyTx)
blockchainApi := blockchainapi.NewBlockchainService(ethClient, multicallBackend, *cfg.Marketplace.DiamondContractAddress, *cfg.Marketplace.MorTokenAddress, explorer, wallet, proxyRouterApi, sessionRepo, scorer, appLog, rpcLog, cfg.Blockchain.EthLegacyTx)
proxyRouterApi.SetSessionService(blockchainApi)

modelConfigLoader := config.NewModelConfigLoader(cfg.Proxy.ModelsConfigPath, valid, blockchainApi, &aiengine.ConnectionChecker{}, log)
modelConfigLoader := config.NewModelConfigLoader(cfg.Proxy.ModelsConfigPath, valid, blockchainApi, &aiengine.ConnectionChecker{}, appLog)
err = modelConfigLoader.Init()
if err != nil {
log.Warnf("failed to load model config, running with empty: %s", err)
appLog.Warnf("failed to load model config, running with empty: %s", err)
}

aiEngine := aiengine.NewAiEngine(proxyRouterApi, chatStorage, modelConfigLoader, log)
aiEngine := aiengine.NewAiEngine(proxyRouterApi, chatStorage, modelConfigLoader, appLog)

eventListener := blockchainapi.NewEventsListener(sessionRepo, sessionRouter, wallet, logWatcher, log)
eventListener := blockchainapi.NewEventsListener(sessionRepo, sessionRouter, wallet, logWatcher, appLog)

sessionExpiryHandler := blockchainapi.NewSessionExpiryHandler(blockchainApi, sessionStorage, wallet, log)
blockchainController := blockchainapi.NewBlockchainController(blockchainApi, log)
sessionExpiryHandler := blockchainapi.NewSessionExpiryHandler(blockchainApi, sessionStorage, wallet, appLog)
blockchainController := blockchainapi.NewBlockchainController(blockchainApi, appLog)

ethConnectionValidator := system.NewEthConnectionValidator(*big.NewInt(int64(cfg.Blockchain.ChainID)))
proxyController := proxyapi.NewProxyController(proxyRouterApi, aiEngine, chatStorage, *cfg.Proxy.StoreChatContext.Bool, *cfg.Proxy.ForwardChatContext.Bool, log)
proxyController := proxyapi.NewProxyController(proxyRouterApi, aiEngine, chatStorage, *cfg.Proxy.StoreChatContext.Bool, *cfg.Proxy.ForwardChatContext.Bool, appLog)
walletController := walletapi.NewWalletController(wallet)
systemController := system.NewSystemController(&cfg, wallet, rpcClientStore, sysConfig, appStartTime, chainID, log, ethConnectionValidator)
systemController := system.NewSystemController(&cfg, wallet, rpcClientStore, sysConfig, appStartTime, chainID, appLog, ethConnectionValidator)

apiBus := apibus.NewApiBus(blockchainController, proxyController, walletController, systemController)
httpHandler := httphandlers.CreateHTTPServer(log, apiBus)
httpServer := transport.NewServer(cfg.Web.Address, httpHandler, log.Named("HTTP"))
httpHandler := httphandlers.CreateHTTPServer(appLog, apiBus)
httpServer := transport.NewServer(cfg.Web.Address, httpHandler, appLog.Named("HTTP"))

// http server should shut down latest to keep pprof running
serverErrCh := make(chan error, 1)
Expand All @@ -295,9 +281,9 @@ func start() error {
cancel()
}()

log.Infof("API docs available at %s/swagger/index.html", cfg.Web.PublicUrl)
appLog.Infof("API docs available at %s/swagger/index.html", cfg.Web.PublicUrl)

proxy := proxyctl.NewProxyCtl(eventListener, wallet, chainID, log, connLog, cfg.Proxy.Address, schedulerLogFactory, sessionStorage, modelConfigLoader, valid, aiEngine, blockchainApi, sessionRepo, sessionExpiryHandler)
proxy := proxyctl.NewProxyCtl(eventListener, wallet, chainID, appLog, tcpLog, cfg.Proxy.Address, sessionStorage, modelConfigLoader, valid, aiEngine, blockchainApi, sessionRepo, sessionExpiryHandler)
err = proxy.Run(ctx)

cancelServer()
Expand Down
12 changes: 10 additions & 2 deletions proxy-router/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/system.ConfigResponse"
"$ref": "#/definitions/system.StatusRes"
}
}
}
Expand All @@ -1143,7 +1143,7 @@ const docTemplate = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/system.ConfigResponse"
"$ref": "#/definitions/system.StatusRes"
}
}
}
Expand Down Expand Up @@ -2486,6 +2486,14 @@ const docTemplate = `{
}
}
}
},
"system.StatusRes": {
"type": "object",
"properties": {
"status": {
"type": "string"
}
}
}
},
"externalDocs": {
Expand Down
12 changes: 10 additions & 2 deletions proxy-router/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/system.ConfigResponse"
"$ref": "#/definitions/system.StatusRes"
}
}
}
Expand All @@ -1135,7 +1135,7 @@
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/system.ConfigResponse"
"$ref": "#/definitions/system.StatusRes"
}
}
}
Expand Down Expand Up @@ -2478,6 +2478,14 @@
}
}
}
},
"system.StatusRes": {
"type": "object",
"properties": {
"status": {
"type": "string"
}
}
}
},
"externalDocs": {
Expand Down
9 changes: 7 additions & 2 deletions proxy-router/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,11 @@ definitions:
required:
- urls
type: object
system.StatusRes:
properties:
status:
type: string
type: object
externalDocs:
description: OpenAPI
url: https://swagger.io/resources/open-api/
Expand Down Expand Up @@ -1337,7 +1342,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/system.ConfigResponse'
$ref: '#/definitions/system.StatusRes'
summary: Delete Eth Node URLs
tags:
- system
Expand All @@ -1358,7 +1363,7 @@ paths:
"200":
description: OK
schema:
$ref: '#/definitions/system.ConfigResponse'
$ref: '#/definitions/system.StatusRes'
summary: Set Eth Node URLs
tags:
- system
Expand Down
2 changes: 1 addition & 1 deletion proxy-router/internal/aiengine/ai_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (a *AiEngine) GetAdapter(ctx context.Context, chatID, modelID, sessionID co
return nil, fmt.Errorf("model not found: %s", modelID.Hex())
}
var ok bool
engine, ok = ApiAdapterFactory(modelConfig.ApiType, modelConfig.ModelName, modelConfig.ApiURL, modelConfig.ApiKey, a.log)
engine, ok = ApiAdapterFactory(modelConfig.ApiType, modelConfig.ModelName, modelConfig.ApiURL, modelConfig.ApiKey, modelConfig.Parameters, a.log)
if !ok {
return nil, fmt.Errorf("api adapter not found: %s", modelConfig.ApiType)
}
Expand Down
Loading