🤖 Merge PR #62105 [deepai] Add Types by @NicolasNewman

* feat(@types/deepai): added types for deepai

* refactor: fixed linting errors

* Update types/deepai/index.d.ts

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>

* Update types/deepai/index.d.ts

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>

* Update types/deepai/index.d.ts

Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
This commit is contained in:
Nicolas Newman
2022-09-06 10:10:43 -04:00
committed by GitHub
parent 04799b1419
commit eea4daba2d
4 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { callStandardApi, setApiKey } from 'deepai';
// $ExpectedType void
setApiKey('');
// $ExpectedType Promise<{id: string, output_url: string}>
callStandardApi('torch-srgan', {image: 'foo.jpg'});
// @ts-expect-error
callStandardApi('torch-srgan', {});
// @ts-expect-error
callStandardApi('foobar', {});

40
types/deepai/index.d.ts vendored Normal file
View File

@@ -0,0 +1,40 @@
// Type definitions for deepai 1.0
// Project: https://deepai.org/
// Definitions by: Nicolas Newman <https://github.com/NicolasNewman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace deepai;
export type Models = 'colorizer'
| 'text2img'
| 'text-generator'
| 'torch-srgan'
| 'waifu2x'
| 'nsfw-detector'
| 'toonify'
| 'image-similarity'
| 'deepdream'
| 'summarization'
| 'sentiment-analysis'
| 'text-tagging';
export interface ModelInputs {
'colorizer': {image: string};
'text2img': {text: string};
'text-generator': {text: string};
'torch-srgan': {image: string};
'waifu2x': {image: string};
'nsfw-detector': {image: string};
'toonify': {image: string};
'image-similarity': {image1: string, image2: string};
'deepdream': {image: string};
'summarization': {text: string};
'sentiment-analysis': {text: string};
'text-tagging': {text: string};
}
export interface ModelOutputs {
'torch-srgan': {id: string, output_url: string};
[key: string]: any;
}
export function setApiKey(apiKey: string): void;
/** @async */
export function callStandardApi<T extends Models>(modelName: T, inputs_object: ModelInputs[T]): Promise<ModelOutputs[T]>;

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"deepai-tests.ts"
]
}

1
types/deepai/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "@definitelytyped/dtslint/dt.json" }