Skip to content

Commit

Permalink
V2.10.1 Fixed stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ValgulNecron committed Jul 22, 2024
1 parent 8c6aa97 commit 466565d
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 163 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ toml = "0.8.15"
num-bigint = "0.4.6"
text-to-png = "0.2.0"
thiserror = "1.0.63"
songbird = "0.4.3"

[build-dependencies]
tonic-build = "0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
- [X] Video translation.
- [X] Ask a question and reply the response.

- Music module: (Not sure if I will do this one. since it broke tos)
- Audio module: (Not sure if I will do this one. since it broke tos (in some case))
- [ ] Play music from file upload.

- General module:
Expand Down
3 changes: 1 addition & 2 deletions src/command/run/ai/transcript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub async fn run(
.clone()
.unwrap_or_default();
// check the last 3 characters of the url if it v1/ or v1 or something else
let api_base_url = if api_base_url.ends_with("v1/") {
let url = if api_base_url.ends_with("v1/") {
format!("{}audio/transcriptions/", api_base_url)
} else if api_base_url.ends_with("v1") {
format!("{}/audio/transcriptions/", api_base_url)
Expand All @@ -172,7 +172,6 @@ pub async fn run(
.text("language", lang)
.text("response_format", "json");

let url = format!("{}transcriptions", api_base_url);
let response_result = client
.post(url)
.headers(headers)
Expand Down
8 changes: 5 additions & 3 deletions src/command/run/ai/translation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub async fn run(
let map = get_option_map_string_subcommand(command_interaction);
let attachment_map = get_option_map_attachment_subcommand(command_interaction);
let lang = map
.get(&String::from("prompt"))
.get(&String::from("lang"))
.unwrap_or(DEFAULT_STRING)
.clone();

Expand Down Expand Up @@ -139,6 +139,7 @@ pub async fn run(
.ai_transcription_model
.clone()
.unwrap_or_default();
trace!("{} {}", token, model);
let api_base_url = config
.ai
.transcription
Expand All @@ -153,6 +154,7 @@ pub async fn run(
} else {
format!("{}/v1/audio/translations/", api_base_url)
};
trace!("{}", api_base_url);
headers.insert(
AUTHORIZATION,
HeaderValue::from_str(&format!("Bearer {}", token)).unwrap(),
Expand All @@ -174,10 +176,10 @@ pub async fn run(
.multipart(form)
.send()
.await;
let response = response_result.map_err(|e| FollowupError::WebRequest(format!("{:?}", e)))?;
let response = response_result.map_err(|e| FollowupError::WebRequest(format!("1{:?}", e)))?;
let res_result: Result<Value, reqwest::Error> = response.json().await;

let res = res_result.map_err(|e| FollowupError::WebRequest(format!("{:?}", e)))?;
let res = res_result.map_err(|e| FollowupError::WebRequest(format!("2{:?}", e)))?;

trace!("{}", res);
let text = res["text"].as_str().unwrap_or("");
Expand Down
24 changes: 11 additions & 13 deletions src/grpc_server/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ pub async fn grpc_server_launcher(
};

// Configure the reflection service and register the file descriptor set for the shard service
let reflection = tonic_reflection::server::Builder::configure()
let reflection = match tonic_reflection::server::Builder::configure()
.register_encoded_file_descriptor_set(service::shard::proto::SHARD_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(service::info::proto::INFO_FILE_DESCRIPTOR_SET)
.register_encoded_file_descriptor_set(service::command::proto::COMMAND_FILE_DESCRIPTOR_SET);
.register_encoded_file_descriptor_set(service::command::proto::COMMAND_FILE_DESCRIPTOR_SET).build() {
Ok(reflection) => reflection,
Err(e) => {
error!("Failed to build the reflection service: {}", e);
return;
}
};

let is_tls = grpc_config.use_tls;
trace!("TLS: {}", is_tls);
Expand All @@ -82,19 +88,11 @@ pub async fn grpc_server_launcher(
let tls_config = tonic::transport::ServerTlsConfig::new().identity(identity);
builder = builder.tls_config(tls_config).unwrap()
}
let mut builder = builder
let builder = builder
.add_service(get_shard_server(shard_service))
.add_service(get_info_server(info_service))
.add_service(get_command_server(command_service));

let reflection = match reflection.build() {
Ok(reflection) => reflection,
Err(e) => {
error!("Failed to build reflection service: {}", e);
return;
}
};
builder = builder.add_service(reflection);
.add_service(get_command_server(command_service))
.add_service(reflection);

// Serve the gRPC server
builder.serve(addr.parse().unwrap()).await.unwrap()
Expand Down
Loading

0 comments on commit 466565d

Please sign in to comment.