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

feat:Update openapi.yaml with new endpoints and schema modifications for LangSmith #113

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Oct 28, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new API endpoints for handling AI messages and chat interactions, enhancing conversational capabilities.
    • Added support for tool integrations with new schemas.
  • Improvements

    • Updated existing endpoints for better run tracking and monitoring functionalities.
    • Revised schema for prompt optimization, reflecting a new approach.
  • Miscellaneous

    • Included new query parameters and made minor updates to existing schemas.

@github-actions github-actions bot enabled auto-merge October 28, 2024 21:18
@github-actions github-actions bot merged commit 81bb8c9 into main Oct 28, 2024
3 checks passed
Copy link

coderabbitai bot commented Oct 28, 2024

Walkthrough

The changes in this pull request primarily involve updates to the openapi.yaml file for the LangSmith application. New endpoints and schemas have been added to facilitate AI and chat message handling, alongside modifications to existing models like TracerSession and RunSchema. The PlaygroundOptimizePromptRequestSchema has been removed in favor of the new PlayGroundGraph schema, indicating a strategic shift in prompt optimization. Additionally, various minor updates have been made to existing schemas and query parameters.

Changes

File Change Summary
src/libs/LangSmith/openapi.yaml - Added new endpoints and schemas for AI messages, chat messages, tool calls, and usage metadata.
- Modified existing endpoints and schemas, including updates to TracerSession and RunSchema.
- Removed PlaygroundOptimizePromptRequestSchema and added PlayGroundGraph schema.
- Various minor updates to existing schemas and new query parameters.

Possibly related PRs

Suggested reviewers

  • github-actions

Poem

In the land of code, where rabbits play,
New paths are forged in a bright array.
With endpoints fresh and schemas anew,
We hop along, with joy in view!
So let’s celebrate this wondrous change,
In our coding burrow, we’ll rearrange! 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Update openapi.yaml with new endpoints and schema modifications for LangSmith Oct 28, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
src/libs/LangSmith/openapi.yaml (2)

7390-7390: Add documentation for the Canvas endpoint.

The endpoint's purpose and expected behavior should be documented to help API consumers understand its usage.

Add a description field to the operation:

 operationId: canvas_api_v1_prompts_canvas_post
+description: "Endpoint for processing and optimizing prompts using the Canvas feature. This endpoint accepts a PlayGroundGraph containing messages and artifacts, and returns the processed results."
 requestBody:

15611-15664: Add descriptions for enum values.

The artifact_length and reading_level enums would benefit from descriptions explaining the implications of each value.

Add descriptions for the enum values:

 artifact_length:
   title: Artifact Length
   enum:
     - shortest
     - short
     - long
     - longest
   type: string
   nullable: true
+  description: |
+    Controls the length of the generated artifact:
+    * shortest - Minimal length output
+    * short - Concise output
+    * long - Detailed output
+    * longest - Comprehensive output

 reading_level:
   title: Reading Level
   enum:
     - child
     - teenager
     - college
     - phd
   type: string
   nullable: true
+  description: |
+    Controls the complexity of the generated content:
+    * child - Simple language suitable for children
+    * teenager - Language suitable for teenagers
+    * college - College-level complexity
+    * phd - Advanced academic level
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d8a01e7 and a4044d8.

