Skip to content

Commit 6a7d69a

Browse files
committed
Updated example [skip ci]
1 parent e38f23e commit 6a7d69a

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

examples/cohere/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ publish = false
88
pgvector = { path = "../..", features = ["postgres"] }
99
postgres = "0.19"
1010
serde_json = "1"
11-
ureq = { version = "2", features = ["json"] }
11+
ureq = { version = "3", features = ["json"] }

examples/cohere/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ fn fetch_embeddings(texts: &[&str], input_type: &str) -> Result<Vec<Vec<u8>>, Bo
3939
let api_key = std::env::var("CO_API_KEY").or(Err("Set CO_API_KEY"))?;
4040

4141
let response: Value = ureq::post("https://api.cohere.com/v1/embed")
42-
.set("Authorization", &format!("Bearer {}", api_key))
43-
.send_json(ureq::json!({
42+
.header("Authorization", &format!("Bearer {}", api_key))
43+
.send_json(serde_json::json!({
4444
"texts": texts,
4545
"model": "embed-english-v3.0",
4646
"input_type": input_type,
4747
"embedding_types": &["ubinary"],
4848
}))?
49-
.into_json()?;
49+
.body_mut()
50+
.read_json()?;
5051

5152
let embeddings = response["embeddings"]["ubinary"]
5253
.as_array()

0 commit comments

Comments
 (0)