Abraxas-365 / Abraxas-365/langchain-rust

Allow `OpenAiToolAgentBuilder` to accept a Vec rather than an Array for `tools`

Ouverte
#323 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
1.3k
Forks
177
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

**Is your feature request related to a problem? Please describe.**

I don't think it's possible to have the tools set dynamically (i.e. not at compile time) because it only accepts an array, not a Vec. If it was changed to a Vec, you can still set it in the same way it is in the example using `vec![..]`.

**Describe the solution you'd like**

Change the signature to a Vec rather than an array.

**Describe alternatives you've considered**

I tried just setting the variables directly, but they're not public.

**Additional context**

I've already implemented this in a private fork. It's basically a 3 line change. Let me know if you want me to open a PR.

```
diff --git a/examples/open_ai_tools_agent.rs b/examples/open_ai_tools_agent.rs
index 842b615..a84aa68 100644
--- a/examples/open_ai_tools_agent.rs
+++ b/examples/open_ai_tools_agent.rs
@@ -35,7 +35,7 @@ async fn main() {
let tool_calc = Date {};
let command_executor = CommandExecutor::default();
let agent = OpenAiToolAgentBuilder::new()
- .tools(&[
+ .tools(&vec![
Arc::new(serpapi_tool),
Arc::new(tool_calc),
Arc::new(command_executor),
diff --git a/src/agent/open_ai_tools/builder.rs b/src/agent/open_ai_tools/builder.rs
index a51f8d7..21793cb 100644
--- a/src/agent/open_ai_tools/builder.rs
+++ b/src/agent/open_ai_tools/builder.rs
@@ -25,8 +25,8 @@ impl OpenAiToolAgentBuilder {
}
}

- pub fn tools(mut self, tools: &[Arc]) -> Self {
- self.tools = Some(tools.to_vec());
+ pub fn tools(mut self, tools: &Vec>) -> Self {
+ self.tools = Some(tools.clone());
self
}
```

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.