Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-101917

$https.config.parseJsonStrings support nested docs, arrays

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 8.2.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Atlas Streams
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As a follow on to https://jira.mongodb.org/browse/SERVER-101258, we need to be able to handle arrays in the results, for example the OpenAI API returns an array called choices.

      How we might call the stage:

      $https: {
            connectionName: "AzureChatGPT",
            method: "POST",
            as: "apiResults",
      
            // this means deserialize all json strings found in the response.
            config: { parseJsonStrings: true },
            payload: [
              {
                $project: {
                  _id: 0,
                  model: "gpt-4o-mini",
                  response_format: { type: "json_object" },
                  messages: [
      .... 

      example Data from API

      {
          ...,
          choices: [
            {
              ...
              message: {
                content: '{"sentiment_score":0,"reasoning":"The conversation discusses various databases, including MongoDB and Oracle, but does not have a strong positive or negative sentiment overall. It reflects a neutral stance on the potential adoption of new technologies and their integration challenges.","orig_language":"English","streaming_score":0}',
              }
            },
             {
              ...
              message: {
                content: '{"sentiment_score":0,"reasoning":"The conversation discusses various databases, including MongoDB and Oracle, but does not have a strong positive or negative sentiment overall. It reflects a neutral stance on the potential adoption of new technologies and their integration challenges.","orig_language":"English","streaming_score":0}',
              }
            } 
          ], 

            Assignee:
            calvin.nix@mongodb.com Calvin Nix
            Reporter:
            kenny.gorman@mongodb.com Kenny Gorman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              None
              None
              None
              None