Skip to content

Investigate formatting multiline values in cassette yaml files #127

@lamchau

Description

@lamchau

In #118 we added VCR tests and the generated yaml files are difficult to read.

      string: "{\n  \"candidates\": [\n    {\n      \"content\": {\n        \"parts\":
        [\n          {\n            \"text\": \"Hello! \U0001F44B  How can I help
        you today? \U0001F60A \\n\"\n          }\n        ],\n        \"role\": \"model\"\n
        \     },\n      \"finishReason\": \"STOP\",\n      \"index\": 0,\n      \"safetyRatings\":
        [\n        {\n          \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n
        \         \"probability\": \"NEGLIGIBLE\"\n        },\n        {\n          \"category\":
        \"HARM_CATEGORY_HATE_SPEECH\",\n          \"probability\": \"NEGLIGIBLE\"\n
        \       },\n        {\n          \"category\": \"HARM_CATEGORY_HARASSMENT\",\n
        \         \"probability\": \"NEGLIGIBLE\"\n        },\n        {\n          \"category\":
        \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n          \"probability\": \"NEGLIGIBLE\"\n
        \       }\n      ]\n    }\n  ],\n  \"usageMetadata\": {\n    \"promptTokenCount\":
        8,\n    \"candidatesTokenCount\": 12,\n    \"totalTokenCount\": 20\n  }\n}\n"

Ideally, the output would be a YAML literal block scalar for readability

interactions:
  - request:
      body: |-
        {
          "system_instruction": {
            "parts": [
              {
                "text": "You are a helpful assistant."
              }
            ]
          },
          "contents": [
            {
              "role": "user",
              "parts": [
                {
                  "text": "Hello"
                }
              ]
            }
          ]
        }
  - response:
      body:
        string: |- 
          {
            "candidates": [
              {
                "content": {
                  "parts": [
                    {
                      "text": "Hello! 👋  How can I help you today? 😊 \n"
                    }
                  ],
                  "role": "model"
                },
                "finishReason": "STOP",
                "index": 0,
                "safetyRatings": [ ... ]
                ]
              }
            ],
            "usageMetadata": { ... }
          }
          

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions