Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the modules with controllers were modified to be dynamic #85

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arodriguezcb
Copy link

@arodriguezcb arodriguezcb commented Dec 16, 2024

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Currently, modules are loaded as singletons and with static paths, which makes it difficult to use multiple assistants configurations.

Issue Number: N/A

What is the new behavior?

Modules are created dynamically and a prefix is added to modify the paths of each loaded assitant.

  • Yes
  • No

Other information

@arodriguezcb arodriguezcb force-pushed the feature/dynamic-modules branch from 2339996 to f1391ff Compare December 16, 2024 18:46
Copy link
Member

@sebastianmusial sebastianmusial left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much, @arodriguezcb, for your contributions to the project! 🎉 I'm really excited about the new features. Please take a look at my comments and let me know if you have some questions. 🙌

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to changes in this file when I run npm run start:dev command I receive error:
"The Nx Daemon is unsupported in WebAssembly environments. Some things may be slower than or not function as expected."

@@ -5,7 +5,7 @@ import { AgentsModule } from './agents/agents.module';
import { ChatSockets } from './chat.sockets';

@Module({
imports: [AgentsModule, AssistantModule.forRoot(assistantConfig)],
imports: [AgentsModule, AssistantModule.register(assistantConfig)],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the readme file:

  • forRoot -> register
  • new property in the configuration

@@ -13,10 +13,13 @@ export const assistantParams: AssistantCreateParams = {
export const assistantConfig: AssistantConfigParams = {
id: process.env['ASSISTANT_ID'] || '',
params: assistantParams,
assistantPrefix: 'assistant-prefix',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put default assistant-prefix as an "optional" value - empty string?

@@ -13,10 +13,13 @@ export const assistantParams: AssistantCreateParams = {
export const assistantConfig: AssistantConfigParams = {
id: process.env['ASSISTANT_ID'] || '',
params: assistantParams,
assistantPrefix: 'assistant-prefix',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image Please check my screenshot, It looks like we have multiple instances instead of one with the prefix 🤔

In my opinion we should have only once instance and decide if we would like have prefix or not.

import { AiService } from './ai.service';
import { AiController } from './ai.controller';
import { createControllerWithPrefix } from '../../utils/controllers';

@Module({
providers: [AiService],
controllers: [AiController],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we have multiple controllers, please remove it.

import { FilesService } from './files.service';
import { FilesController } from './files.controller';
import { AiModule } from '../ai';
import { createControllerWithPrefix } from '../../utils/controllers';

@Module({
imports: [AiModule],
providers: [FilesService],
controllers: [FilesController],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we have multiple controllers, please remove it.

import { ThreadsController } from './threads.controller';
import { ThreadsService } from './threads.service';
import { AiModule } from '../ai';
import { createControllerWithPrefix } from '../../utils/controllers';

@Module({
imports: [AiModule],
providers: [ThreadsService],
controllers: [ThreadsController],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case we have multiple controllers, please remove it.


expect(originalPath).toBe('test');

expect(prefixedPath).toBe('api/test');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't image the case that we would like to keep both version - with and without prefix. IMO user should be able to decide and select only one option by providing prefix or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants