Comments (5)
Please use fork for personal branches and contributions
from async-openai.
@64bit Why did you want Config: Clone
in the first place? I looked through the codebase, it seems config.clone
is never used. So, after removing the trait bound Clone
in Config
, you can just use a box like
pub struct Client {
...
config: Box<dyn Config>,
...
}
No need to propagate the generics everywhere
from async-openai.
Also, I can't push branches:
(base) ➜ async-openai git:(deip/common-config-trait) git push --set-upstream origin deip/common-config-trait
ERROR: Permission to 64bit/async-openai.git denied to deipkumar.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Do I need to be added as a contributor?
from async-openai.
I do not recall :)
Your idea of Box-ing it is actually good. Not sure what the rippling effects would be but worth exploring.
from async-openai.
Having a trait with associated type would allow the idea to work using only generics (no need for dynamic dispatch):
// Only Config seems to be polymorphic here.
// In any case, one can always have client: impl GenericClient<Config=C> below (see my comment on #125 below)
fn use_client<C: GenericConfig>(client: Client<C>) {
let models = client.models();
// ...
}
fn main() {
let openai_config = OpenAIConfig::default();
let openai_client = Client::with_config(openai_config);
// No need for dynamic dispatch: the types in your problem are known at compile time. No boxing means zero cost dispatch at run time.
use_client(openai_client);
let azure_config = AzureConfig::default();
let azure_client = Client::with_config(azure_config);
use_client(azure_client);
}
Related to a comment of mine (#125 (comment)).
Keep in mind that the suggestion in the comment does allow dynamic dispatch using a simple design widely used in the Rust world (Iterator
s use it). It's just that dynamic dispatch is not required for solving the present issue.
from async-openai.
Related Issues (20)
- Example of multiple function calls HOT 2
- how to change base_url? HOT 2
- text to speech - flac format does not seem to work HOT 9
- Auto Generation from OpenAPI spec HOT 2
- Add support for llama.cpp completions HOT 2
- impls.rs: AssistantTools HOT 3
- query for client files list seems to be missing HOT 1
- Why is there a \n\n prepended to the response? HOT 2
- Changing base url - Usage with open source LLM - Invalid status code: 404 Not Found HOT 3
- Stabilizing wasm target HOT 2
- Support text-to-speech (TTS) streaming functionality HOT 12
- Advanced error handling for OpenAI-like LLM APIs
- Test compilation failed HOT 2
- Support variable length embeddings HOT 3
- OpenAI transcriptions api language field is invalid ! HOT 1
- Embedding deserialization error when using encoding_format `EncodingFormat::Base64`
- Ollama AI Chat Completion Example / OpenAI Compatibility HOT 3
- Sync OpenAPI spec changes after 4th Jan 24 HOT 1
- Initialize `Client` with custom HTTP client, config, and backoff HOT 3
- Usage of std::thread::sleep inside async function in assistants example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async-openai.