dongri / openai-api-rs

OpenAI API client library for Rust (unofficial)
https://docs.rs/openai-api-rs
MIT License
290 stars 47 forks source link

Fields of `Tool` are private #59

Closed o-agassizii closed 8 months ago

o-agassizii commented 8 months ago

Describe the bug

Recently, functions field was marked as deprecated and we are told to use tools instead.

https://github.com/dongri/openai-api-rs/pull/54

However, I am not able to construct an instance of Tools because the fields are private and nor is there any Tools::new() function to use nor any ToolBuilder one can use.

To Reproduce

Try to make an instance of Tool from a different crate using this crate.

Code snippets

let req = ChatCompletionRequest {
    // ...
    tools: Some(vec![Tool {
        tool_type: "function".into(),
        function: Function {
            // ...
        } }]),
    tool_choice: Some(ToolChoiceType::ToolChoice { tool: Tool {
        tool_type: "function".into(),
        function: Function {
            // ...
        } }}),
}

Can't do this because the fields in Tool are private.

OS

Any

Rust version

cargo 1.75.0

Library version

openai-api-rs v2.1.7

dongri commented 8 months ago

@o-agassizii Thank your for report the bug https://github.com/dongri/openai-api-rs/blob/v3.0.0/examples/function_call.rs#L38-L50 I Fixed this issue