use crate::client::Anthropic;
use crate::core::error::Error;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Completion {
pub id: String,
pub completion: String,
pub model: String,
pub stop_reason: Option<String>,
#[serde(flatten)]
pub extra: Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CompletionCreateParams {
pub model: String,
pub max_tokens_to_sample: u64,
pub prompt: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub stream: Option<bool>,
#[serde(flatten)]
pub extra: Value,
}
pub struct Completions<'a> {
client: &'a Anthropic,
}
impl<'a> Completions<'a> {
pub(crate) fn new(client: &'a Anthropic) -> Self {
Self { client }
}
pub async fn create(&self, params: CompletionCreateParams) -> Result<Completion, Error> {
self.client.post("/v1/complete", ¶ms).await
}
}