This repository was archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
146e645
commit b42c9e1
Showing
26 changed files
with
282 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/akeru-server/src/core/application/controllers/assistant/assistantController.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/akeru-server/src/core/application/controllers/userController.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/akeru-server/src/core/application/services/assistantService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/akeru-server/src/core/application/services/messageService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/akeru-server/src/core/application/services/threadService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/akeru-server/src/core/application/services/tokenService.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
69 changes: 0 additions & 69 deletions
69
packages/akeru-server/src/infrastructure/adaptaters/adaptermanager.ts
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
packages/akeru-server/src/infrastructure/adaptaters/openai/gpt4Adapter.test.ts
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
packages/akeru-server/src/infrastructure/adaptaters/openai/gpt4Adapter.ts
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
packages/akeru-server/src/infrastructure/adapters/AdapterManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { BaseAdapter, StreamableAdapter } from "./BaseAdapter"; | ||
import { SupportedModels } from "./adapter"; | ||
import { GPTAdapter } from "./openai/GPTAdapter"; | ||
import { GPTModels } from "./openai/models"; | ||
|
||
/** | ||
* The AdapterManager is used to decide what adapter to use for a given assistant | ||
* @param StreamableAdapter - The adapter that is used to generate a streamable response | ||
* @param Adapters - The adapter that is used to generate a single response | ||
* @returns The AdapterManager instance | ||
*/ | ||
export class AdapterManager { | ||
|
||
private StreamableAdapter: Map<SupportedModels, StreamableAdapter> = new Map(); | ||
private Adapters: Map<SupportedModels, BaseAdapter> = new Map(); | ||
public static instance: AdapterManager = new AdapterManager(); | ||
|
||
constructor(){ | ||
this.initStreamableAdapter(); | ||
this.initAdapters(); | ||
} | ||
|
||
/** | ||
* Initialize the StreamableAdapter | ||
* Sets all the streamable adapters that are available | ||
*/ | ||
private initStreamableAdapter() { | ||
this.StreamableAdapter.set("gpt-4", new GPTAdapter("gpt-4")); | ||
this.StreamableAdapter.set("gpt-3.5-turbo", new GPTAdapter("gpt-3.5-turbo")); | ||
this.StreamableAdapter.set("gpt-4-turbo-preview", new GPTAdapter("gpt-4-turbo-preview")); | ||
} | ||
|
||
/** | ||
* Initialize the Adapters | ||
* Sets all the adapters that are available, that does not support streamable responses | ||
*/ | ||
private initAdapters() { | ||
this.Adapters.set("gpt-4", new GPTAdapter("gpt-4")); | ||
this.Adapters.set("gpt-3.5-turbo", new GPTAdapter("gpt-3.5-turbo")); | ||
this.Adapters.set("gpt-4-turbo-preview", new GPTAdapter("gpt-4-turbo-preview")); | ||
} | ||
|
||
public getStreamableAdapter(adapterName: SupportedModels): StreamableAdapter | undefined { | ||
return this.StreamableAdapter.get(adapterName); | ||
} | ||
public getBaseAdapter(adapterName: SupportedModels): BaseAdapter | undefined { | ||
return this.Adapters.get(adapterName); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/akeru-server/src/infrastructure/adapters/BaseAdapter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { AdapterRequest } from "./adapter"; | ||
|
||
export interface StreamableAdapter { | ||
generateStreamableResponse(args: AdapterRequest): Promise<string>; | ||
} | ||
|
||
/** | ||
* BaseAdapter defines the interface for any Adapters that we have without defining the implementation. | ||
*/ | ||
export abstract class BaseAdapter { | ||
|
||
abstract adapterName: string; | ||
abstract adapterDescription: string; | ||
|
||
/** | ||
* Based on a set of roles and content, generate a response. | ||
* @param everyRoleAndContent - An array of roles and content. | ||
* @param instruction - The instruction given to the assistant. | ||
*/ | ||
abstract generateSingleResponse(args: AdapterRequest): Promise<string>; | ||
|
||
/** | ||
* Based on the attributes of the adapter return the response of the adapter. | ||
* This implementation can vary from adapters, for instance OpenAI adapters have their own endpoints that can be called. | ||
* @returns Any object that contains the information of the adapter. | ||
*/ | ||
abstract getAdapterInformation(): Object; | ||
} |
Oops, something went wrong.