Giter Site home page Giter Site logo

groq-api-rs's Issues

Groq param in structure useless

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.

Easier way to create a new "RequestBuilder" 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.

Make "Groq" struct hashable?

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!

Readme not accurate

The readme sample code is not up to date. As mentioned in #13 the new request format should contain

let mut client = Groq::new()...
... .request(client)...

and not

let client = Groq::new()...
... .request(client)...

See #13 for more details about this change and it's reasoning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.