Skip to content

Commit

Permalink
Merge pull request #521 from narengogi/cleanup
Browse files Browse the repository at this point in the history
Remove a few unused variables
  • Loading branch information
VisargD authored Aug 22, 2024
2 parents 38b4c69 + 3691071 commit 82a7f80
Show file tree
Hide file tree
Showing 16 changed files with 12 additions and 33 deletions.
2 changes: 1 addition & 1 deletion plugins/aporia/validateProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
PluginHandler,
PluginParameters,
} from '../types';
import { getText, post } from '../utils';
import { post } from '../utils';

export const APORIA_BASE_URL = 'https://gr-prd.aporia.com';

Expand Down
3 changes: 1 addition & 2 deletions src/handlers/handlerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ import {
} from '../types/requestBody';
import { convertKeysToCamelCase } from '../utils';
import { retryRequest } from './retryHandler';
import { env } from 'hono/adapter';
import { env, getRuntimeKey } from 'hono/adapter';
import { afterRequestHookHandler, responseHandler } from './responseHandlers';
import { getRuntimeKey } from 'hono/adapter';
import { HookSpan, HooksManager } from '../middlewares/hooks';

/**
Expand Down
3 changes: 1 addition & 2 deletions src/handlers/proxyGetHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, HonoRequest } from 'hono';
import { Context } from 'hono';
import { retryRequest } from './retryHandler';
import Providers from '../providers';
import {
Expand All @@ -7,7 +7,6 @@ import {
HEADER_KEYS,
RETRY_STATUS_CODES,
POWERED_BY,
RESPONSE_HEADER_KEYS,
AZURE_OPEN_AI,
} from '../globals';
import { updateResponseHeaders } from './handlerUtils';
Expand Down
1 change: 0 additions & 1 deletion src/providers/azure-openai/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Options } from '../../types/requestBody';
import { ProviderAPIConfig } from '../types';

const AzureOpenAIAPIConfig: ProviderAPIConfig = {
Expand Down
1 change: 0 additions & 1 deletion src/providers/bedrock/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Options } from '../../types/requestBody';
import { ProviderAPIConfig } from '../types';
import { generateAWSHeaders } from './utils';

Expand Down
4 changes: 0 additions & 4 deletions src/providers/fireworks-ai/imageGenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ interface FireworksAIImageObject {
['X-Fireworks-Billing-Idempotency-Id']: string;
}

interface FireworksAIImageGenerateResponse extends ImageGenerateResponse {
data: FireworksAIImageObject[];
}

export const FireworksAIImageGenerateResponseTransform: (
response:
| FireworksAIImageObject[]
Expand Down
3 changes: 1 addition & 2 deletions src/providers/google-vertex-ai/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Options } from '../../types/requestBody';
import { ProviderAPIConfig } from '../types';
import { getModelAndProvider } from './utils';
import { getAccessToken } from './utils';
import { getModelAndProvider, getAccessToken } from './utils';

const getProjectRoute = (
providerOptions: Options,
Expand Down
4 changes: 2 additions & 2 deletions src/providers/google/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export const GoogleChatCompleteResponseTransform: (
model: 'Unknown',
provider: 'google',
choices:
response.candidates?.map((generation, index) => {
response.candidates?.map((generation) => {
let message: Message = { role: 'assistant', content: '' };
if (generation.content.parts[0]?.text) {
message = {
Expand Down Expand Up @@ -459,7 +459,7 @@ export const GoogleChatCompleteStreamChunkTransform: (
model: '',
provider: 'google',
choices:
parsedChunk.candidates?.map((generation, index) => {
parsedChunk.candidates?.map((generation) => {
let message: Message = { role: 'assistant', content: '' };
if (generation.content.parts[0]?.text) {
message = {
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ollama/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface OllamaErrorResponse {
export const OllamaEmbedResponseTransform: (
response: OllamaEmbedResponse | OllamaErrorResponse,
responseStatus: number
) => EmbedResponse | ErrorResponse = (response, responseStatus) => {
) => EmbedResponse | ErrorResponse = (response) => {
if ('error' in response) {
return generateErrorResponse(
{ message: response.error, type: null, param: null, code: null },
Expand Down
2 changes: 1 addition & 1 deletion src/providers/palm/embed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PALM } from '../../globals';
import { EmbedParams, EmbedResponse } from '../../types/embedRequestBody';
import { EmbedResponse } from '../../types/embedRequestBody';
import {
GoogleErrorResponse,
GoogleErrorResponseTransform,
Expand Down
2 changes: 1 addition & 1 deletion src/providers/perplexity-ai/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export interface PerplexityAIChatCompletionStreamChunk {
export const PerplexityAIChatCompleteResponseTransform: (
response: PerplexityAIChatCompleteResponse | PerplexityAIErrorResponse,
responseStatus: number
) => ChatCompletionResponse | ErrorResponse = (response, responseStatus) => {
) => ChatCompletionResponse | ErrorResponse = (response) => {
if ('error' in response) {
return generateErrorResponse(
{
Expand Down
4 changes: 2 additions & 2 deletions src/providers/reka-ai/chatComplete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { REKA_AI } from '../../globals';
import { Message, Params } from '../../types/requestBody';
import { Params } from '../../types/requestBody';
import {
ChatCompletionResponse,
ErrorResponse,
Expand Down Expand Up @@ -145,7 +145,7 @@ export interface RekaAIErrorResponse {
export const RekaAIChatCompleteResponseTransform: (
response: RekaAIChatCompleteResponse | RekaAIErrorResponse,
responseStatus: number
) => ChatCompletionResponse | ErrorResponse = (response, responseStatus) => {
) => ChatCompletionResponse | ErrorResponse = (response) => {
if ('detail' in response) {
return generateErrorResponse(
{
Expand Down
2 changes: 1 addition & 1 deletion src/providers/workers-ai/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const WorkersAiAPIConfig: ProviderAPIConfig = {
const { apiKey } = providerOptions;
return { Authorization: `Bearer ${apiKey}` };
},
getEndpoint: ({ providerOptions, fn, gatewayRequestBody: params }) => {
getEndpoint: ({ fn, gatewayRequestBody: params }) => {
const { model } = params;
switch (fn) {
case 'complete': {
Expand Down
1 change: 0 additions & 1 deletion src/providers/workers-ai/chatComplete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { WORKERS_AI } from '../../globals';
import { Params, Message } from '../../types/requestBody';
import {
ChatCompletionResponse,
ErrorResponse,
Expand Down
10 changes: 0 additions & 10 deletions src/services/transformToProviderRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ function setNestedProperty(obj: any, path: string, value: any) {
current[parts[parts.length - 1]] = value;
}

function setArrayNestedProperties(
obj: any,
path: Array<string>,
value: Array<any>
) {
for (let i = 0; i < path.length; i++) {
setNestedProperty(obj, path[i], value[i]);
}
}

/**
* Transforms the request body to match the structure required by the AI provider.
* It also ensures the values for each parameter are within the minimum and maximum
Expand Down
1 change: 0 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
GOOGLE_VERTEX_AI,
PERPLEXITY_AI,
DEEPINFRA,
OLLAMA,
} from './globals';
import { Params } from './types/requestBody';

Expand Down

0 comments on commit 82a7f80

Please sign in to comment.