-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_bedrock_raw_generate.rs
51 lines (40 loc) · 1.16 KB
/
demo_bedrock_raw_generate.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use crate::bedrock::bedrock_client::{BedrockClient, BedrockClientOptions};
use crate::bedrock::model_info::{ModelInfo, ModelName};
pub async fn demo_generate_raw() {
let model_id = ModelInfo::from_model_name(ModelName::AnthropicClaudeHaiku1x);
let profile_name = "bedrock";
let region = "us-west-2";
let prompt = "Hi. In a short paragraph, explain what you can do.";
let payload = serde_json::json!({
"anthropic_version": "bedrock-2023-05-31",
"max_tokens": 1000,
"messages": [{
"role": "user",
"content": [{
"type": "text",
"text": prompt
}]
}]
});
let options = BedrockClientOptions::new()
.profile_name(profile_name)
.region(region);
let client = BedrockClient::new(options).await;
let result = client
.generate_raw(
model_id.to_string(),
payload,
)
.await
.unwrap();
println!("{:?}", result);
}
// Create a test
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_demo_generate_raw() {
demo_generate_raw().await;
}
}