Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core[patch]: Improve console.log format for messages #6121

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Conversation

jacoblee93
Copy link
Collaborator

@jacoblee93 jacoblee93 commented Jul 17, 2024

Checked console.dir(message, { depth: null }) and JSON.stringify(message)

Before:

AIMessage {
  lc_serializable: true,
  lc_kwargs: {
    content: '',
    tool_calls: [ [Object] ],
    invalid_tool_calls: [],
    additional_kwargs: { function_call: undefined, tool_calls: [Array] },
    response_metadata: {},
    id: 'chatcmpl-9m7NDoFInLTEzw9rF8cLv8mbE2BxQ'
  },
  lc_namespace: [ 'langchain_core', 'messages' ],
  content: '',
  name: undefined,
  additional_kwargs: { function_call: undefined, tool_calls: [ [Object] ] },
  response_metadata: {
    tokenUsage: { completionTokens: 30, promptTokens: 63, totalTokens: 93 },
    finish_reason: 'tool_calls'
  },
  id: 'chatcmpl-9m7NDoFInLTEzw9rF8cLv8mbE2BxQ',
  tool_calls: [
    {
      name: 'pet_expert',
      args: [Object],
      type: 'tool_call',
      id: 'call_kKW7x1wBsICArIvQwdo5Oty0'
    }
  ],
  invalid_tool_calls: [],
  usage_metadata: { input_tokens: 63, output_tokens: 30, total_tokens: 93 }
}

After:

AIMessage {
  "id": "chatcmpl-9m8idsKhvNqDIanBP9kj17Ig1ytQ2",
  "content": "",
  "additional_kwargs": {
    "tool_calls": [
      {
        "id": "call_4t74hRzUwQ9yDRbPg8oftyzi",
        "type": "function",
        "function": "[Object]"
      }
    ]
  },
  "response_metadata": {
    "tokenUsage": {
      "completionTokens": 30,
      "promptTokens": 63,
      "totalTokens": 93
    },
    "finish_reason": "tool_calls"
  },
  "tool_calls": [
    {
      "name": "pet_expert",
      "args": {
        "context": "pirate",
        "question": "What are dogs known for?",
        "answer_style": "short"
      },
      "type": "tool_call",
      "id": "call_4t74hRzUwQ9yDRbPg8oftyzi"
    }
  ],
  "invalid_tool_calls": [],
  "usage_metadata": {
    "input_tokens": 63,
    "output_tokens": 30,
    "total_tokens": 93
  }
}

Copy link

vercel bot commented Jul 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2024 0:36am
langchainjs-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 18, 2024 0:36am

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. auto:improvement Medium size change to existing code to handle new use-cases labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:improvement Medium size change to existing code to handle new use-cases lgtm PRs that are ready to be merged as-is size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants