Skip to content
Draft
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
260 changes: 260 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ version = "0.0.2"
edition = "2024"

[dependencies]
async-trait = "0.1.89"
thiserror = "2.0.17"

[dev-dependencies]
tokio = { version = "1.49.0", features = ["full"] }
15 changes: 15 additions & 0 deletions examples/basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use parrot::llm::get_available_models;

#[tokio::main]
async fn main() {
let available_models = get_available_models().expect("failed to get models");

for model in available_models.into_iter() {
let out = model
.prompt("reply with a check mark if this request is successful")
.await
.expect("failed to prompt");

println!("{} - {}", model.get_name(), out.trim());
}
}
5 changes: 4 additions & 1 deletion src/llm/anthropic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::error::LLMError;

use super::{Model, ModelFactory, constants::names};

use async_trait::async_trait;

use std::env::var;

const ANTHROPIC_API_KEY: &str = "ANTHROPIC_API_KEY";
Expand All @@ -21,12 +23,13 @@ impl ModelFactory for Anthropic {
}
}

#[async_trait]
impl Model for Anthropic {
fn get_name(&self) -> String {
names::ANTHROPIC.into()
}

fn prompt(&self, _: &str) -> Result<String, LLMError> {
async fn prompt(&self, _: &str) -> Result<String, LLMError> {
unimplemented!("anthropic api")
}
}
5 changes: 4 additions & 1 deletion src/llm/claude.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::process::Command;

use async_trait::async_trait;

use crate::{
error::LLMError,
llm::{Model, ModelFactory, constants::names},
Expand All @@ -20,12 +22,13 @@ impl ModelFactory for Claude {
}
}

#[async_trait]
impl Model for Claude {
fn get_name(&self) -> String {
names::CLAUDE.into()
}

fn prompt(&self, input: &str) -> Result<String, LLMError> {
async fn prompt(&self, input: &str) -> Result<String, LLMError> {
let out = Command::new(CLAUDE_CLI_NAME)
.args([input, "-p"])
.output()
Expand Down
5 changes: 4 additions & 1 deletion src/llm/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use async_trait::async_trait;

use crate::{
error::LLMError,
llm::{Model, ModelFactory, constants::names},
Expand All @@ -20,12 +22,13 @@ impl ModelFactory for CursorCLI {
}
}

#[async_trait]
impl Model for CursorCLI {
fn get_name(&self) -> String {
names::CURSOR.into()
}

fn prompt(&self, input: &str) -> Result<String, LLMError> {
async fn prompt(&self, input: &str) -> Result<String, LLMError> {
let out = Command::new(CURSOR_CLI_NAME)
.args([input, "-p"])
.output()
Expand Down
Loading
Loading