-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app service extends embeddingService
- Loading branch information
Olasunkanmi Oyinlola
authored and
Olasunkanmi Oyinlola
committed
Feb 11, 2024
1 parent
1705bb6
commit 7406cb1
Showing
3 changed files
with
10 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
import { CONSTANTS } from "../core/constants"; | ||
import { IDocumentService } from "../interfaces/document-service.interface"; | ||
import { IEmbeddingService } from "../interfaces/embedding-service.interface"; | ||
import { DocumentService } from "./document-service"; | ||
import { EmbeddingService } from "./embed-service"; | ||
import { database } from ".."; | ||
|
||
export class AppService { | ||
constructor(private readonly APIkey: string, private readonly documentPath: string) {} | ||
export class AppService extends EmbeddingService { | ||
constructor(apikey: string, private readonly documentPath: string, AIModel: string) { | ||
super(apikey, AIModel); | ||
} | ||
async createEmbeddings(): Promise<void> { | ||
const documentService: IDocumentService = new DocumentService(); | ||
const embeddingService: IEmbeddingService = new EmbeddingService(this.APIkey, CONSTANTS.generativeAIModel); | ||
let text: string; | ||
if (this.documentPath.length) { | ||
text = await documentService.convertPDFToText(this.documentPath); | ||
} | ||
if (text) { | ||
console.log("...generating embeddings"); | ||
const embeddings = await embeddingService.generateEmbeddings(text); | ||
const embeddings = await this.generateEmbeddings(text); | ||
if (embeddings) { | ||
console.log("...embeddings generated"); | ||
return await database.createDocument(text, embeddings); | ||
} | ||
} | ||
} | ||
|
||
async similaritySearch() {} | ||
} |
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