Skip to content

Commit f73f0e5

Browse files
committed
feature-233-implement-openrouter: Update embedding response structure for improved data handling
- Changed the EmbedResponse interface to return a 2D array of embeddings instead of a 1D array, enhancing the flexibility of the embedding data. - Updated the getEmbedding method in DockerRepository to reflect the new response structure and improved logging for better traceability. - Adjusted VectorActionUseCase to handle the updated embeddings format, ensuring consistency across the application.
1 parent 5dc231a commit f73f0e5

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/data/repository/docker_repository.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface EmbedRequest {
88
}
99

1010
interface EmbedResponse {
11-
vector: number[];
11+
embeddings: number[][];
1212
}
1313

1414
export class DockerRepository {
@@ -164,7 +164,7 @@ export class DockerRepository {
164164
}
165165
}
166166

167-
getEmbedding = async (textInstructionsPairs: [string, string][]): Promise<number[]> => {
167+
getEmbedding = async (textInstructionsPairs: [string, string][]): Promise<number[][]> => {
168168
try {
169169
const request: EmbedRequest = {
170170
instructions: textInstructionsPairs.map(pair => pair[0]),
@@ -184,7 +184,8 @@ export class DockerRepository {
184184
}
185185

186186
const data: EmbedResponse = await response.json();
187-
return data.vector;
187+
logDebugInfo(`🐳 🟡 Embedding: ${JSON.stringify(data)}`);
188+
return data.embeddings;
188189
} catch (error) {
189190
logError('Error getting embedding: ' + error);
190191
throw error;

src/usecase/vector_action_use_case.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ export class VectorActionUseCase implements ParamUseCase<Execution, Result[]> {
1717
await this.dockerRepository.startContainer();
1818

1919

20-
const embedding = await this.dockerRepository.getEmbedding(
20+
const embeddings = await this.dockerRepository.getEmbedding(
2121
[
2222
[this.CODE_INSTRUCTION, "function sum(a, b) { return a + b; }"]
2323
]
2424
);
2525

26-
logDebugInfo(`Embedding: ${embedding}`);
26+
logDebugInfo(`Embedding: ${embeddings}`);
2727

2828
results.push(
2929
new Result({

0 commit comments

Comments
 (0)