Skip to content

Commit

Permalink
Merge pull request #114 from Portkey-AI/feat/lint-prettier
Browse files Browse the repository at this point in the history
Linting + Prettier
  • Loading branch information
VisargD authored Oct 10, 2024
2 parents c4a7489 + a0d30fd commit 20b71de
Show file tree
Hide file tree
Showing 38 changed files with 4,023 additions and 3,536 deletions.
19 changes: 18 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,24 @@ module.exports = {
"plugin:@typescript-eslint/recommended",
"prettier",
],
ignorePatterns: [
'**/node_modules/',
'**/dist/',
'**/*.test.js',
'**/examples/*',
'**/src/index.ts',
'**/src/error.ts',
'**/src/streaming.ts',
],
rules: {
'no-unused-vars': 'off',
"no-case-declarations": "warn",
"no-console": "warn",
"no-duplicate-imports": "error",
"@typescript-eslint/no-unused-vars": "error",
"prefer-const": "error",
"@typescript-eslint/no-explicit-any": "off",
'no-undef': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
}
};
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"semi": true,
"tabWidth": 2,
"printWidth": 80,
"endOfLine": "lf",
"singleQuote": true,
"arrowParens": "always",
"bracketSpacing": true,
"trailingComma": "es5"
}

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"scripts": {
"test": "jest",
"build": "bash ./build",
"lint": "eslint --ext ts,js .",
"fix": "eslint --fix --ext ts,js ."
"format:check": "prettier --check \"src/**/*.ts\"",
"format": "prettier --write \"src/**/*.ts\"",
"lint:check": "eslint --ext ts,js .",
"lint:fix": "eslint --fix --ext ts,js ."
},
"imports": {
"portkey-ai": ".",
Expand Down
70 changes: 35 additions & 35 deletions src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
export type Headers = Record<string, string | null | undefined>
export type Headers = Record<string, string | null | undefined>;

export interface ApiClientInterface {
apiKey?: string | null;
baseURL?: string | null;
virtualKey?: string | null | undefined;
config?: Record<string, unknown> | string | null | undefined;
provider?: string | null | undefined;
traceID?: string | null | undefined;
metadata?: Record<string, unknown> | null | undefined;
Authorization?: string | null | undefined;
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined;
openaiProject?: string | null | undefined;
openaiOrganization?: string | null | undefined;
awsSecretAccessKey?: string | null | undefined;
awsAccessKeyId?: string | null | undefined;
awsSessionToken?: string | null | undefined;
awsRegion?: string | null | undefined;
vertexProjectId?: string | null | undefined;
vertexRegion?: string | null | undefined;
workersAiAccountId?: string | null | undefined;
azureResourceName?: string | null | undefined;
azureDeploymentId?: string | null | undefined;
azureApiVersion?: string | null | undefined;
azureEndpointName?: string | null | undefined;
huggingfaceBaseUrl?: string | null | undefined;
forwardHeaders?: Array<string> | null | undefined;
cacheNamespace?: string | null | undefined;
requestTimeout?: number | null | undefined;
strictOpenAiCompliance?: boolean | null | undefined;
anthropicBeta?: string | null | undefined;
anthropicVersion?: string | null | undefined;
mistralFimCompletion?: string | null | undefined;
apiKey?: string | null;
baseURL?: string | null;
virtualKey?: string | null | undefined;
config?: Record<string, unknown> | string | null | undefined;
provider?: string | null | undefined;
traceID?: string | null | undefined;
metadata?: Record<string, unknown> | null | undefined;
Authorization?: string | null | undefined;
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined;
openaiProject?: string | null | undefined;
openaiOrganization?: string | null | undefined;
awsSecretAccessKey?: string | null | undefined;
awsAccessKeyId?: string | null | undefined;
awsSessionToken?: string | null | undefined;
awsRegion?: string | null | undefined;
vertexProjectId?: string | null | undefined;
vertexRegion?: string | null | undefined;
workersAiAccountId?: string | null | undefined;
azureResourceName?: string | null | undefined;
azureDeploymentId?: string | null | undefined;
azureApiVersion?: string | null | undefined;
azureEndpointName?: string | null | undefined;
huggingfaceBaseUrl?: string | null | undefined;
forwardHeaders?: Array<string> | null | undefined;
cacheNamespace?: string | null | undefined;
requestTimeout?: number | null | undefined;
strictOpenAiCompliance?: boolean | null | undefined;
anthropicBeta?: string | null | undefined;
anthropicVersion?: string | null | undefined;
mistralFimCompletion?: string | null | undefined;
}

export interface APIResponseType {
getHeaders: () => Record<string, string> | null | undefined
}
getHeaders: () => Record<string, string> | null | undefined;
}
76 changes: 38 additions & 38 deletions src/_types/portkeyConstructs.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
export interface RetrySettings {
attempts: number;
on_status_codes: Array<number>
attempts: number;
on_status_codes: Array<number>;
}

