ededddy / groq-api-rs Goto Github PK
View Code? Open in Web Editor NEWA Rust Client For groq Inference API
Home Page: https://docs.rs/groq-api-rs/latest/groq_api_rs/
A Rust Client For groq Inference API
Home Page: https://docs.rs/groq-api-rs/latest/groq_api_rs/
Having "groq_instance" as a struct field is pretty useless since you cannot add messages to it at all ->
async fn send_request(
&mut self,
req: &crate::ai::request::Request,
) -> Option<crate::ai::response::Response> {
let request: builder::RequestBuilder = self.get_builder_instance_based_on_config();
self.groq_instance = **self.groq_instance**(error here).add_message(Message::UserMessage {
content: Some(req.get_request_string().clone()),
name: Some("user".to_string()),
role: None,
tool_call_id: None,
});
}
error:
cannot move out of `__self.groq_instance` which is behind a mutable reference
move occurs because `__self.groq_instance` has type `Groq`, which does not implement the `Copy` trait
Maybe it is also best to make the "add_message" and other function take &mut self instead of just mut self (returning nothing also).
I think a quick fix would be to just add Clone atr to Groq struct but that would patch the hole but not the problem since Clone is slow to use for every req.
Very critical because there is literally no workaround other than creating a new instance of the struct.
Creating "RequestBuilder" struct gets quite lengthy if you have a custom configuration that you would like to load. Example
It would be much more useful to have either a class passed into the "new" function or have a function taking all of the parameters and loading them into the class.
Hi!
I may not understand some of the consequences of making a struct Hashable via "#[derive(Hash)]", but could you do that? It would be very useful since, at the moment, I had to make a work-around by ->
`pub struct HashableGroq {
groq_instance: Groq,
identifier: String,
}
impl Hash for HashableGroq {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.identifier.hash(state);
}
}
impl HashableGroq {
pub fn new() -> Self {
return Self {
groq_instance: Groq::new(""),
identifier: generate_random_string(10),
};
}
pub fn get_groq_instance(&mut self) -> &mut Groq {
return &mut self.groq_instance;
}
}`
Thanks!
Rust does not have generators at the moment (generator is a nightly experimental api), so in the end you would need to do async r/w to a vec.
atm, the stream implementation is naive and group as vector as return.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.