Skip to content

Commit 1f8d139

Browse files
committed
make ToolDyn public
1 parent 041eec9 commit 1f8d139

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

async-openai/src/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ where
485485
if message.data == "[DONE]" {
486486
break;
487487
}
488-
488+
println!("message: {:?}", message.data);
489489
let response = match serde_json::from_str::<O>(&message.data) {
490490
Err(e) => Err(map_deserialization_error(e, message.data.as_bytes())),
491491
Ok(output) => Ok(output),

async-openai/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ mod projects;
149149
mod runs;
150150
mod steps;
151151
mod threads;
152-
mod tools;
152+
pub mod tools;
153153
pub mod traits;
154154
pub mod types;
155155
mod uploads;
@@ -181,7 +181,6 @@ pub use projects::Projects;
181181
pub use runs::Runs;
182182
pub use steps::Steps;
183183
pub use threads::Threads;
184-
pub use tools::{Tool, ToolManager, ToolCallStreamManager};
185184
pub use uploads::Uploads;
186185
pub use users::Users;
187186
pub use vector_store_file_batches::VectorStoreFileBatches;

async-openai/src/tools.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub trait Tool: Send + Sync {
6565

6666
/// A dynamic trait for tools that allows for runtime tool management.
6767
/// This trait provides a way to work with tools without knowing their concrete types at compile time.
68-
trait ToolDyn: Send + Sync {
68+
pub trait ToolDyn: Send + Sync {
6969
/// Returns the tool's definition as a ChatCompletionTool.
7070
fn definition(&self) -> ChatCompletionTool;
7171

examples/tool-call-stream/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use std::error::Error;
22
use std::io::{stdout, Write};
33

4+
use async_openai::tools::{Tool, ToolCallStreamManager, ToolManager};
45
use async_openai::types::{
56
ChatCompletionRequestAssistantMessageArgs, ChatCompletionRequestMessage,
67
ChatCompletionRequestUserMessageArgs, FinishReason,
78
};
89
use async_openai::{types::CreateChatCompletionRequestArgs, Client};
9-
use async_openai::{Tool, ToolCallStreamManager, ToolManager};
1010
use futures::StreamExt;
1111
use rand::seq::SliceRandom;
1212
use rand::{thread_rng, Rng};
@@ -67,7 +67,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
6767
}
6868

6969
if !is_end_with_tool_call {
70-
return Err("The response is not ended with tool call".into());
70+
println!("The response is not ended with tool call");
7171
}
7272
let tool_calls = tool_call_stream_manager.finish_stream();
7373
let function_responses = tool_manager.call(tool_calls.clone()).await;

examples/tool-call/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::io::{stdout, Write};
22

3+
use async_openai::tools::{Tool, ToolManager};
34
use async_openai::types::{
45
ChatCompletionRequestAssistantMessageArgs, ChatCompletionRequestMessage,
56
ChatCompletionRequestUserMessageArgs,
67
};
78
use async_openai::{types::CreateChatCompletionRequestArgs, Client};
8-
use async_openai::{Tool, ToolManager};
99
use futures::StreamExt;
1010
use rand::seq::SliceRandom;
1111
use rand::{thread_rng, Rng};

0 commit comments

Comments
 (0)