⛔ Files ignored due to path filters (128)
  • src/libs/LangSmith/Generated/JsonConverters.AIMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.AIMessageChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.AIMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.AIMessageTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ChatMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ChatMessageChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ChatMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ChatMessageTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.FunctionMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.FunctionMessageChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.FunctionMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.FunctionMessageTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.HumanMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.HumanMessageChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.HumanMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.HumanMessageTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.InvalidToolCallType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.InvalidToolCallTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.MessagesItem.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.PlayGroundGraphArtifactLength.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.PlayGroundGraphArtifactLengthNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.PlayGroundGraphMessageDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.PlayGroundGraphMessageDiscriminatorTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.PlayGroundGraphReadingLevel.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.PlayGroundGraphReadingLevelNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.SystemMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.SystemMessageChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.SystemMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.SystemMessageTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolCallChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolCallChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolCallType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolCallTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageChunkStatus.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageChunkStatusNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageChunkTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageStatus.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageStatusNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonConverters.ToolMessageTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.IPromptsClient.Canvas.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessage.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageChunkAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageChunkContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageChunkResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.AIMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.Artifact.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ArtifactContent.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessage.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageChunkAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageChunkContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageChunkResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ChatMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessage.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageChunkAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageChunkContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageChunkResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.FunctionMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.Highlight.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessage.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageChunkAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageChunkContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageChunkResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.HumanMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.InputTokenDetails.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.InvalidToolCall.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.InvalidToolCallType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.MessagesItem.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.OutputTokenDetails.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.PlayGroundGraph.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.PlayGroundGraphArtifactLength.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.PlayGroundGraphMessageDiscriminator.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.PlayGroundGraphMessageDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.PlayGroundGraphReadingLevel.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessage.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageChunkAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageChunkContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageChunkResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.SystemMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolCall.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolCallArgs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolCallChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolCallChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolCallType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessage.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageArtifact.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunk.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunkAdditionalKwargs.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunkArtifact.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunkContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunkResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunkStatus.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageChunkType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageResponseMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageStatus.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.ToolMessageType.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.Models.UsageMetadata.g.cs is excluded by !**/generated/**
  • src/libs/LangSmith/Generated/LangSmith.PromptsClient.Canvas.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/LangSmith/openapi.yaml (12 hunks)
🔇 Additional comments (2)
src/libs/LangSmith/openapi.yaml (2)

10262-10313: LGTM! Well-structured message schemas.

The message type schemas are well-designed with:

  • Consistent structure across different message types
  • Proper validation through required fields
  • Comprehensive documentation with examples
  • Support for both string and structured content

Also applies to: 14169-14248, 18607-18678


14366-14379: LGTM! Comprehensive token usage tracking.

The token usage schemas provide:

  • Detailed breakdown of token usage
  • Flexibility for different types of token counting
  • Clear documentation with examples
  • Version tracking for schema changes

Also applies to: 15453-15463, 19920-19941

Comment on lines +19358 to +19510
type: string
description: "A chunk of a tool call (e.g., as part of a stream).\n\nWhen merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\nall string attributes are concatenated. Chunks are only merged if their\nvalues of `index` are equal and not None.\n\nExample:\n\n.. code-block:: python\n\n left_chunks = [ToolCallChunk(name=\"foo\", args='{\"a\":', index=0)]\n right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]\n\n (\n AIMessageChunk(content=\"\", tool_call_chunks=left_chunks)\n + AIMessageChunk(content=\"\", tool_call_chunks=right_chunks)\n ).tool_call_chunks == [ToolCallChunk(name='foo', args='{\"a\":1}', index=0)]"
ToolMessage:
title: ToolMessage
required:
- content
- tool_call_id
type: object
properties:
content:
title: Content
anyOf:
- type: string
- type: array
items:
anyOf:
- type: string
- type: object
additional_kwargs:
title: Additional Kwargs
type: object
response_metadata:
title: Response Metadata
type: object
type:
title: Type
enum:
- tool
type: string
default: tool
name:
title: Name
type: string
nullable: true
id:
title: Id
type: string
nullable: true
tool_call_id:
title: Tool Call Id
type: string
artifact:
title: Artifact
status:
title: Status
enum:
- success
- error
type: string
default: success
description: "Message for passing the result of executing a tool back to a model.\n\nToolMessages contain the result of a tool invocation. Typically, the result\nis encoded inside the `content` field.\n\nExample: A ToolMessage representing a result of 42 from a tool call with id\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n ToolMessage(content='42', tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL')\n\n\nExample: A ToolMessage where only part of the tool output is sent to the model\n and the full output is passed in to artifact.\n\n .. versionadded:: 0.2.17\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n tool_output = {\n \"stdout\": \"From the graph we can see that the correlation between x and y is ...\",\n \"stderr\": None,\n \"artifacts\": {\"type\": \"image\", \"base64_data\": \"/9j/4gIcSU...\"},\n }\n\n ToolMessage(\n content=tool_output[\"stdout\"],\n artifact=tool_output,\n tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL',\n )\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel."
ToolMessageChunk:
title: ToolMessageChunk
required:
- content
- tool_call_id
type: object
properties:
content:
title: Content
anyOf:
- type: string
- type: array
items:
anyOf:
- type: string
- type: object
additional_kwargs:
title: Additional Kwargs
type: object
response_metadata:
title: Response Metadata
type: object
type:
title: Type
enum:
- ToolMessageChunk
type: string
default: ToolMessageChunk
name:
title: Name
type: string
nullable: true
id:
title: Id
type: string
nullable: true
tool_call_id:
title: Tool Call Id
type: string
artifact:
title: Artifact
status:
title: Status
enum:
- success
- error
type: string
default: success
description: Tool Message chunk.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding JSON schema validation for tool arguments.

While the tool-related schemas are well-designed, the args field in ToolCall could benefit from additional validation to ensure it contains valid JSON.

Consider updating the args field definition:

 args:
   title: Args
   type: object
+  additionalProperties: true
+  description: "JSON object containing the arguments for the tool call. Must be valid JSON."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ToolCall:
title: ToolCall
required:
- name
- args
- id
type: object
properties:
name:
title: Name
type: string
args:
title: Args
type: object
id:
title: Id
type: string
nullable: true
type:
title: Type
enum:
- tool_call
type: string
description: "Represents a request to call a tool.\n\nExample:\n\n .. code-block:: python\n\n {\n \"name\": \"foo\",\n \"args\": {\"a\": 1},\n \"id\": \"123\"\n }\n\n This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n and an identifier of \"123\"."
ToolCallChunk:
title: ToolCallChunk
required:
- name
- args
- id
- index
type: object
properties:
name:
title: Name
type: string
nullable: true
args:
title: Args
type: string
nullable: true
id:
title: Id
type: string
nullable: true
index:
title: Index
type: integer
nullable: true
type:
title: Type
enum:
- tool_call_chunk
type: string
description: "A chunk of a tool call (e.g., as part of a stream).\n\nWhen merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\nall string attributes are concatenated. Chunks are only merged if their\nvalues of `index` are equal and not None.\n\nExample:\n\n.. code-block:: python\n\n left_chunks = [ToolCallChunk(name=\"foo\", args='{\"a\":', index=0)]\n right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]\n\n (\n AIMessageChunk(content=\"\", tool_call_chunks=left_chunks)\n + AIMessageChunk(content=\"\", tool_call_chunks=right_chunks)\n ).tool_call_chunks == [ToolCallChunk(name='foo', args='{\"a\":1}', index=0)]"
ToolMessage:
title: ToolMessage
required:
- content
- tool_call_id
type: object
properties:
content:
title: Content
anyOf:
- type: string
- type: array
items:
anyOf:
- type: string
- type: object
additional_kwargs:
title: Additional Kwargs
type: object
response_metadata:
title: Response Metadata
type: object
type:
title: Type
enum:
- tool
type: string
default: tool
name:
title: Name
type: string
nullable: true
id:
title: Id
type: string
nullable: true
tool_call_id:
title: Tool Call Id
type: string
artifact:
title: Artifact
status:
title: Status
enum:
- success
- error
type: string
default: success
description: "Message for passing the result of executing a tool back to a model.\n\nToolMessages contain the result of a tool invocation. Typically, the result\nis encoded inside the `content` field.\n\nExample: A ToolMessage representing a result of 42 from a tool call with id\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n ToolMessage(content='42', tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL')\n\n\nExample: A ToolMessage where only part of the tool output is sent to the model\n and the full output is passed in to artifact.\n\n .. versionadded:: 0.2.17\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n tool_output = {\n \"stdout\": \"From the graph we can see that the correlation between x and y is ...\",\n \"stderr\": None,\n \"artifacts\": {\"type\": \"image\", \"base64_data\": \"/9j/4gIcSU...\"},\n }\n\n ToolMessage(\n content=tool_output[\"stdout\"],\n artifact=tool_output,\n tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL',\n )\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel."
ToolMessageChunk:
title: ToolMessageChunk
required:
- content
- tool_call_id
type: object
properties:
content:
title: Content
anyOf:
- type: string
- type: array
items:
anyOf:
- type: string
- type: object
additional_kwargs:
title: Additional Kwargs
type: object
response_metadata:
title: Response Metadata
type: object
type:
title: Type
enum:
- ToolMessageChunk
type: string
default: ToolMessageChunk
name:
title: Name
type: string
nullable: true
id:
title: Id
type: string
nullable: true
tool_call_id:
title: Tool Call Id
type: string
artifact:
title: Artifact
status:
title: Status
enum:
- success
- error
type: string
default: success
description: Tool Message chunk.
ToolCall:
title: ToolCall
required:
- name
- args
- id
type: object
properties:
name:
title: Name
type: string
args:
title: Args
type: object
additionalProperties: true
description: "JSON object containing the arguments for the tool call. Must be valid JSON."
id:
title: Id
type: string
nullable: true
type:
title: Type
enum:
- tool_call
type: string
description: "Represents a request to call a tool.\n\nExample:\n\n .. code-block:: python\n\n {\n \"name\": \"foo\",\n \"args\": {\"a\": 1},\n \"id\": \"123\"\n }\n\n This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n and an identifier of \"123\"."
ToolCallChunk:
title: ToolCallChunk
required:
- name
- args
- id
- index
type: object
properties:
name:
title: Name
type: string
nullable: true
args:
title: Args
type: string
nullable: true
id:
title: Id
type: string
nullable: true
index:
title: Index
type: integer
nullable: true
type:
title: Type
enum:
- tool_call_chunk
type: string
description: "A chunk of a tool call (e.g., as part of a stream).\n\nWhen merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\nall string attributes are concatenated. Chunks are only merged if their\nvalues of `index` are equal and not None.\n\nExample:\n\n.. code-block:: python\n\n left_chunks = [ToolCallChunk(name=\"foo\", args='{\"a\":', index=0)]\n right_chunks = [ToolCallChunk(name=None, args='1}', index=0)]\n\n (\n AIMessageChunk(content=\"\", tool_call_chunks=left_chunks)\n + AIMessageChunk(content=\"\", tool_call_chunks=right_chunks)\n ).tool_call_chunks == [ToolCallChunk(name='foo', args='{\"a\":1}', index=0)]"
ToolMessage:
title: ToolMessage
required:
- content
- tool_call_id
type: object
properties:
content:
title: Content
anyOf:
- type: string
- type: array
items:
anyOf:
- type: string
- type: object
additional_kwargs:
title: Additional Kwargs
type: object
response_metadata:
title: Response Metadata
type: object
type:
title: Type
enum:
- tool
type: string
default: tool
name:
title: Name
type: string
nullable: true
id:
title: Id
type: string
nullable: true
tool_call_id:
title: Tool Call Id
type: string
artifact:
title: Artifact
status:
title: Status
enum:
- success
- error
type: string
default: success
description: "Message for passing the result of executing a tool back to a model.\n\nToolMessages contain the result of a tool invocation. Typically, the result\nis encoded inside the `content` field.\n\nExample: A ToolMessage representing a result of 42 from a tool call with id\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n ToolMessage(content='42', tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL')\n\n\nExample: A ToolMessage where only part of the tool output is sent to the model\n and the full output is passed in to artifact.\n\n .. versionadded:: 0.2.17\n\n .. code-block:: python\n\n from langchain_core.messages import ToolMessage\n\n tool_output = {\n \"stdout\": \"From the graph we can see that the correlation between x and y is ...\",\n \"stderr\": None,\n \"artifacts\": {\"type\": \"image\", \"base64_data\": \"/9j/4gIcSU...\"},\n }\n\n ToolMessage(\n content=tool_output[\"stdout\"],\n artifact=tool_output,\n tool_call_id='call_Jja7J89XsjrOLA5r!MEOW!SL',\n )\n\nThe tool_call_id field is used to associate the tool call request with the\ntool call response. This is useful in situations where a chat model is able\nto request multiple tool calls in parallel."
ToolMessageChunk:
title: ToolMessageChunk
required:
- content
- tool_call_id
type: object
properties:
content:
title: Content
anyOf:
- type: string
- type: array
items:
anyOf:
- type: string
- type: object
additional_kwargs:
title: Additional Kwargs
type: object
response_metadata:
title: Response Metadata
type: object
type:
title: Type
enum:
- ToolMessageChunk
type: string
default: ToolMessageChunk
name:
title: Name
type: string
nullable: true
id:
title: Id
type: string
nullable: true
tool_call_id:
title: Tool Call Id
type: string
artifact:
title: Artifact
status:
title: Status
enum:
- success
- error
type: string
default: success
description: Tool Message chunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant