Skip to content

Commit fa117c3

Browse files
fix: Handle empty prompt (using only template/inputs from providerOptions)
1 parent 95e399d commit fa117c3

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

integrations/ai-sdk/src/convert-to-humanloop-chat-messages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { HumanloopChatPrompt } from './humanloop-api-types';
1111
const messages: HumanloopChatPrompt = [];
1212

1313
for (const { role, content } of prompt) {
14+
// Skip empty messages, i.e. when prompt == ""
15+
if (content === "") {
16+
continue;
17+
}
18+
1419
switch (role) {
1520
case 'system': {
1621
messages.push({ role: 'system', content });

integrations/ai-sdk/src/humanloop-chat-language-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class HumanloopChatLanguageModel implements LanguageModelV1 {
9797
const { path, id, prompt: promptProviderMetadata, ...restProviderMetadata } = (providerMetadata?.humanloop as HumanloopProviderMetadata) ?? {};
9898

9999
if (!path && !id) {
100-
throw new Error("One of path or id is required in providerMetadata.humanloop.")
100+
throw new Error("Either path or id is required in providerOptions.humanloop.")
101101
}
102102

103103
// prompt hyperparameters:

0 commit comments

Comments
 (0)