@myscheme/voice-navigation-sdk 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"bedrock.d.ts","sourceRoot":"","sources":["../../src/services/bedrock.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAiCD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,YAAY,CAA6B;gBAErC,MAAM,EAAE,aAAa;IAwBjC,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAO7C,OAAO,CAAC,iBAAiB;IA+BnB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmEpE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc;IAO9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAwDjD"}
1
+ {"version":3,"file":"bedrock.d.ts","sourceRoot":"","sources":["../../src/services/bedrock.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,mBAAmB,EAAmB,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAiCD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAgB;IACxC,OAAO,CAAC,YAAY,CAA6B;gBAErC,MAAM,EAAE,aAAa;IAwBjC,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI;IAO7C,OAAO,CAAC,iBAAiB;IA+BnB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAmEpE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,cAAc;IAO9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAoFjD"}
@@ -134,7 +134,8 @@ export class BedrockService {
134
134
  throw new Error("Bedrock embedding model is not configured");
135
135
  }
136
136
  const payload = {
137
- inputText: prompt,
137
+ texts: [prompt],
138
+ input_type: "search_query",
138
139
  };
139
140
  const input = {
140
141
  modelId: this.embeddingModelId,
@@ -149,13 +150,30 @@ export class BedrockService {
149
150
  throw new Error("No response body from Bedrock embedding request");
150
151
  }
151
152
  const decoded = JSON.parse(new TextDecoder().decode(response.body));
152
- const embedding = decoded.embedding ||
153
- decoded.vector ||
154
- (Array.isArray(decoded.embeddings)
155
- ? decoded.embeddings
156
- : decoded.embeddings?.values) ||
157
- decoded.results?.find((item) => Array.isArray(item.embedding))
158
- ?.embedding;
153
+ let embedding;
154
+ if (decoded.embeddings) {
155
+ if (Array.isArray(decoded.embeddings)) {
156
+ if (decoded.embeddings.length > 0 &&
157
+ Array.isArray(decoded.embeddings[0])) {
158
+ embedding = decoded.embeddings[0];
159
+ }
160
+ else if (decoded.embeddings.length > 0 &&
161
+ typeof decoded.embeddings[0] === "number") {
162
+ embedding = decoded.embeddings;
163
+ }
164
+ }
165
+ else if (typeof decoded.embeddings === "object" &&
166
+ "values" in decoded.embeddings) {
167
+ embedding = decoded.embeddings.values;
168
+ }
169
+ }
170
+ if (!embedding) {
171
+ embedding =
172
+ decoded.embedding ||
173
+ decoded.vector ||
174
+ decoded.results?.find((item) => Array.isArray(item.embedding))
175
+ ?.embedding;
176
+ }
159
177
  if (!Array.isArray(embedding)) {
160
178
  throw new Error("Unexpected embedding response structure");
161
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myscheme/voice-navigation-sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Voice navigation SDK using Azure Speech and AWS Bedrock",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",