The "algorithm" and "AP" in method and variable names refer to "model" and "MP" respectively.
You can invoke the models of your choice available via Orange by sending invocation requests from your dApp to the system using the Orange Server SDK.
The general sequence in which you would call the methods to send an invocation request by specifying an model and a dataset is:
Call GetAlgorithmProviders and GetDataProviders to go through the available model and data providers.
Choose an MP and DP, and call GetAlgorithmMethods and GetDataMethods to fetch the method details on available models and datasets.
Choose an MP method and a DP method ensuring the schemas match, then call RequestOrangeScoreto send an invocation request along with authorized and signed wallet information.
Call GetUserTask to fetch the invocation results, or the status of a task.
The Orange server uses GraphQL for its interface design. You can use the methods defined below to perform actions such as fetching MP and DP schema details and sending calculation requests using a model-data pair for specific wallets and DIDs.
To use the SDK you need a DID for your dApp. You can get one by creating a wallet using ONTO app.
Initialization
Add this dependency in the go.mod file in your project.
github.com/orange-protocol/orange-sdk-go latest
Schema definition
The major schemas defined for the interface are described below.
Returns the details of all the currently registered model providers.
Method:GetAlgorithmProviders
Parameters: none
Returns: []*AlgorithmProvider
typeAlgorithmProviderstruct { Name string`json:"name"` Type string`json:"type"` Introduction string`json:"introduction"` Did string`json:"did"` CreateTime int64`json:"createTime"` Title string`json:"title"` Provider string`json:"provider"` InvokeFrequency int64`json:"invokeFrequency"` APIState int64`json:"apiState"` Author string`json:"author"` Popularity int64`json:"popularity"` Delay int64`json:"delay"` Icon string`json:"icon"`}
2. Fetch available methods for an MP
Returns all the currently available models and the associated schemas as defined by an MP.
Method:GetAlgorithmMethods
Parameters
apdid- The DID of specified MP
Returns: []*ProviderMethod
typeProviderMethodstruct { Name string`json:"name"` ParamSchema string`json:"paramSchema"` ResultSchema string`json:"resultSchema"`}
3. Fetch details for all available DPs
Returns the details of all the currently registered data providers.
Method:GetDataProviders
Parameters: none
Returns: []*DataProvider
typeDataProviderstruct { Name string`json:"name"` Type string`json:"type"` Introduction string`json:"introduction"` Did string`json:"did"` CreateTime int64`json:"createTime"` Title string`json:"title"` Provider string`json:"provider"` InvokeFrequency int64`json:"invokeFrequency"` APIState int64`json:"apiState"` Author string`json:"author"` Popularity int64`json:"popularity"` Delay int64`json:"delay"` Icon string`json:"icon"`}
4. Fetch available data methods for a DP
Returns all the currently available datasets and the associated schemas as defined by a DP.
Method:GetDataMethods
Parameters
dpdid- The DID of specified DP
Returns: []*ProviderMethod
typeProviderMethodstruct { Name string`json:"name"` ParamSchema string`json:"paramSchema"` ResultSchema string`json:"resultSchema"`}
5. Send a request to run the model with selected data
Sends a request to generate the score or report for the specified wallet addresses using the specified model and dataset, or MP and DP method respectively. Returns a taskId.
Calculation requests are handled asynchronously. You can use the returned task ID to fetch the generated result.
Please note that certain types of data or volume may take some time to fetch, and so the calculation may take up to an hour in certain extreme cases after a request is sent successfully.
Method:RequestOrangeScore
Parameters
*RequestOrangeScoreReq- defined below
typeRequestOrangeScoreReqstruct { AppDid string`json:"appDid"`// DID of your dApp Data RequestOrangeScoreData`json:"data"`// request data, specified as below Sig string`json:"sig"`// signature: dApp's DID signed with its private key }typeRequestOrangeScoreDatastruct { Userdid string`json:"userDid"`// DID of the user Apdid string`json:"apdid"`// DID of the MP Apmethod string`json:"apmethod"`// MP method name Dpdid string`json:"dpdid"`// DID of the DP Dpmethod string`json:"dpmethod"`// DP method name overwriteOld bool`json:"overwriteOld"`// whether override existing task Wallets []*UserWallet`json:"wallets"`// user's wallet details, specified as below}typeUserWalletstruct { Chain string`json:"chain"`// name of the chain Address string`json:"address"`// linked wallet address Pubkey string`json:"pubkey"`// wallet public key Sig string`json:"sig"`// signature: user's DID signed with their private key}