MCPcopy Index your code
hub / github.com/continuedev/continue / convertMessageContent

Function convertMessageContent

core/util/messageConversion.ts:139–168  ·  view source on GitHub ↗

* Convert OpenAI message content to unified MessageContent format

(
  content: string | null | Array<any>,
)

Source from the content-addressed store, hash-verified

137 * Convert OpenAI message content to unified MessageContent format
138 */
139function convertMessageContent(
140 content: string | null | Array<any>,
141): MessageContent {
142 if (content === null) {
143 return "";
144 }
145
146 if (typeof content === "string") {
147 return content;
148 }
149
150 if (Array.isArray(content)) {
151 return content.map((part: any) => {
152 if (part.type === "text") {
153 return {
154 type: "text" as const,
155 text: part.text,
156 };
157 } else if (part.type === "image_url") {
158 return {
159 type: "imageUrl" as const,
160 imageUrl: { url: part.image_url.url },
161 };
162 }
163 throw new Error(`Unsupported content part type: ${part.type}`);
164 });
165 }
166
167 throw new Error(`Unsupported content type: ${typeof content}`);
168}
169
170/**
171 * Convert unified MessageContent to OpenAI format

Callers 1

convertToUnifiedMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected