Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

1.4 KB
Raw Blame
use crate::prelude::ServerToolUse;
use crate::types::response::Citation;
use crate::types::response::code_execution::{
    BashCodeExecutionResponse, TextEditorCodeExecutionResponse,
};
use async_openai::error::OpenAIError;
use async_openai::types::chat::CreateChatCompletionStreamResponse;
use futures::Stream;
use std::pin::Pin;

/// Items that are returned in an Anthropic stream but not supported by OpenAI
#[derive(Clone, Debug, PartialEq)]
pub enum AnthropicResponseExtension {
    Citation(Citation),
    BashCodeExecutionToolResponse(BashCodeExecutionResponse),
    TextEditorCodeExecutionToolResponse(TextEditorCodeExecutionResponse),
    ServerToolUse(ServerToolUse),
}

/// A standard OpenAI response item or an item only sent by Anthropic
#[derive(Clone, Debug, PartialEq)]
pub enum ExtendedAnthropicStreamItem {
    OpenAI(CreateChatCompletionStreamResponse),
    Extension(AnthropicResponseExtension),
}

impl From<CreateChatCompletionStreamResponse> for ExtendedAnthropicStreamItem {
    fn from(value: CreateChatCompletionStreamResponse) -> Self {
        Self::OpenAI(value)
    }
}

impl From<AnthropicResponseExtension> for ExtendedAnthropicStreamItem {
    fn from(value: AnthropicResponseExtension) -> Self {
        Self::Extension(value)
    }
}

/// Full stream type of mixed openai items and anthropic items
pub type ExtendedStream =
    Pin<Box<dyn Stream<Item = Result<ExtendedAnthropicStreamItem, OpenAIError>> + Send>>;