export interface FunctionInterface {
name: string;
description: string;
parameters: string;
name: string;
description: string;
parameters: string;
}

export interface ModelParams {
model?: string;
suffix?: string;
max_tokens?: number;
temperature?: number;
top_k?: number;
top_p?: number;
n?: number;
stop_sequences?: Array<any>;
timeout?: number;
functions?: Array<FunctionInterface>;
function_call?: string | FunctionInterface;
logprobs?: number;
echo?: boolean;
stop?: Array<string>;
presence_penalty?: number;
frequency_penalty?: number;
best_of?: number;
logit_bias?: Record<string, number>;
user?: string;
organization?: string;
seed?: number;
response_format?: any;
service_tier?: string;
top_logprobs?: number | null;
parallel_tool_calls?: boolean;
tools?: Array<Tool>;
tool_choice?: any;
[key: string]: any;
model?: string;
suffix?: string;
max_tokens?: number;
temperature?: number;
top_k?: number;
top_p?: number;
n?: number;
stop_sequences?: Array<any>;
timeout?: number;
functions?: Array<FunctionInterface>;
function_call?: string | FunctionInterface;
logprobs?: number;
echo?: boolean;
stop?: Array<string>;
presence_penalty?: number;
frequency_penalty?: number;
best_of?: number;
logit_bias?: Record<string, number>;
user?: string;
organization?: string;
seed?: number;
response_format?: any;
service_tier?: string;
top_logprobs?: number | null;
parallel_tool_calls?: boolean;
tools?: Array<Tool>;
tool_choice?: any;
[key: string]: any;
}

export interface Message {
role: string
content: string
role: string;
content: string;
}

export interface Tool {
type?: string;
function?: Record<string, any>
}
type?: string;
function?: Record<string, any>;
}
28 changes: 14 additions & 14 deletions src/apiResource.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import type { Portkey } from "./index";
import type { Portkey } from './index';

export class ApiResource {
protected client: Portkey;
protected post: Portkey["_post"]
protected put: Portkey["_put"]
protected getMethod: Portkey["_get"]
protected deleteMethod: Portkey["_delete"]
protected client: Portkey;
protected post: Portkey['_post'];
protected put: Portkey['_put'];
protected getMethod: Portkey['_get'];
protected deleteMethod: Portkey['_delete'];

constructor(client: Portkey) {
this.client = client
this.post = client._post.bind(client)
this.put = client._put.bind(client)
this.getMethod = client._get.bind(client)
this.deleteMethod = client._delete.bind(client) // delete is a reserved word
}
}
constructor(client: Portkey) {
this.client = client;
this.post = client._post.bind(client);
this.put = client._put.bind(client);
this.getMethod = client._get.bind(client);
this.deleteMethod = client._delete.bind(client); // delete is a reserved word
}
}
Loading

0 comments on commit 20b71de

Please sign in to comment.