Skip to content

Commit

Permalink
update import paths
Browse files Browse the repository at this point in the history
  • Loading branch information
HaruHunab1320 committed Jul 16, 2024
1 parent 066f448 commit 24d9a07
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 94 deletions.
11 changes: 0 additions & 11 deletions packages/cloud/next/keywords/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions packages/cloud/next/keywords/project.json

This file was deleted.

13 changes: 4 additions & 9 deletions packages/plugins/core/src/lib/config/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const corePluginCredentials = [
pluginName: corePluginName,
},
{
name: 'PERPLEXITY_API_KEY',
name: 'PERPLEXITYAI_API_KEY',
serviceType: 'perplexity',
credentialType: 'plugin',
clientName: 'Perplexity',
Expand Down Expand Up @@ -89,7 +89,7 @@ export const corePluginCredentials = [
pluginName: corePluginName,
},
{
name: 'TOGETHERAI_API_KEY',
name: 'TOGETHER_API_KEY',
serviceType: 'togetherai',
credentialType: 'plugin',
clientName: 'TogetherAI',
Expand Down Expand Up @@ -125,7 +125,7 @@ export const corePluginCredentials = [
pluginName: corePluginName,
},
{
name: 'OPENROUTER_API_KEY',
name: 'OPEN_ROUTER_API_KEY',
serviceType: 'openrouter',
credentialType: 'plugin',
clientName: 'OpenRouter',
Expand Down Expand Up @@ -293,7 +293,7 @@ export const corePluginCredentials = [
pluginName: corePluginName,
},
{
name: 'VERTEXAI_API_KEY',
name: 'GOOGLE_VERTEX_AI_API_KEY',
serviceType: 'vertexai',
credentialType: 'plugin',
clientName: 'VertexAI',
Expand All @@ -313,8 +313,3 @@ export type CorePluginCredentialNames = ExtractPluginCredentialNames<
export type CorePluginCredentialsKeys = {
[K in CorePluginCredentialNames]: string | undefined
}

// export type CorePluginCredentials = Record<
// CorePluginCredentialNames,
// string | undefined
// >
14 changes: 13 additions & 1 deletion packages/server/agents-v2/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ const config: Config = {
preset: '../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]sx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
'^.+\\.[tj]sx?$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.spec.json',
useESM: true,
},
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../../coverage/packages/server/agents-v2',
Expand All @@ -14,6 +20,12 @@ const config: Config = {
'^@/(.*)$': '<rootDir>/src/$1',
},
testPathIgnorePatterns: ['/node_modules/', '/__tests__/unit/'],
extensionsToTreatAsEsm: ['.ts'],
globals: {
'ts-jest': {
useESM: true,
},
},
}

export default config
2 changes: 1 addition & 1 deletion packages/server/agents-v2/src/lib/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Agent extends EventEmitterWrapper<AgentEvents> {
// Here we create a new event emitter from a passed in config dependency.
// We extended from the EventEmitterWrapper class to enable custom event emitters we extend from.

console.log('EVENT EMITFER', config)
console.log('EVENT EMITTER', config)
const eventEmitter =
new config.dependencies.eventEmitter() as TypedEmitter<AgentEvents>
super(eventEmitter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { RedisPubSub } from '../dependencies/redisPubSub'
import { KeywordsLLMService as LLMService } from '../services/LLMService/KeywordsLLMService'
import { TypedEmitter } from 'tiny-typed-emitter'
import { DefaultDependenciesType } from '../interfaces/IDependencies'
import { CredentialManager } from '../services/credentialsManager/credentialsManager'

// Default implementations for the services
export const DEFAULT_DEPENDENCIES: DefaultDependenciesType = {
Expand All @@ -15,5 +16,6 @@ export const DEFAULT_DEPENDENCIES: DefaultDependenciesType = {
eventEmitter: TypedEmitter,
// database: DatabaseService,
eventStore: EventStore,
LLMService: LLMService,
coreLLMService: LLMService,
credentialManager: CredentialManager,
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ISpellStorage } from '../interfaces/ISpellStorage'
import { ICommandHub } from '../interfaces/ICommandHub'
import { ServiceType } from '../interfaces/IDependencies'
import { ILLMService } from '../interfaces/ILLMService'
import { ICredentialManager } from '../interfaces/ICredentialsManager'

/**
* This is the central source of truth for all dependencies that are available.
Expand All @@ -29,7 +30,8 @@ export const DependencyInterfaces = {
EventEmitter: {} as IEventEmitter,
SpellStorage: {} as ISpellStorage,
CommandHub: {} as ICommandHub,
LLMService: {} as ILLMService,
coreLLMService: {} as ILLMService,
CredentialManager: {} as ICredentialManager,
// We can also just use this to add key:value types for later access
['Factory<EventStore>']: {} as unknown,
// ... other services
Expand All @@ -47,7 +49,8 @@ export const CONFIG_TO_SERVICE_MAP = {
// database: { useSingleton: true, service: 'Database' },
eventStore: { useSingleton: false, service: 'EventStore' },
eventEmitter: { useSingleton: true, service: 'EventEmitter' },
LLMService: { useSingleton: true, service: 'LLMService' },
coreLLMService: { useSingleton: true, service: 'LLMService' },
credentialManager: { useSingleton: true, service: 'CredentialManager' },
// ... other mappings
} as const

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Prisma } from '../../../../db/src'
import { Prisma } from '@magickml/server-db'

export type Credential = Prisma.$credentialsPayload['scalars']

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { createOpenAI } from '@magickml/vercel-sdk-core'

import { KeywordsLLMService } from './KeywordsLLMService' // Adjust the import path as needed
import { KeywordsService } from '../../../../../../cloud/next/keywords/src' // Adjust the import path as needed
import { createOpenAI } from '../../../../../vercel/core/src/lib/magick-openai/src' // Adjust the import path as needed

import { z } from 'zod'
import {
GenerateObjectResult,
GenerateObjectRequest,
} from '../../../../../../shared/llm-service-types/src' // Adjust the import path as needed
import { z } from 'zod'
import { StreamObjectRequest } from '../../../../../../shared/llm-service-types/src' // Adjust the import path as needed
GenerateObjectResult,
StreamObjectRequest,
} from '@magickml/llm-service-types'
import { KeywordsService } from '@magickml/keywords-service'

// Mock the dependencies
jest.mock('../../../../../../cloud/next/keywords/src')
jest.mock('../../../../../vercel/core/src/lib/magick-openai/src')
jest.mock('@magickml/keywords-service')
jest.mock('@magickml/vercel-sdk-core')
jest.mock('ai')

describe('KeywordsLLMService', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {
DeepPartial,
} from 'ai'

import {
ILLMService,
ExtensibleLanguageModelProvider,
} from '../../interfaces/ILLMService'
import { KeywordsService } from '@magickml/keywords-service'
import { createOpenAI } from '@magickml/vercel-sdk-core'
import {
CoreTool,
ExtensibleLanguageModel,
Expand All @@ -17,13 +23,7 @@ import {
StreamObjectReturn,
StreamObjectYield,
StreamTextReturn,
} from '../../../../../../shared/llm-service-types/src'
import {
ILLMService,
ExtensibleLanguageModelProvider,
} from '../../interfaces/ILLMService'
import { KeywordsService } from '../../../../../../cloud/next/keywords/src'
import { createOpenAI } from '../../../../../vercel/core/src/lib/magick-openai/src'
} from '@magickml/llm-service-types'

type KeywordsModel = {
model_name: string
Expand Down Expand Up @@ -106,7 +106,6 @@ export class KeywordsLLMService implements ILLMService {
if (!provider || !customerIdentifier) {
throw new Error('Provider, apiKey, and customerIdentifier are required')
}
console.log('api key', process.env['KEYWORDS_API_KEY'])
const openai = createOpenAI({
baseURL: 'https://api.keywordsai.co',
apiKey: 'QnVif7uB.zeRJatZvTRWe9yABP8nx4ZCeuJuTsxQ3',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { CREDENTIALS_ENCRYPTION_KEY } from '../../../../../config/src'
import { decrypt, encrypt } from '../../../../../credentials/src'
import { prismaCore } from '../../../../../db/src'
import { prismaCore } from '@magickml/server-db'
import {
CredentialKeyValuePair,
ICredentialManager,
Credential,
} from '../../interfaces/ICredentialsManager'
import { decrypt, encrypt } from '@magickml/credentials'
import { CREDENTIALS_ENCRYPTION_KEY } from '@magickml/server-config'

export class CredentialManager implements ICredentialManager {
protected projectId: string
Expand Down
9 changes: 3 additions & 6 deletions packages/server/agents-v2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "bundler",
"esModuleInterop": true,
"downlevelIteration": true,
"experimentalDecorators": true,
"allowImportingTsExtensions": true,
"emitDeclarationOnly": true,
"target": "es2021",
"types": ["node"],
"emitDeclarationOnly": true
},
"files": [],
"include": [],
Expand All @@ -19,5 +16,5 @@
{
"path": "./tsconfig.spec.json"
}
],
]
}
3 changes: 1 addition & 2 deletions packages/server/config/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
import { config } from 'dotenv-flow'
// import { importMetaEnv } from '../../../client/config/src/lib/import-meta-env'
import { v4 } from 'uuid'
import { importMetaEnv } from './import-meta-env'

// Load environment variables
config({
path: '../../../.env.*',
})

// Check whether "process" is defined or not, and assign the appropriate environment object.
const processEnv = typeof process === 'undefined' ? importMetaEnv : process.env
const processEnv = process?.env

/**
* Get an environment variable value for the given key.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["../../../../.eslintrc.json"],
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
Expand Down
11 changes: 11 additions & 0 deletions packages/server/keywords/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# server-keywords

This library was generated with [Nx](https://nx.dev).

## Building

Run `nx build server-keywords` to build the library.

## Running unit tests

Run `nx test server-keywords` to execute the unit tests via [Jest](https://jestjs.io).
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable */
export default {
displayName: 'keywords',
preset: '../../../../jest.preset.js',
displayName: 'server-keywords',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../../coverage/packages/cloud/next/keywords',
coverageDirectory: '../../../coverage/packages/server/keywords',
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@magickml/keywords",
"name": "@magickml/keywords-service",
"version": "0.0.1",
"dependencies": {
"tslib": "^2.3.0"
Expand Down
31 changes: 31 additions & 0 deletions packages/server/keywords/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "server/keywords",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/server/keywords/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/packages/server/keywords",
"tsConfig": "packages/server/keywords/tsconfig.lib.json",
"packageJson": "packages/server/keywords/package.json",
"main": "packages/server/keywords/src/index.ts",
"assets": ["packages/server/keywords/*.md"]
}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "packages/server/keywords/jest.config.ts"
}
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../../tsconfig.base.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../../../dist/out-tsc",
"outDir": "../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../../dist/out-tsc",
"outDir": "../../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
Expand Down
2 changes: 1 addition & 1 deletion portal/cloud
Submodule cloud updated from b4f308 to 84bf5a
Loading

0 comments on commit 24d9a07

Please sign in to comment.