Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/audio sessions #58

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions crates/edgen_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

extern crate alloc;

use std::future::Future;
use std::time::Duration;

pub mod llm;
Expand All @@ -27,6 +28,9 @@ pub mod settings;

pub mod perishable;

/// A generic [`Box`]ed [`Future`], used to emulate `async` functions in traits.
pub type BoxedFuture<'a, T> = Box<dyn Future<Output = T> + Send + Unpin + 'a>;

/// Return the [`Duration`] that cleanup threads should wait before looking for and freeing unused
/// resources, after last doing so.
pub fn cleanup_interval() -> Duration {
Expand Down
11 changes: 3 additions & 8 deletions crates/edgen_core/src/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* limitations under the License.
*/

use core::future::Future;
use crate::BoxedFuture;
use core::time::Duration;
use futures::Stream;
use serde::Serialize;
Expand Down Expand Up @@ -53,7 +53,7 @@ pub trait LLMEndpoint {
&'a self,
model_path: impl AsRef<Path> + Send + 'a,
args: CompletionArgs,
) -> Box<dyn Future<Output = Result<String, LLMEndpointError>> + Send + Unpin + 'a>;
) -> BoxedFuture<Result<String, LLMEndpointError>>;

/// Given a prompt with several arguments, return a [`Box`]ed [`Future`] which may eventually
/// contain a [`Stream`] of [`String`] chunks of the prompt completion, acquired as they get
Expand All @@ -62,12 +62,7 @@ pub trait LLMEndpoint {
&'a self,
model_path: impl AsRef<Path> + Send + 'a,
args: CompletionArgs,
) -> Box<
dyn Future<Output = Result<Box<dyn Stream<Item = String> + Unpin + Send>, LLMEndpointError>>
+ Send
+ Unpin
+ 'a,
>;
) -> BoxedFuture<Result<Box<dyn Stream<Item = String> + Unpin + Send>, LLMEndpointError>>;

/// Unloads everything from memory.
fn reset(&self);
Expand Down
3 changes: 1 addition & 2 deletions crates/edgen_core/src/perishable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ where
let check_date = if accessed + ttl > Instant::now() {
accessed + ttl
} else {
// TODO when something "perishes", the CPU gets hogged by this task, probably
accessed + Duration::from_secs(5)
Instant::now() + Duration::from_secs(5)
};

select! {
Expand Down
Loading
Loading