MCPcopy Create free account
hub / github.com/continuedev/continue / convertFromMessageContent

Function convertFromMessageContent

core/util/messageConversion.ts:173–198  ·  view source on GitHub ↗

* Convert unified MessageContent to OpenAI format

(
  content: MessageContent,
)

Source from the content-addressed store, hash-verified

171 * Convert unified MessageContent to OpenAI format
172 */
173function convertFromMessageContent(
174 content: MessageContent,
175): string | Array<any> {
176 if (typeof content === "string") {
177 return content;
178 }
179
180 if (Array.isArray(content)) {
181 return content.map((part: any) => {
182 if (part.type === "text") {
183 return {
184 type: "text",
185 text: part.text,
186 };
187 } else if (part.type === "imageUrl") {
188 return {
189 type: "image_url",
190 image_url: { url: part.imageUrl.url },
191 };
192 }
193 throw new Error(`Unsupported content part type: ${part.type}`);
194 });
195 }
196
197 throw new Error(`Unsupported content type: ${typeof content}`);
198}
199
200/**
201 * Create a ChatHistoryItem from a ChatMessage

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected