We should probably use RwLock for API key & base url?
Problem
We're currently using Mutexes but it makes sense to use a RwLock since it allows multiple readers at the same time.
Solution
Use RwLock
Let me know your thoughts
TBH, I would rather have a structure holding the key instead of setting it globally.
TBH, I would rather have a structure holding the key instead of setting it globally.
We could keep the option of setting a global key, for simplicity, and also allow for specifying a key (to override the global) within the builder pattern for each API. This keeps it simple for users that only need to use a single key while allowing for users that need multiple keys.
TBH, I would rather have a structure holding the key instead of setting it globally.
Same. To be honest, I don't expect a library like this to even assume any defaults from the env.
IMHO
- It's not idiomatic Rust.
- It's not hard to program a local struct.
- Tons of libraries provide a
Clientstruct. - Why would you make global variables at all in 2024 (or in 2022, when you made a first commit), considering how they are perceived now?
Sorry, if I sound too critical. But I just got highly triggered :laughing:
You have a very good and interesting library, but I would certainly NOT use it in my projects.
What if I want to build a multi-agent system? Use different, but OpenAI compatible API, different keys for different projects?, etc.