-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Vertex AI in chatbot and service layers - Introduced Vertex AI as a new provider option in the chatbot and service layers. - Updated environment variable checks to include GOOGLE_PROJECT_ID. - Enhanced .gitignore to exclude additional file types. - Added VertexAIService class for handling interactions with Vertex AI. - Updated LLM interfaces and factory to accommodate Vertex AI configurations. - Implemented response generation methods for Vertex AI and updated existing services to support new functionality.
- Loading branch information
1 parent
0312ff0
commit ce43c46
Showing
11 changed files
with
315 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.md |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,4 +119,9 @@ dist/* | |
node_modules/* | ||
client/* | ||
.env | ||
.env.example | ||
*.lock | ||
*.sh | ||
*.json | ||
*.md | ||
*.txt |
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
40 changes: 40 additions & 0 deletions
40
ai/cryptocom-ai-agent-service/src/services/llm/llm.factory.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,40 @@ | ||
import { LLMProvider, Options } from '../agent/agent.interfaces.js'; | ||
import { OpenAIService } from './openai.service.js'; | ||
import { GeminiService } from './gemini.service.js'; | ||
import { VertexAIService } from './vertexai.service.js'; | ||
import { LLMService } from './llm.interface.js'; | ||
|
||
export function createLLMService(options: Options): LLMService { | ||
switch (options.llmProvider) { | ||
case LLMProvider.OpenAI: | ||
if (!options.openAI?.apiKey) { | ||
throw new Error('OpenAI API key is required'); | ||
} | ||
return new OpenAIService({ | ||
apiKey: options.openAI.apiKey, | ||
model: options.openAI.model, | ||
}); | ||
|
||
case LLMProvider.Gemini: | ||
if (!options.gemini?.apiKey) { | ||
throw new Error('Gemini API key is required'); | ||
} | ||
return new GeminiService({ | ||
apiKey: options.gemini.apiKey, | ||
model: options.gemini.model, | ||
}); | ||
|
||
case LLMProvider.VertexAI: | ||
if (!options.vertexAI?.projectId) { | ||
throw new Error('Vertex AI project ID is required'); | ||
} | ||
return new VertexAIService({ | ||
projectId: options.vertexAI.projectId, | ||
location: options.vertexAI.location, | ||
model: options.vertexAI.model, | ||
}); | ||
|
||
default: | ||
throw new Error(`Unsupported LLM provider: ${options.llmProvider}`); | ||
} | ||
} |
15 changes: 9 additions & 6 deletions
15
ai/cryptocom-ai-agent-service/src/services/llm/llm.interface.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 |
---|---|---|
@@ -1,15 +1,18 @@ | ||
import { AIMessageResponse, FunctionCallResponse, QueryContext } from '../agent/agent.interfaces.js'; | ||
import { AIMessageResponse, QueryContext, FunctionCallResponse } from '../agent/agent.interfaces.js'; | ||
|
||
export interface LLMConfig { | ||
apiKey?: string; | ||
model?: string; | ||
projectId?: string; | ||
location?: string; | ||
} | ||
|
||
export interface LLMService { | ||
generateResponse(context: QueryContext[]): Promise<AIMessageResponse>; | ||
interpretUserQuery(query: string, context: QueryContext[]): Promise<AIMessageResponse>; | ||
generateFinalResponse( | ||
query: string, | ||
functionResponses: FunctionCallResponse[], | ||
context: QueryContext[] | ||
): Promise<string>; | ||
} | ||
|
||
export interface LLMConfig { | ||
apiKey: string; | ||
model?: string; | ||
} |
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
Oops, something went wrong.