首頁>編程相關>其他源碼

Superplatform旨在將AI時代的力量還給開發者——自行託管自己的AI平台!

開始

運行 Superplatform 最簡單的方法是使用 Docker。如果沒有 Docker,請安裝它。進入 repo root 並:

docker compose up

在前台運行平台。如果您按 Ctrl+C,它就會停止運作。如果你想在後台運行它:

docker compose up -d

使用

現在超級平台正在運行,您有幾個與之互動的選項。

使用者介面

您可以造訪http://127.0.0.1:3901並使用使用者名稱singulatron和密碼changeme登錄,然後開始使用它,就像使用ChatGPT一樣。

點擊大“AI”按鈕並首先下載模型。不用擔心,此模型將在重新啟動後保留(請參閱 docker-compose.yaml 中的磁碟區)。

客戶

為簡潔起見,下面的範例假設您已前往 UI 並下載了模型。 (也可以與客戶一起完成,但時間會更長)。

讓我們用 JS 來做一個同步提示。在你的專案中運行

npm i -s @superplatform/client

確保你的package.json包含"type": "module" ,將以下程式碼片段放入index.js

 import { UserSvcApi , PromptSvcApi , Configuration } from "@superplatform/client" ;

async function testDrive ( ) {
  let userService = new UserSvcApi ( ) ;
  let loginResponse = await userService . login ( {
    request : {
      slug : "singulatron" ,
      password : "changeme" ,
    } ,
  } ) ;

  const promptSvc = new PromptSvcApi (
    new Configuration ( {
      apiKey : loginResponse . token ?. token ,
    } )
  ) ;

  let promptRsp = await promptSvc . addPrompt ( {
    request : {
      sync : true ,
      prompt : "Is a cat an animal? Just answer with yes or no please." ,
    } ,
  } ) ;

  console . log ( promptRsp ) ;
}

testDrive ( ) ;

並運行

$ node index.js 
{
  answer: ' Yes, a cat is an animal.n ' +
    ' n ' +
    ' But if you meant to ask whether cats are domesticated animals or pets, then the answer is also yes. Cats belong to the Felidae family and are common household pets around the world. They are often kept for companionship and to control rodent populations. ' ,
  prompt: undefined
}

根據您的系統,人工智慧可能需要一段時間才能回應。如果需要很長時間檢查後端日誌是否正在處理,您應該看到以下內容:

superplatform-backend-1   | { " time " : " 2024-11-27T17:27:14.602762664Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :1, " totalResponses " :1}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:15.602328634Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :4, " totalResponses " :9}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:16.602428481Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :5, " totalResponses " :17}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:17.602586968Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :6, " totalResponses " :24}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:18.602583176Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :6, " totalResponses " :31}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:19.602576641Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :6, " totalResponses " :38}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:20.602284446Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :6, " totalResponses " :46}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:21.602178149Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :6, " totalResponses " :53}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:22.602470024Z " , " level " : " DEBUG " , " msg " : " LLM is streaming " , " promptId " : " prom_e3SA9bJV5u " , " responsesPerSecond " :6, " totalResponses " :61}
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:23.174054316Z " , " level " : " INFO " , " msg " : " Saving chat message " , " messageId " : " msg_e3SARBJAZe " }
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:23.175854857Z " , " level " : " DEBUG " , " msg " : " Event published " , " eventName " : " chatMessageAdded " }
superplatform-backend-1   | { " time " : " 2024-11-27T17:27:23.176260122Z " , " level " : " DEBUG " , " msg " : " Finished streaming LLM " , " error " : " <nil> " }

情境

Superplatform 是一個微服務平台,我第一次想到是在 2013 年,當時我正在為 Uber 的競爭對手 Hailo 工作。我擱置了這個想法,認為其他人最終會實現它。現在,隨著人工智慧的繁榮和我們即將推出的所有人工智慧應用程序,我意識到我必須自己建立它,因為沒有其他人這樣做。

它是一個伺服器和生態系統,使您能夠自行託管人工智慧模型,建立以任何語言利用這些模型的應用程序,並利用旨在支援各種專案的基於微服務的公共後端。

主要用例

在您的伺服器上運行

請參閱此頁面以協助您入門。

服務

請參閱 https://superplatform.ai/docs/category/superplatform-api/

在您的筆記型電腦/PC 上運行

我們已暫時停止分送桌面版本。請參閱此頁面以了解運行該軟體的替代方法。

執照

Superplatform 根據 AGPL-3.0 許可。

展開
附加信息