Annotation Interface VCRModel


@Retention(RUNTIME) @Target(FIELD) public @interface VCRModel
Marks a field to be automatically wrapped with VCR recording/playback functionality.

When applied to an EmbeddingModel or ChatModel field, the VCR extension will automatically wrap the model with the appropriate VCR wrapper after it's initialized.

Usage:


 @VCRTest(mode = VCRMode.PLAYBACK_OR_RECORD)
 class MyLLMTest {

     @VCRModel
     private EmbeddingModel embeddingModel;

     @VCRModel
     private ChatModel chatModel;

     @BeforeEach
     void setup() {
         // Initialize your models normally - VCR will wrap them automatically
         embeddingModel = new OpenAiEmbeddingModel(...);
         chatModel = new OpenAiChatModel(...);
     }

     @Test
     void testEmbedding() {
         // Use the model - calls are recorded/replayed transparently
         float[] embedding = embeddingModel.embed("Hello").content();
     }
 }
 

Supported model types:

  • LangChain4J: dev.langchain4j.model.embedding.EmbeddingModel, dev.langchain4j.model.chat.ChatLanguageModel
  • Spring AI: org.springframework.ai.embedding.EmbeddingModel, org.springframework.ai.chat.model.ChatModel
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional model name for embedding cache key generation.
  • Element Details

    • modelName

      String modelName
      Optional model name for embedding cache key generation. If not specified, the field name will be used.
      Default:
      ""