11import { expect , test } from 'vitest'
22import { formatCallKentTranscriptWithWorkersAi } from '#app/utils/cloudflare-ai-call-kent-transcript-format.server.ts'
3+ import { setEnv } from '#tests/env-disposable.ts'
34
45test ( 'formatCallKentTranscriptWithWorkersAi rejects empty transcripts' , async ( ) => {
56 await expect (
@@ -8,6 +9,14 @@ test('formatCallKentTranscriptWithWorkersAi rejects empty transcripts', async ()
89} )
910
1011test ( 'formatCallKentTranscriptWithWorkersAi returns paragraphs and preserves separators' , async ( ) => {
12+ using _env = setEnv ( {
13+ CLOUDFLARE_API_TOKEN : 'MOCK_CLOUDFLARE_API_TOKEN' ,
14+ CLOUDFLARE_ACCOUNT_ID : 'mock-account' ,
15+ CLOUDFLARE_AI_GATEWAY_ID : 'mock-gateway' ,
16+ CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN : 'MOCK_CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN' ,
17+ CLOUDFLARE_AI_CALL_KENT_TRANSCRIPT_FORMAT_MODEL : '@cf/meta/llama-3.1-8b-instruct' ,
18+ } )
19+
1120 const transcript = `
1221Announcer: You're listening to the Call Kent Podcast. Now let's hear the call.
1322
@@ -39,13 +48,29 @@ Announcer: This has been the Call Kent Podcast. Thanks for listening.
3948} )
4049
4150test ( 'formatCallKentTranscriptWithWorkersAi works without --- separators' , async ( ) => {
51+ using _env = setEnv ( {
52+ CLOUDFLARE_API_TOKEN : 'MOCK_CLOUDFLARE_API_TOKEN' ,
53+ CLOUDFLARE_ACCOUNT_ID : 'mock-account' ,
54+ CLOUDFLARE_AI_GATEWAY_ID : 'mock-gateway' ,
55+ CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN : 'MOCK_CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN' ,
56+ CLOUDFLARE_AI_CALL_KENT_TRANSCRIPT_FORMAT_MODEL : '@cf/meta/llama-3.1-8b-instruct' ,
57+ } )
58+
4259 const transcript = `Caller: Hi Kent. This is a single block transcript. It should still get paragraph breaks.`
4360 const formatted = await formatCallKentTranscriptWithWorkersAi ( { transcript } )
4461 expect ( formatted ) . toContain ( 'Caller:' )
4562 expect ( formatted ) . toMatch ( / [ . ! ? ] \n \n / )
4663} )
4764
4865test ( 'formatCallKentTranscriptWithWorkersAi does not truncate long transcripts' , async ( ) => {
66+ using _env = setEnv ( {
67+ CLOUDFLARE_API_TOKEN : 'MOCK_CLOUDFLARE_API_TOKEN' ,
68+ CLOUDFLARE_ACCOUNT_ID : 'mock-account' ,
69+ CLOUDFLARE_AI_GATEWAY_ID : 'mock-gateway' ,
70+ CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN : 'MOCK_CLOUDFLARE_AI_GATEWAY_AUTH_TOKEN' ,
71+ CLOUDFLARE_AI_CALL_KENT_TRANSCRIPT_FORMAT_MODEL : '@cf/meta/llama-3.1-8b-instruct' ,
72+ } )
73+
4974 const longBody = Array . from (
5075 { length : 600 } ,
5176 ( _ , i ) => `Sentence ${ i + 1 } .` ,
0 commit comments