MCPcopy Index your code
hub / github.com/simstudioai/sim / buildOpenAIProvider

Function buildOpenAIProvider

apps/sim/lib/knowledge/embeddings.ts:103–121  ·  view source on GitHub ↗
(modelName: string, apiKey: string)

Source from the content-addressed store, hash-verified

101}
102
103function buildOpenAIProvider(modelName: string, apiKey: string): ResolvedProvider['buildRequest'] {
104 return (inputs) => ({
105 apiUrl: 'https://api.openai.com/v1/embeddings',
106 headers: {
107 Authorization: `Bearer ${apiKey}`,
108 'Content-Type': 'application/json',
109 },
110 body: {
111 input: inputs,
112 model: modelName,
113 encoding_format: 'float',
114 dimensions: EMBEDDING_DIMENSIONS,
115 },
116 parse: (json) => {
117 const data = json as { data: Array<{ embedding: number[] }> }
118 return data.data.map((item) => item.embedding)
119 },
120 })
121}
122
123function buildAzureOpenAIProvider(
124 deployment: string,

Callers 1

resolveProviderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected