@sogni-ai/sogni-client 3.0.0-alpha.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +335 -0
- package/README.md +4 -11
- package/dist/Account/CurrentAccount.d.ts +3 -3
- package/dist/Account/CurrentAccount.js +12 -4
- package/dist/Account/CurrentAccount.js.map +1 -1
- package/dist/Account/index.d.ts +42 -13
- package/dist/Account/index.js +132 -29
- package/dist/Account/index.js.map +1 -1
- package/dist/Account/types.d.ts +21 -0
- package/dist/ApiClient/WebSocketClient/events.d.ts +55 -7
- package/dist/ApiClient/WebSocketClient/index.js +1 -1
- package/dist/ApiClient/index.d.ts +4 -2
- package/dist/ApiClient/index.js +12 -3
- package/dist/ApiClient/index.js.map +1 -1
- package/dist/ApiGroup.d.ts +0 -3
- package/dist/ApiGroup.js +0 -1
- package/dist/ApiGroup.js.map +1 -1
- package/dist/Projects/Job.d.ts +43 -0
- package/dist/Projects/Job.js +76 -0
- package/dist/Projects/Job.js.map +1 -1
- package/dist/Projects/Project.d.ts +1 -1
- package/dist/Projects/Project.js +9 -18
- package/dist/Projects/Project.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +2 -2
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +7 -2
- package/dist/Projects/index.js +48 -10
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/ControlNetParams.d.ts +7 -2
- package/dist/Projects/types/events.d.ts +6 -0
- package/dist/Projects/types/index.d.ts +16 -3
- package/dist/Projects/utils.d.ts +2 -0
- package/dist/Projects/utils.js +14 -0
- package/dist/Projects/utils.js.map +1 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.js +6 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.js +15 -0
- package/dist/lib/utils.js.map +1 -1
- package/dist/types/token.d.ts +1 -0
- package/dist/types/token.js +3 -0
- package/dist/types/token.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +2 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/src/Account/CurrentAccount.ts +14 -6
- package/src/Account/index.ts +163 -59
- package/src/Account/types.ts +26 -0
- package/src/ApiClient/WebSocketClient/events.ts +59 -7
- package/src/ApiClient/WebSocketClient/index.ts +1 -1
- package/src/ApiClient/index.ts +15 -4
- package/src/ApiGroup.ts +0 -4
- package/src/Projects/Job.ts +98 -0
- package/src/Projects/Project.ts +11 -19
- package/src/Projects/createJobRequestMessage.ts +4 -2
- package/src/Projects/index.ts +53 -13
- package/src/Projects/types/ControlNetParams.ts +8 -2
- package/src/Projects/types/events.ts +6 -0
- package/src/Projects/types/index.ts +17 -3
- package/src/Projects/utils.ts +12 -0
- package/src/Stats/index.ts +2 -2
- package/src/index.ts +23 -19
- package/src/lib/utils.ts +4 -0
- package/src/types/token.ts +1 -0
- package/src/version.ts +2 -1
|
@@ -16,7 +16,8 @@ export type ControlNetName =
|
|
|
16
16
|
| 'segmentation'
|
|
17
17
|
| 'shuffle'
|
|
18
18
|
| 'softedge'
|
|
19
|
-
| 'tile'
|
|
19
|
+
| 'tile'
|
|
20
|
+
| 'instantid';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Raw ControlNet parameters passed to the API
|
|
@@ -53,8 +54,13 @@ export interface ControlNetParams {
|
|
|
53
54
|
name: ControlNetName;
|
|
54
55
|
/**
|
|
55
56
|
* ControlNet input image
|
|
57
|
+
* Supported types:
|
|
58
|
+
* `File` - file object from input[type=file]
|
|
59
|
+
* `Buffer` - Node.js buffer object with image data
|
|
60
|
+
* `Blob` - blob object with image data
|
|
61
|
+
* `true` - indicates that the image is already uploaded to the server
|
|
56
62
|
*/
|
|
57
|
-
image?: File | Buffer | Blob;
|
|
63
|
+
image?: File | Buffer | Blob | boolean;
|
|
58
64
|
/**
|
|
59
65
|
* ControlNet strength 0 to 1. 0 full control to prompt, 1 full control to ControlNet
|
|
60
66
|
*/
|
|
@@ -29,11 +29,17 @@ export interface JobEventBase {
|
|
|
29
29
|
export interface JobInitiating extends JobEventBase {
|
|
30
30
|
type: 'initiating';
|
|
31
31
|
workerName: string;
|
|
32
|
+
positivePrompt?: string;
|
|
33
|
+
negativePrompt?: string;
|
|
34
|
+
jobIndex?: number;
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
export interface JobStarted extends JobEventBase {
|
|
35
38
|
type: 'started';
|
|
36
39
|
workerName: string;
|
|
40
|
+
positivePrompt?: string;
|
|
41
|
+
negativePrompt?: string;
|
|
42
|
+
jobIndex?: number;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
export interface JobProgress extends JobEventBase {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SupernetType } from '../../ApiClient/WebSocketClient/types';
|
|
2
2
|
import { ControlNetParams } from './ControlNetParams';
|
|
3
|
+
import { TokenType } from '../../types/token';
|
|
3
4
|
|
|
4
5
|
export interface SupportedModel {
|
|
5
6
|
id: string;
|
|
@@ -102,12 +103,14 @@ export interface ProjectParams {
|
|
|
102
103
|
*/
|
|
103
104
|
numberOfImages: number;
|
|
104
105
|
/**
|
|
105
|
-
* Generate images based on starting image.
|
|
106
|
+
* Generate images based on the starting image.
|
|
107
|
+
* Supported types:
|
|
106
108
|
* `File` - file object from input[type=file]
|
|
107
|
-
* `Buffer` - buffer object with image data
|
|
109
|
+
* `Buffer` - Node.js buffer object with image data
|
|
108
110
|
* `Blob` - blob object with image data
|
|
111
|
+
* `true` - indicates that the image is already uploaded to the server
|
|
109
112
|
*/
|
|
110
|
-
startingImage?: File | Buffer | Blob;
|
|
113
|
+
startingImage?: File | Buffer | Blob | boolean;
|
|
111
114
|
/**
|
|
112
115
|
* How strong effect of starting image should be. From 0 to 1, default 0.5
|
|
113
116
|
*/
|
|
@@ -141,6 +144,11 @@ export interface ProjectParams {
|
|
|
141
144
|
* ControlNet model parameters
|
|
142
145
|
*/
|
|
143
146
|
controlNet?: ControlNetParams;
|
|
147
|
+
/**
|
|
148
|
+
* Select which tokens to use for the project.
|
|
149
|
+
* If not specified, the Sogni token will be used.
|
|
150
|
+
*/
|
|
151
|
+
tokenType?: TokenType;
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
export type ImageUrlParams = {
|
|
@@ -156,6 +164,10 @@ export interface EstimateRequest {
|
|
|
156
164
|
* Network to use. Can be 'fast' or 'relaxed'
|
|
157
165
|
*/
|
|
158
166
|
network: SupernetType;
|
|
167
|
+
/**
|
|
168
|
+
* Token type
|
|
169
|
+
*/
|
|
170
|
+
tokenType?: TokenType;
|
|
159
171
|
/**
|
|
160
172
|
* Model ID
|
|
161
173
|
*/
|
|
@@ -195,3 +207,5 @@ export interface EstimateRequest {
|
|
|
195
207
|
*/
|
|
196
208
|
height?: number;
|
|
197
209
|
}
|
|
210
|
+
|
|
211
|
+
export type EnhancementStrength = 'light' | 'medium' | 'heavy';
|
package/src/Stats/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import ApiGroup from '../ApiGroup';
|
|
2
|
-
import {
|
|
2
|
+
import { ApiResponse } from '../ApiClient';
|
|
3
3
|
import { LeaderboardItem, LeaderboardParams } from './types';
|
|
4
4
|
|
|
5
5
|
class StatsApi extends ApiGroup {
|
|
6
6
|
async leaderboard(params: LeaderboardParams) {
|
|
7
|
-
const res = await this.client.rest.get<
|
|
7
|
+
const res = await this.client.rest.get<ApiResponse<LeaderboardItem[]>>(
|
|
8
8
|
'/v1/leaderboard/',
|
|
9
9
|
params
|
|
10
10
|
);
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AbstractProvider, JsonRpcProvider, getDefaultProvider } from 'ethers';
|
|
2
1
|
// Account API
|
|
3
2
|
import AccountApi from './Account';
|
|
4
3
|
import CurrentAccount from './Account/CurrentAccount';
|
|
@@ -18,6 +17,7 @@ import { AvailableModel, ProjectParams, Scheduler, TimeStepSpacing } from './Pro
|
|
|
18
17
|
import StatsApi from './Stats';
|
|
19
18
|
// Base Types
|
|
20
19
|
import ErrorData from './types/ErrorData';
|
|
20
|
+
import { TokenType } from './types/token';
|
|
21
21
|
|
|
22
22
|
export type {
|
|
23
23
|
AvailableModel,
|
|
@@ -29,7 +29,8 @@ export type {
|
|
|
29
29
|
ProjectStatus,
|
|
30
30
|
Scheduler,
|
|
31
31
|
SupernetType,
|
|
32
|
-
TimeStepSpacing
|
|
32
|
+
TimeStepSpacing,
|
|
33
|
+
TokenType
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
export { ApiError, CurrentAccount, Job, Project };
|
|
@@ -49,6 +50,13 @@ export interface SogniClientConfig {
|
|
|
49
50
|
* @internal
|
|
50
51
|
*/
|
|
51
52
|
socketEndpoint?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Disable WebSocket connection. Useful for testing or when WebSocket is not needed.
|
|
55
|
+
* Note that many may not work without WebSocket connection.
|
|
56
|
+
* @experimental
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
disableSocket?: boolean;
|
|
52
60
|
/**
|
|
53
61
|
* Which network to use after logging in. Can be 'fast' or 'relaxed'
|
|
54
62
|
*/
|
|
@@ -62,10 +70,6 @@ export interface SogniClientConfig {
|
|
|
62
70
|
* @default 'warn'
|
|
63
71
|
**/
|
|
64
72
|
logLevel?: LogLevel;
|
|
65
|
-
/**
|
|
66
|
-
* If provided, the client will connect to this JSON-RPC endpoint to interact with the blockchain
|
|
67
|
-
*/
|
|
68
|
-
jsonRpcUrl?: string;
|
|
69
73
|
/**
|
|
70
74
|
* If true, the client will connect to the testnet. Ignored if jsonRpcUrl is provided
|
|
71
75
|
*/
|
|
@@ -92,7 +96,7 @@ export class SogniClient {
|
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
/**
|
|
95
|
-
*
|
|
99
|
+
* Create client instance, with default configuration
|
|
96
100
|
* @param config
|
|
97
101
|
*/
|
|
98
102
|
static async createInstance(config: SogniClientConfig): Promise<SogniClient> {
|
|
@@ -100,21 +104,21 @@ export class SogniClient {
|
|
|
100
104
|
const socketEndpoint = config.socketEndpoint || 'wss://socket.sogni.ai';
|
|
101
105
|
const network = config.network || 'fast';
|
|
102
106
|
const logger = config.logger || new DefaultLogger(config.logLevel || 'warn');
|
|
103
|
-
const isTestnet = config.testnet !== undefined ? config.testnet :
|
|
107
|
+
const isTestnet = config.testnet !== undefined ? config.testnet : false;
|
|
104
108
|
|
|
105
|
-
const client = new ApiClient(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
const client = new ApiClient(
|
|
110
|
+
restEndpoint,
|
|
111
|
+
socketEndpoint,
|
|
112
|
+
config.appId,
|
|
113
|
+
network,
|
|
114
|
+
logger,
|
|
115
|
+
config.disableSocket
|
|
116
|
+
);
|
|
113
117
|
const eip712 = new EIP712Helper({
|
|
114
|
-
name: 'Sogni-testnet',
|
|
118
|
+
name: isTestnet ? 'Sogni-testnet' : 'Sogni AI',
|
|
115
119
|
version: '1',
|
|
116
|
-
chainId:
|
|
120
|
+
chainId: isTestnet ? '84532' : '8453'
|
|
117
121
|
});
|
|
118
|
-
return new SogniClient({ client,
|
|
122
|
+
return new SogniClient({ client, eip712 });
|
|
119
123
|
}
|
|
120
124
|
}
|
package/src/lib/utils.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TokenType = 'sogni' | 'spark';
|
package/src/version.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { version } from '../package.json';
|
|
2
|
+
export const LIB_VERSION = version;
|