Skip to content

Commit

Permalink
Merge pull request #27 from Aleph-Alpha/chat-response
Browse files Browse the repository at this point in the history
refactor: make ChatOutput public
moldhouse authored Oct 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents ae378aa + 5d5c445 commit 6f80217
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
@@ -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"`.
@@ -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,
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::{
@@ -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

0 comments on commit 6f80217

Please sign in to comment.