-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed fal.ai, added together.ai, free /flux command & upgraded llam…
…a model to 70b, maybe ill do something with the free 405b too
- Loading branch information
1 parent
3181c93
commit df281cc
Showing
7 changed files
with
120 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mod fal; | ||
mod openai; | ||
mod together; | ||
|
||
pub use fal::*; | ||
pub use openai::*; | ||
pub use together::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use reqwest::Client; | ||
use serde::{Deserialize, Serialize}; | ||
use std::env; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct ImageRequest { | ||
pub model: String, | ||
pub prompt: String, | ||
pub width: u32, | ||
pub height: u32, | ||
pub steps: u32, | ||
pub n: u32, | ||
pub response_format: String, | ||
} | ||
|
||
pub struct TogetherClient { | ||
client: Client, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct ImageResponse { | ||
// pub id: String, | ||
// pub model: String, | ||
// pub object: String, | ||
pub data: Vec<ImageData>, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct ImageData { | ||
pub timings: Timings, | ||
// pub index: u32, | ||
pub b64_json: String, | ||
} | ||
|
||
#[derive(Deserialize, Debug)] | ||
pub struct Timings { | ||
pub inference: f64, | ||
} | ||
|
||
impl TogetherClient { | ||
pub fn new() -> Self { | ||
Self { | ||
client: Client::new(), | ||
} | ||
} | ||
|
||
pub async fn submit_request( | ||
&self, | ||
prompt: ImageRequest, | ||
) -> Result<ImageResponse, reqwest::Error> { | ||
// base64 image | ||
|
||
let response = self | ||
.client | ||
.post("https://api.together.xyz/v1/images/generations") | ||
.header( | ||
"Authorization", | ||
format!("Bearer {}", env::var("TOGETHER_KEY").unwrap()), | ||
) | ||
.header("Content-Type", "application/json") | ||
.json(&prompt) | ||
.send() | ||
.await?; | ||
|
||
let response = response.json::<ImageResponse>().await?; | ||
|
||
Ok(response) | ||
} | ||
} |
Oops, something went wrong.