repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { GoogleGenAI } from "@google/genai"; |
| #2 | import { Embedder } from "./base"; |
| #3 | import { EmbeddingConfig } from "../types"; |
| #4 | |
| #5 | export class GoogleEmbedder implements Embedder { |
| #6 | private google: GoogleGenAI; |
| #7 | private model: string; |
| #8 | private embeddingDims?: number; |
| #9 | |
| #10 | constructor(config: EmbeddingConfig) { |
| #11 | this.google = new GoogleGenAI({ |
| #12 | apiKey: config.apiKey || process.env.GOOGLE_API_KEY, |
| #13 | }); |
| #14 | this.model = config.model || "gemini-embedding-001"; |
| #15 | this.embeddingDims = config.embeddingDims || 1536; |
| #16 | } |
| #17 | |
| #18 | async embed(text: string): Promise<number[]> { |
| #19 | const response = await this.google.models.embedContent({ |
| #20 | model: this.model, |
| #21 | contents: text, |
| #22 | config: { outputDimensionality: this.embeddingDims }, |
| #23 | }); |
| #24 | return response.embeddings![0].values!; |
| #25 | } |
| #26 | |
| #27 | async embedBatch(texts: string[]): Promise<number[][]> { |
| #28 | const response = await this.google.models.embedContent({ |
| #29 | model: this.model, |
| #30 | contents: texts, |
| #31 | config: { outputDimensionality: 768 }, |
| #32 | }); |
| #33 | return response.embeddings!.map((item) => item.values!); |
| #34 | } |
| #35 | } |
| #36 |