Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
shaper committed Dec 22, 2024
1 parent 6baacb0 commit e78a1eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ describe('complex part-level transformations', () => {
const result = convertToOpenAICompatibleChatMessages([
{
role: 'tool',
providerMetadata: { // this just gets omitted as we prioritize content-level metadata
providerMetadata: {
// this just gets omitted as we prioritize content-level metadata
openaiCompatible: { responseTier: 'detailed' },
},
content: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
import { convertUint8ArrayToBase64 } from '@ai-sdk/provider-utils';
import { OpenAICompatibleChatPrompt } from './openai-compatible-api-types';

function getOpenAIMetadata(message: { providerMetadata?: LanguageModelV1ProviderMetadata }) {
function getOpenAIMetadata(message: {
providerMetadata?: LanguageModelV1ProviderMetadata;
}) {
return message?.providerMetadata?.openaiCompatible ?? {};
}

Expand All @@ -24,7 +26,11 @@ export function convertToOpenAICompatibleChatMessages(

case 'user': {
if (content.length === 1 && content[0].type === 'text') {
messages.push({ role: 'user', content: content[0].text, ...getOpenAIMetadata(content[0]) });
messages.push({
role: 'user',
content: content[0].text,
...getOpenAIMetadata(content[0]),
});
break;
}

Expand All @@ -43,8 +49,9 @@ export function convertToOpenAICompatibleChatMessages(
url:
part.image instanceof URL
? part.image.toString()
: `data:${part.mimeType ?? 'image/jpeg'
};base64,${convertUint8ArrayToBase64(part.image)}`,
: `data:${
part.mimeType ?? 'image/jpeg'
};base64,${convertUint8ArrayToBase64(part.image)}`,
},
...partMetadata,
};
Expand Down

0 comments on commit e78a1eb

Please sign in to comment.