summaryrefslogtreecommitdiffstats
path: root/src/client/claude.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/claude.rs')
-rw-r--r--src/client/claude.rs44
1 files changed, 28 insertions, 16 deletions
diff --git a/src/client/claude.rs b/src/client/claude.rs
index 8a7b14c..d8046a9 100644
--- a/src/client/claude.rs
+++ b/src/client/claude.rs
@@ -22,30 +22,41 @@ impl ClaudeClient {
pub const PROMPTS: [PromptAction<'static>; 1] =
[("api_key", "API Key:", true, PromptKind::String)];
+}
- fn prepare_chat_completions(&self, data: ChatCompletionsData) -> Result<RequestData> {
- let api_key = self.get_api_key().ok();
+impl_client_trait!(
+ ClaudeClient,
+ (
+ prepare_chat_completions,
+ claude_chat_completions,
+ claude_chat_completions_streaming
+ ),
+ (noop_prepare_embeddings, noop_embeddings),
+ (noop_prepare_rerank, noop_rerank),
+);
- let body = claude_build_chat_completions_body(data, &self.model)?;
+fn prepare_chat_completions(
+ self_: &ClaudeClient,
+ data: ChatCompletionsData,
+) -> Result<RequestData> {
+ let api_key = self_.get_api_key().ok();
- let mut request_data = RequestData::new(API_BASE, body);
+ let body = claude_build_chat_completions_body(data, &self_.model)?;
- request_data.header("anthropic-version", "2023-06-01");
- if let Some(api_key) = api_key {
- request_data.header("x-api-key", api_key)
- }
+ let mut request_data = RequestData::new(API_BASE, body);
- Ok(request_data)
+ request_data.header("anthropic-version", "2023-06-01");
+ if let Some(api_key) = api_key {
+ request_data.header("x-api-key", api_key)
}
-}
-impl_client_trait!(
- ClaudeClient,
- claude_chat_completions,
- claude_chat_completions_streaming
-);
+ Ok(request_data)
+}
-pub async fn claude_chat_completions(builder: RequestBuilder) -> Result<ChatCompletionsOutput> {
+pub async fn claude_chat_completions(
+ builder: RequestBuilder,
+ _model: &Model,
+) -> Result<ChatCompletionsOutput> {
let res = builder.send().await?;
let status = res.status();
let data: Value = res.json().await?;
@@ -59,6 +70,7 @@ pub async fn claude_chat_completions(builder: RequestBuilder) -> Result<ChatComp
pub async fn claude_chat_completions_streaming(
builder: RequestBuilder,
handler: &mut SseHandler,
+ _model: &Model,
) -> Result<()> {
let mut function_name = String::new();
let mut function_arguments = String::new();