Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make ChatOutput public #27

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading