-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Chat Completions API (foundation-model-stack#240)
* Implement Chat Completions API Signed-off-by: declark1 <[email protected]> * Conditionally enable chat completions endpoint Signed-off-by: declark1 <[email protected]> * Update chat completions to chat completions detection, rename items for alignment Signed-off-by: declark1 <[email protected]> --------- Signed-off-by: declark1 <[email protected]>
- Loading branch information
Showing
4 changed files
with
98 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use tracing::{info, instrument}; | ||
|
||
use super::{ChatCompletionsDetectionTask, Error, Orchestrator}; | ||
use crate::clients::openai::{ChatCompletionsResponse, OpenAiClient}; | ||
|
||
impl Orchestrator { | ||
#[instrument(skip_all, fields(trace_id = ?task.trace_id, headers = ?task.headers))] | ||
pub async fn handle_chat_completions_detection( | ||
&self, | ||
task: ChatCompletionsDetectionTask, | ||
) -> Result<ChatCompletionsResponse, Error> { | ||
info!("handling chat completions detection task"); | ||
let client = self | ||
.ctx | ||
.clients | ||
.get_as::<OpenAiClient>("chat_generation") | ||
.expect("chat_generation client not found"); | ||
Ok(client.chat_completions(task.request, task.headers).await?) | ||
} | ||
} |
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