Skip to content

Commit 745bcd9

Browse files
committed
fix messages.test.ts
1 parent 074b9d5 commit 745bcd9

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

common/src/util/__tests__/messages.test.ts

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,7 @@ describe('convertCbToModelMessages', () => {
636636
content: [
637637
{
638638
type: 'text',
639-
text: 'M',
640-
},
641-
{
642-
type: 'text',
643-
text: 'ore context',
639+
text: 'More context',
644640
providerOptions: expect.objectContaining({
645641
openaiCompatible: {
646642
cache_control: {
@@ -682,11 +678,7 @@ describe('convertCbToModelMessages', () => {
682678
content: [
683679
{
684680
type: 'text',
685-
text: 'I',
686-
},
687-
{
688-
type: 'text',
689-
text: 'nstructions',
681+
text: 'Instructions',
690682
providerOptions: expect.objectContaining({
691683
openaiCompatible: {
692684
cache_control: {
@@ -724,11 +716,7 @@ describe('convertCbToModelMessages', () => {
724716
content: [
725717
{
726718
type: 'text',
727-
text: 'M',
728-
},
729-
{
730-
type: 'text',
731-
text: 'ore context',
719+
text: 'More context',
732720
providerOptions: expect.objectContaining({
733721
openaiCompatible: {
734722
cache_control: {
@@ -768,11 +756,7 @@ describe('convertCbToModelMessages', () => {
768756
{ type: 'text', text: 'More context' },
769757
{
770758
type: 'text',
771-
text: 'U',
772-
},
773-
{
774-
type: 'text',
775-
text: 'ser message',
759+
text: 'User message',
776760
providerOptions: expect.objectContaining({
777761
openaiCompatible: {
778762
cache_control: {
@@ -863,14 +847,14 @@ describe('convertCbToModelMessages', () => {
863847
])
864848
})
865849

866-
it('should skip very short text content when finding cache control location', () => {
850+
it('should handle very short text content when finding cache control location', () => {
867851
const messages: Message[] = [
868852
{ role: 'system', content: 'System' },
869853
{
870854
role: 'user',
871855
content: [
872-
{ type: 'text', text: 'Long enough text' },
873-
{ type: 'text', text: 'X' }, // Too short
856+
{ type: 'text', text: 'Longer text' },
857+
{ type: 'text', text: 'X' }, // Short
874858
],
875859
},
876860
{ role: 'user', content: 'Next', tags: ['USER_PROMPT'] },
@@ -886,10 +870,10 @@ describe('convertCbToModelMessages', () => {
886870
{
887871
role: 'user',
888872
content: [
889-
{ type: 'text', text: 'L' },
873+
{ type: 'text', text: 'Longer text' },
890874
{
891875
type: 'text',
892-
text: 'ong enough text',
876+
text: 'X',
893877
providerOptions: expect.objectContaining({
894878
openaiCompatible: {
895879
cache_control: {
@@ -898,10 +882,6 @@ describe('convertCbToModelMessages', () => {
898882
},
899883
}),
900884
},
901-
{
902-
type: 'text',
903-
text: 'X',
904-
},
905885
],
906886
},
907887
expect.objectContaining({ role: 'user' }),

common/src/util/messages.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,6 @@ export function convertCbToModelMessages({
302302
break addCacheControlLoop
303303
}
304304

305-
if (lastContentPart.text.length < 2) {
306-
// continue searching in this message
307-
continue
308-
}
309-
310305
prevMessage.content = [
311306
...contentBlock.slice(0, lastContentIndex),
312307
withCacheControl(lastContentPart),

0 commit comments

Comments
 (0)