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 { AzureOpenAI } from "openai"; |
| #2 | import { Embedder } from "./base"; |
| #3 | import { EmbeddingConfig } from "../types"; |
| #4 | |
| #5 | export class AzureOpenAIEmbedder implements Embedder { |
| #6 | private client: AzureOpenAI; |
| #7 | private model: string; |
| #8 | private embeddingDims?: number; |
| #9 | |
| #10 | constructor(config: EmbeddingConfig) { |
| #11 | if (!config.apiKey || !config.modelProperties?.endpoint) { |
| #12 | throw new Error("Azure OpenAI requires both API key and endpoint"); |
| #13 | } |
| #14 | |
| #15 | const { endpoint, ...rest } = config.modelProperties; |
| #16 | |
| #17 | this.client = new AzureOpenAI({ |
| #18 | apiKey: config.apiKey, |
| #19 | endpoint: endpoint as string, |
| #20 | ...rest, |
| #21 | }); |
| #22 | this.model = config.model || "text-embedding-3-small"; |
| #23 | this.embeddingDims = config.embeddingDims || 1536; |
| #24 | } |
| #25 | |
| #26 | async embed(text: string): Promise<number[]> { |
| #27 | const response = await this.client.embeddings.create({ |
| #28 | model: this.model, |
| #29 | input: text, |
| #30 | }); |
| #31 | return response.data[0].embedding; |
| #32 | } |
| #33 | |
| #34 | async embedBatch(texts: string[]): Promise<number[][]> { |
| #35 | const response = await this.client.embeddings.create({ |
| #36 | model: this.model, |
| #37 | input: texts, |
| #38 | }); |
| #39 | return response.data.map((item) => item.embedding); |
| #40 | } |
| #41 | } |
| #42 |