update format
This commit is contained in:
+7
-3
@@ -1,7 +1,9 @@
|
|||||||
pub mod qwen2_5vl;
|
pub mod qwen2_5vl;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use candle_core::{DType, Device};
|
use candle_core::{DType, Device};
|
||||||
use openai_dive::v1::resources::chat::{ChatCompletionChunkResponse, ChatCompletionParameters, ChatCompletionResponse};
|
use openai_dive::v1::resources::chat::{
|
||||||
|
ChatCompletionChunkResponse, ChatCompletionParameters, ChatCompletionResponse,
|
||||||
|
};
|
||||||
use rocket::futures::Stream;
|
use rocket::futures::Stream;
|
||||||
|
|
||||||
pub trait GenerateModel {
|
pub trait GenerateModel {
|
||||||
@@ -9,6 +11,8 @@ pub trait GenerateModel {
|
|||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
fn generate(&mut self, mes: ChatCompletionParameters) -> Result<ChatCompletionResponse>;
|
fn generate(&mut self, mes: ChatCompletionParameters) -> Result<ChatCompletionResponse>;
|
||||||
fn generate_stream(&mut self, mes: ChatCompletionParameters) -> Result<impl Stream<Item = Result<ChatCompletionChunkResponse, anyhow::Error>>>;
|
fn generate_stream(
|
||||||
|
&mut self,
|
||||||
|
mes: ChatCompletionParameters,
|
||||||
|
) -> Result<impl Stream<Item = Result<ChatCompletionChunkResponse, anyhow::Error>>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
pub mod config;
|
pub mod config;
|
||||||
|
pub mod generate;
|
||||||
pub mod model;
|
pub mod model;
|
||||||
pub mod processor;
|
pub mod processor;
|
||||||
pub mod generate;
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
|
pub mod img_utils;
|
||||||
pub mod tensor_utils;
|
pub mod tensor_utils;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod img_utils;
|
|
||||||
pub mod video_utils;
|
pub mod video_utils;
|
||||||
+3
-1
@@ -3,7 +3,9 @@ use candle_core::{DType, Device};
|
|||||||
use candle_transformers::generation::LogitsProcessor;
|
use candle_transformers::generation::LogitsProcessor;
|
||||||
use openai_dive::v1::resources::{
|
use openai_dive::v1::resources::{
|
||||||
chat::{
|
chat::{
|
||||||
ChatCompletionChoice, ChatCompletionChunkChoice, ChatCompletionChunkResponse, ChatCompletionResponse, ChatMessage, ChatMessageContent, DeltaChatMessage, DeltaFunction, DeltaToolCall, Function, ToolCall
|
ChatCompletionChoice, ChatCompletionChunkChoice, ChatCompletionChunkResponse,
|
||||||
|
ChatCompletionResponse, ChatMessage, ChatMessageContent, DeltaChatMessage, DeltaFunction,
|
||||||
|
DeltaToolCall, Function, ToolCall,
|
||||||
},
|
},
|
||||||
shared::FinishReason,
|
shared::FinishReason,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
|
||||||
use aha::models::qwen2_5vl::config::Config;
|
use aha::models::qwen2_5vl::config::Config;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn qwen2_5vl_config() -> Result<()> {
|
fn qwen2_5vl_config() -> Result<()> {
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
use std::{pin::pin, time::Instant};
|
use std::{pin::pin, time::Instant};
|
||||||
|
|
||||||
use aha::{models::{qwen2_5vl::generate::Qwen2_5VLGenerateModel, GenerateModel}, ModelType};
|
use aha::{
|
||||||
use anyhow::{Result};
|
ModelType,
|
||||||
|
models::{GenerateModel, qwen2_5vl::generate::Qwen2_5VLGenerateModel},
|
||||||
|
};
|
||||||
|
use anyhow::Result;
|
||||||
use candle_core::{DType, Device};
|
use candle_core::{DType, Device};
|
||||||
use openai_dive::v1::resources::chat::ChatCompletionParameters;
|
use openai_dive::v1::resources::chat::ChatCompletionParameters;
|
||||||
use rocket::futures::StreamExt;
|
use rocket::futures::StreamExt;
|
||||||
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn qwen2_5vl_generate() -> Result<()> {
|
fn qwen2_5vl_generate() -> Result<()> {
|
||||||
// test with cpu :(太慢了, : RUST_BACKTRACE=1 cargo test qwen2_5vl_generate -- --nocapture
|
// test with cpu :(太慢了, : RUST_BACKTRACE=1 cargo test qwen2_5vl_generate -- --nocapture
|
||||||
@@ -40,7 +42,7 @@ fn qwen2_5vl_generate() -> Result<()> {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
let mes:ChatCompletionParameters = serde_json::from_str(message)?;
|
let mes: ChatCompletionParameters = serde_json::from_str(message)?;
|
||||||
let i_start = Instant::now();
|
let i_start = Instant::now();
|
||||||
// let mut model = Qwen2_5VLGenerateModel::init(model_path, &device, dtype)?;
|
// let mut model = Qwen2_5VLGenerateModel::init(model_path, &device, dtype)?;
|
||||||
let mut model = ModelType::init(ModelType::Qwen2_5VL, model_path, None, None)?;
|
let mut model = ModelType::init(ModelType::Qwen2_5VL, model_path, None, None)?;
|
||||||
@@ -53,7 +55,6 @@ fn qwen2_5vl_generate() -> Result<()> {
|
|||||||
let i_duration = i_start.elapsed();
|
let i_duration = i_start.elapsed();
|
||||||
println!("Time elapsed in generate is: {:?}", i_duration);
|
println!("Time elapsed in generate is: {:?}", i_duration);
|
||||||
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ async fn qwen2_5vl_stream() -> Result<()> {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
let mes:ChatCompletionParameters = serde_json::from_str(message)?;
|
let mes: ChatCompletionParameters = serde_json::from_str(message)?;
|
||||||
let i_start = Instant::now();
|
let i_start = Instant::now();
|
||||||
// let mut model = Qwen2_5VLGenerateModel::init(model_path, &device, dtype)?;
|
// let mut model = Qwen2_5VLGenerateModel::init(model_path, &device, dtype)?;
|
||||||
let mut model = ModelType::init(ModelType::Qwen2_5VL, model_path, None, None)?;
|
let mut model = ModelType::init(ModelType::Qwen2_5VL, model_path, None, None)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user