-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/PADW 65 GUC Based Transformer Server Type (#11)
* Integrating transformer_client to enable GUC-based switching between different transformer server types (Ollama or OpenAI), enhancing flexibility for transformer server configuration. * Refactor TransformerServerType with FromStr implementation - Implemented FromStr for TransformerServerType to simplify string parsing. - Improved error handling by returning &'static str for invalid server types. * Logging Cleanup
- Loading branch information
Showing
8 changed files
with
59 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod ollama_client; | ||
pub mod openai_client; | ||
pub mod transformer_client; | ||
mod ollama_client; | ||
mod openai_client; | ||
pub mod setup; | ||
pub mod guc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::model::prompt_template::PromptTemplate; | ||
use super::{guc, openai_client, ollama_client}; | ||
use TransformerServerType::{OpenAI, Ollama}; | ||
use std::str::FromStr; | ||
|
||
pub enum TransformerServerType { | ||
OpenAI, | ||
Ollama | ||
} | ||
|
||
impl FromStr for TransformerServerType { | ||
type Err = &'static str; | ||
|
||
fn from_str(s: &str) -> Result<TransformerServerType, Self::Err> { | ||
match s.to_lowercase().as_str() { | ||
"openai" => Ok(OpenAI), | ||
"ollama" => Ok(Ollama), | ||
_ => Err("Invalid Transformer Server Type"), | ||
} | ||
} | ||
} | ||
|
||
pub async fn send_request(new_json: &str, template_type: PromptTemplate, col: &u32, hints: &str) -> Result<serde_json::Value, Box<dyn std::error::Error>> { | ||
|
||
let transformer_server_type_str = guc::get_guc(guc::PgAutoDWGuc::TransformerServerType).ok_or("GUC: Transformer Server Type is not set.")?; | ||
|
||
let transformer_server_type = transformer_server_type_str.parse::<TransformerServerType>() | ||
.map_err(|e| format!("Error parsing Transformer Server Type: {}", e))?; | ||
|
||
match transformer_server_type { | ||
OpenAI => openai_client::send_request(new_json, template_type, col, hints).await, | ||
Ollama => ollama_client::send_request(new_json, template_type, col, hints).await, | ||
} | ||
} | ||
|