-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:effectai/effect-js into dev
- Loading branch information
Showing
35 changed files
with
658 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@effectai/sdk": patch | ||
--- | ||
|
||
- add symlinks for license and README | ||
- fix createBatch types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Authentication | ||
Some functions in the Effect AI SDK require authentication with the EOS blockchain. This is done by passing a session object to the createClient function. | ||
A session can be established by either [private key](https://github.com/wharfkit/wallet-plugin-privatekey) or [wallet plugins](https://wharfkit.com/plugins?tag=wallet-plugin). | ||
|
||
### Private Key | ||
To authenticate using a private key we recommend using the [wallet-plugin-privatekey](https://github.com/wharfkit/wallet-plugin-privatekey) | ||
And passing it through a session to the `createClient` function. | ||
|
||
```ts twoslash | ||
import { | ||
createClient, | ||
eos, | ||
Session | ||
} from "@effectai/sdk"; | ||
|
||
import { WalletPluginPrivateKey } from '@wharfkit/wallet-plugin-privatekey' | ||
|
||
const session = new Session({ | ||
chain: eos, | ||
walletPlugin: new WalletPluginPrivateKey( | ||
'5Jtoxgny5tT7NiNFp1MLogviuPJ9NniWjnU4wKzaX4t7pL4kJ8s', | ||
), | ||
}) | ||
|
||
const client = await createClient({ session }) | ||
``` | ||
|
||
### Wallet Plugin | ||
It's also possible to authenticate using a wallet plugin, for example using the [wallet-plugin-anchor](https://github.com/wharfkit/wallet-plugin-anchor) | ||
This one is a bit more complicated and requires two additional packages: [`@wharfkit/session`](https://github.com/wharfkit/session) and [`@wharfkit/web-renderer`](https://github.com/wharfkit/web-renderer) | ||
|
||
```ts twoslash | ||
import { | ||
createClient, | ||
eos, | ||
} from "@effectai/sdk"; | ||
|
||
import { SessionKit } from "@wharfkit/session"; | ||
import { WebRenderer } from "@wharfkit/web-renderer"; | ||
import { WalletPluginAnchor } from "@wharfkit/wallet-plugin-anchor"; | ||
|
||
const webRenderer = new WebRenderer(); | ||
|
||
const sessionKit = new SessionKit( | ||
{ | ||
appName: "Effect Network", | ||
chains: [eos], | ||
ui: webRenderer, | ||
walletPlugins: [ | ||
new WalletPluginAnchor(), | ||
], | ||
}, | ||
) | ||
|
||
const session = await sessionKit.restore(); | ||
|
||
if(!session) { | ||
throw new Error('Session not found') | ||
} | ||
|
||
const client = await createClient({ session }) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
## Adding tasks | ||
|
||
Adding tasks to a campaign is done through <u>batches</u> batches are a collection of tasks that are added to a campaign. Each batch can contain multiple tasks. | ||
Let's start by creating a batch with 3 tasks to our newly created image classification campaign. | ||
Adding tasks to a campaign is done through adding <u>batches</u>. | ||
|
||
```ts [example.ts] | ||
import { createBatch } from '@effectai/effect-js' | ||
Batches are a collection of tasks that are added to a campaign. Each batch can contain multiple tasks. | ||
Let's start by creating a batch with 3 tasks to our newly created image classification campaign. | ||
|
||
```ts twoslash | ||
// [!include ~/snippets/getting-started/getting-started-auth.ts] | ||
if(!client.session) { | ||
throw new Error('No session found') | ||
} | ||
const { actor } = client.session | ||
|
||
if(!actor) { | ||
throw new Error('No actor found') | ||
} | ||
//---cut--- | ||
import { createBatch } from '@effectai/sdk' | ||
|
||
const batch = await createBatch({ | ||
client, | ||
batch: { | ||
campaign_id: '<..>', // the id of the campaign | ||
repetitions: 1 // number of times each task should be repeated | ||
payer: actor // the actor that will pay the workers for the tasks | ||
} | ||
data: [ | ||
// The campaign id to which the batch should be added | ||
campaignId : 1, | ||
// The number of times each task in the batch should be repeated | ||
repetitions: 1, | ||
// The reward for each task in the batch | ||
reward: 3, | ||
// The template placeholders for each task in the batch | ||
taskData : [ | ||
{ | ||
image: 'https://example.com/image.jpg', //task 1 image placeholder | ||
ipfs_url: 'https://example.com/image.jpg', //task 1 image placeholder | ||
}, | ||
{ | ||
image: 'https://example.com/image2.jpg', //task 2 image placeholder | ||
ipfs_url: 'https://example.com/image2.jpg', //task 2 image placeholder | ||
}, | ||
{ | ||
image: 'https://example.com/image3.jpg', // task 3 image placeholder | ||
ipfs_url: 'https://example.com/image3.jpg', // task 3 image placeholder | ||
} | ||
] | ||
], | ||
}) | ||
``` | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Collecting Results | ||
|
||
TODO:: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docs.effect.ai |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.