Skip to content

Commit

Permalink
refactor: make ChatOutput public
Browse files Browse the repository at this point in the history
  • Loading branch information
moldhouse committed Oct 23, 2024
1 parent ae378aa commit 5d5c445
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,16 @@ impl<'a> TaskChat<'a> {
}

#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct Choice {
pub struct ChatOutput {
pub message: Message<'static>,
pub finish_reason: String,
}

#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct ChatResponse {
pub choices: Vec<Choice>,
pub struct ResponseChat {
pub choices: Vec<ChatOutput>,
}

#[derive(Serialize)]
struct ChatBody<'a> {
/// Name of the model tasked with completing the prompt. E.g. `luminous-base"`.
Expand Down Expand Up @@ -125,9 +126,9 @@ impl<'a> ChatBody<'a> {
}

impl<'a> Task for TaskChat<'a> {
type Output = Choice;
type Output = ChatOutput;

type ResponseBody = ChatResponse;
type ResponseBody = ResponseChat;

fn build_request(
&self,
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ mod semantic_embedding;
mod tokenization;
use std::time::Duration;

use chat::Choice;
use http::HttpClient;
use semantic_embedding::{BatchSemanticEmbeddingOutput, SemanticEmbeddingOutput};
use tokenizers::Tokenizer;

pub use self::{
chat::{Role, TaskChat},
chat::{ChatOutput, Message, Role, TaskChat},
completion::{CompletionOutput, Sampling, Stopping, TaskCompletion},
detokenization::{DetokenizationOutput, TaskDetokenization},
explanation::{
Expand Down Expand Up @@ -213,7 +212,7 @@ impl Client {
/// Ok(())
/// }
/// ```
pub async fn chat(&self, task: &TaskChat<'_>, model: &str, how: &How) -> Result<Choice, Error> {
pub async fn chat(&self, task: &TaskChat<'_>, model: &str, how: &How) -> Result<ChatOutput, Error> {
self.http_client
.output_of(&task.with_model(model), how)
.await
Expand Down

0 comments on commit 5d5c445

Please sign in to comment.