Skip to content

Conversation

@cyborg42
Copy link

@cyborg42 cyborg42 commented Mar 9, 2025

This pull request includes no breaking change.

Support structured outputs and tools in chats.

@cyborg42 cyborg42 closed this Mar 10, 2025
@cyborg42 cyborg42 reopened this Mar 10, 2025
@cyborg42 cyborg42 changed the title Add json_schema to ChatCompletionResponseFormat Support structured outputs and tools in chats Mar 10, 2025
@cyborg42 cyborg42 force-pushed the master branch 2 times, most recently from 7822ccc to 67b20c5 Compare March 10, 2025 08:45
@cyborg42 cyborg42 marked this pull request as draft March 10, 2025 09:19
@cyborg42 cyborg42 marked this pull request as ready for review March 10, 2025 15:45
@cyborg42 cyborg42 marked this pull request as draft March 10, 2025 21:38
@cyborg42 cyborg42 marked this pull request as ready for review March 12, 2025 09:15
@cyborg42
Copy link
Author

cyborg42 commented Mar 12, 2025

@rellfy Hey there! All the new features are tested and ready—would you mind taking a look when you get a chance? Thanks!

@rellfy
Copy link
Owner

rellfy commented Mar 29, 2025

Hi @cyborg42. Thanks for the PR! Sorry for the delay in getting to this.

I believe the addition of ToolCallDelta is a breaking change because the tool_calls field of ChatCompletionMessage changed to the new type -- but this is fine if required due to underlying API updates.

I had a quick look at OpenAI's API and couldn't find the index field. What is the purpose of index? (would be good to have a comment explaining it too!).

The addition of FunctionLiteral is also a breaking change as it will require users to update to the new type. Maybe we can use an enum here as it would be forward compatible if a new tool type is ever added?

src/chat.rs Outdated
///
/// [API Reference](https://platform.openai.com/docs/api-reference/chat/create#chat/create-function_call)
///
/// Deprecated, use `tool_calls` instead

Choose a reason for hiding this comment

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

This can leverage Rust's #[deprecated] attribute.

src/chat.rs Outdated
///
/// [API Reference](https://platform.openai.com/docs/api-reference/chat/create#chat/create-function_call)
///
/// Deprecated, use `tool_calls` instead

Choose a reason for hiding this comment

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

This can leverage Rust's #[deprecated] attribute.

@JeanMertz
Copy link

I came looking for the strict field in this crate, and found this PR, love it!

I'll give it a spin in the project I'm working on, and report back any findings.

@JeanMertz
Copy link

I suspect this PR still needs more work. I tried the branch, but ChatCompletionMessageDelta::tool_calls is always None (whereas ChatCompletionMessageDelta::function_call is not).

@cyborg42 cyborg42 marked this pull request as draft May 8, 2025 09:21
@tusharz1
Copy link

tusharz1 commented Aug 4, 2025

@rellfy any update on this?

}
}

#[derive(Deserialize, Serialize, Clone, Debug, Eq, PartialEq)]

Choose a reason for hiding this comment

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

Suggested change
#[derive(Deserialize, Serialize, Clone, Debug, Eq, PartialEq)]
#[derive(Deserialize, Serialize, Clone, Debug, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]

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.

4 participants