assistant: Improve Amazon Bedrock configuration instructions (#25699)
This commit is contained in:
parent
a5f96909cb
commit
6092918be8
1 changed files with 61 additions and 13 deletions
|
@ -772,7 +772,9 @@ struct ConfigurationView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigurationView {
|
impl ConfigurationView {
|
||||||
const PLACEHOLDER_TEXT: &'static str = "XXXXXXXXXXXXXXXXXXX";
|
const PLACEHOLDER_ACCESS_KEY_ID_TEXT: &'static str = "XXXXXXXXXXXXXXXX";
|
||||||
|
const PLACEHOLDER_SECRET_ACCESS_KEY_TEXT: &'static str =
|
||||||
|
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
|
||||||
const PLACEHOLDER_REGION: &'static str = "us-east-1";
|
const PLACEHOLDER_REGION: &'static str = "us-east-1";
|
||||||
|
|
||||||
fn new(state: gpui::Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
fn new(state: gpui::Entity<State>, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
|
@ -802,12 +804,12 @@ impl ConfigurationView {
|
||||||
Self {
|
Self {
|
||||||
access_key_id_editor: cx.new(|cx| {
|
access_key_id_editor: cx.new(|cx| {
|
||||||
let mut editor = Editor::single_line(window, cx);
|
let mut editor = Editor::single_line(window, cx);
|
||||||
editor.set_placeholder_text(Self::PLACEHOLDER_TEXT, cx);
|
editor.set_placeholder_text(Self::PLACEHOLDER_ACCESS_KEY_ID_TEXT, cx);
|
||||||
editor
|
editor
|
||||||
}),
|
}),
|
||||||
secret_access_key_editor: cx.new(|cx| {
|
secret_access_key_editor: cx.new(|cx| {
|
||||||
let mut editor = Editor::single_line(window, cx);
|
let mut editor = Editor::single_line(window, cx);
|
||||||
editor.set_placeholder_text(Self::PLACEHOLDER_TEXT, cx);
|
editor.set_placeholder_text(Self::PLACEHOLDER_SECRET_ACCESS_KEY_TEXT, cx);
|
||||||
editor
|
editor
|
||||||
}),
|
}),
|
||||||
region_editor: cx.new(|cx| {
|
region_editor: cx.new(|cx| {
|
||||||
|
@ -953,11 +955,20 @@ impl ConfigurationView {
|
||||||
impl Render for ConfigurationView {
|
impl Render for ConfigurationView {
|
||||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||||
const IAM_CONSOLE_URL: &str = "https://us-east-1.console.aws.amazon.com/iam/home";
|
const IAM_CONSOLE_URL: &str = "https://us-east-1.console.aws.amazon.com/iam/home";
|
||||||
const INSTRUCTIONS: [&str; 3] = [
|
const BEDROCK_DOCS_URL: &str =
|
||||||
|
"https://docs.aws.amazon.com/bedrock/latest/userguide/inference-prereq.html";
|
||||||
|
const BEDROCK_MODEL_CATALOG: &str =
|
||||||
|
"https://us-east-1.console.aws.amazon.com/bedrock/home?region=us-east-1#/modelaccess";
|
||||||
|
const INSTRUCTIONS: [&str; 5] = [
|
||||||
"To use Zed's assistant with Bedrock, you need to add the Access Key ID, Secret Access Key and AWS Region. Follow these steps:",
|
"To use Zed's assistant with Bedrock, you need to add the Access Key ID, Secret Access Key and AWS Region. Follow these steps:",
|
||||||
"- Create a pair at:",
|
"- Create a user and security credentials here:",
|
||||||
"- Paste your Access Key ID, Secret Key, and Region below and hit enter to use the assistant:",
|
"- Grant that user permissions according to this documentation:",
|
||||||
|
"- Go to the console and select the models you would like access to:",
|
||||||
|
"- Fill the fields below and hit enter to use the assistant:",
|
||||||
];
|
];
|
||||||
|
const BEDROCK_MODEL_CATALOG_LABEL: &str = "Bedrock Model Catalog";
|
||||||
|
const BEDROCK_IAM_DOCS: &str = "Prerequisites";
|
||||||
|
|
||||||
let env_var_set = self.state.read(cx).credentials_from_env;
|
let env_var_set = self.state.read(cx).credentials_from_env;
|
||||||
|
|
||||||
let bg_color = cx.theme().colors().editor_background;
|
let bg_color = cx.theme().colors().editor_background;
|
||||||
|
@ -980,7 +991,7 @@ impl Render for ConfigurationView {
|
||||||
.size_full()
|
.size_full()
|
||||||
.on_action(cx.listener(ConfigurationView::save_credentials))
|
.on_action(cx.listener(ConfigurationView::save_credentials))
|
||||||
.child(Label::new(INSTRUCTIONS[0]))
|
.child(Label::new(INSTRUCTIONS[0]))
|
||||||
.child(h_flex().child(Label::new(INSTRUCTIONS[1])).child(
|
.child(h_flex().flex_wrap().child(Label::new(INSTRUCTIONS[1])).child(
|
||||||
Button::new("iam_console", IAM_CONSOLE_URL)
|
Button::new("iam_console", IAM_CONSOLE_URL)
|
||||||
.style(ButtonStyle::Subtle)
|
.style(ButtonStyle::Subtle)
|
||||||
.icon(IconName::ArrowUpRight)
|
.icon(IconName::ArrowUpRight)
|
||||||
|
@ -989,18 +1000,55 @@ impl Render for ConfigurationView {
|
||||||
.on_click(move |_, _window, cx| cx.open_url(IAM_CONSOLE_URL))
|
.on_click(move |_, _window, cx| cx.open_url(IAM_CONSOLE_URL))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.child(Label::new(INSTRUCTIONS[2]))
|
.child(h_flex().flex_wrap().child(Label::new(INSTRUCTIONS[2])).child(
|
||||||
|
Button::new("bedrock_iam_docs", BEDROCK_IAM_DOCS)
|
||||||
|
.style(ButtonStyle::Subtle)
|
||||||
|
.icon(IconName::ArrowUpRight)
|
||||||
|
.icon_size(IconSize::XSmall)
|
||||||
|
.icon_color(Color::Muted)
|
||||||
|
.on_click(move |_, _window, cx| cx.open_url(BEDROCK_DOCS_URL))
|
||||||
|
))
|
||||||
|
.child(h_flex().flex_wrap().child(Label::new(INSTRUCTIONS[3])).child(
|
||||||
|
Button::new("bedrock_model_catalog", BEDROCK_MODEL_CATALOG_LABEL)
|
||||||
|
.style(ButtonStyle::Subtle)
|
||||||
|
.icon(IconName::ArrowUpRight)
|
||||||
|
.icon_size(IconSize::XSmall)
|
||||||
|
.icon_color(Color::Muted)
|
||||||
|
.on_click(move |_, _window, cx| cx.open_url(BEDROCK_MODEL_CATALOG))
|
||||||
|
))
|
||||||
|
.child(Label::new(INSTRUCTIONS[4]))
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.my_2()
|
.my_2()
|
||||||
.gap_1()
|
.gap_1p5()
|
||||||
.child(input_base_styles().child(self.render_aa_id_editor(cx)))
|
.child(
|
||||||
.child(input_base_styles().child(self.render_sk_editor(cx)))
|
v_flex()
|
||||||
.child(input_base_styles().child(self.render_region_editor(cx)))
|
.gap_0p5()
|
||||||
|
.child(Label::new("Access Key ID").size(LabelSize::Small))
|
||||||
|
.child(
|
||||||
|
input_base_styles().child(self.render_aa_id_editor(cx))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
v_flex()
|
||||||
|
.gap_0p5()
|
||||||
|
.child(Label::new("Secret Access Key").size(LabelSize::Small))
|
||||||
|
.child(
|
||||||
|
input_base_styles().child(self.render_sk_editor(cx))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
v_flex()
|
||||||
|
.gap_0p5()
|
||||||
|
.child(Label::new("Region").size(LabelSize::Small))
|
||||||
|
.child(
|
||||||
|
input_base_styles().child(self.render_region_editor(cx))
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Label::new(
|
Label::new(
|
||||||
format!("You can also assign the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR} and {ZED_BEDROCK_REGION_VAR} environment variable and restart Zed."),
|
format!("You can also assign the {ZED_BEDROCK_ACCESS_KEY_ID_VAR}, {ZED_BEDROCK_SECRET_ACCESS_KEY_VAR}, and {ZED_BEDROCK_REGION_VAR} environment variables and restart Zed."),
|
||||||
)
|
)
|
||||||
.size(LabelSize::Small),
|
.size(LabelSize::Small),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue