本篇文章授权活动官方亚马逊云科技文章转发、改写权,包括不限于在 亚马逊云科技开发者社区, 知乎,自媒体平台,第三方开发者媒体等亚马逊云科技官方渠道
Preface
Amazon Cloud Technology-Q can quickly get relevant answers to pressing questions, solve problems, and generate content. When you chat with Q, it provides instantly relevant information and advice to help simplify tasks, speed up decision-making, and help inspire creativity and innovation at work.本次我们通过完整的项目开发全方面体验一下Q的实用性,体验在代码开发中是否真正做到解放生产力助力开发。
Combined with the chalk script demonstration diagram developed by Q:
本文主要分为以下结构:
Table of contents
1 Login account
1.1 Login and registration
Open the login page below to log in. If you do not have an account, you can register according to the process
https://portal.aws.amazon.com/billing/signup
1.2 Open the console home page
After logging in, open the console home page link:https://us-east-1.console.aws.amazon.com/console/home?region=us- east-1#
Find [Amazon Q] and click to go to the corresponding page
2 Create and deploy Web version-Q
提示:【2023.12.06】这里存在问题,并没有相应的权限,没办法继续往下,后续可以则会补充,本文只是按照博主的操作流程来,请根据需要选择性浏览
2.1 Create application
Click Get started
to go to the application creation page
At this time, we found that there is no corresponding permission. We need to go to the role and attach the corresponding policy to the current account.
3 additional strategies
In the service in the upper left corner, find [IAM] (you will also need to create a user in this step, and the method will not be described in detail)
In the left navigation bar, select [Role] 】
Search in the search boxteam
and click on the character name to enter
Select附加策略
Check the following permissions:
3.1 Create users and applications
After adding permissions, you can come here to create applications
The user creation failed. It is probably an account problem.目前等待反馈中
4 Get the IAM access key
It is currently impossible to experience Q through the WEB, so we can now experience it through the Vscode plug-in. This step is mainly to provide the key for the plug-in below.
Open[IAM] We found that the default user denies access (it may be a problem with the test account, the new account should not have users )
Manually create a user: damowang (as shown below)
The creation is successful, now continue and give him additional permissions
Permissions refer to the above附加权限
It is best to give [Administrator] permissions to complete the creation
Create access key
getsAccess Key
and after savingSecret Key
5 Configure Vscode-Q plug-in
Download the Q plug-in in Vscode
5.1 Permission configuration
5.1.1 Configuring Q + CodeWhisperer
Login authentication through Builder ID
A prompt box will pop up, selectopen
, and the default browser will pop up to open for permission verification
Create a developer ID account and fill in your email address until the registration is successful (如果有账号选择登录即可
)
After successful registration, he will redirect the page for authorization. If not, please follow the steps again and click Allow Authorization.
After the authorization is successful, we can return to Vscode
返回Vscode后验证通过
Configuration completed
5.1.2 Configuring Explorer
Select the second module in the middle, expand the options and fill in Access Key, Secret Key, and fill in the keys you just created respectively.
Configuration saved successfully
5.1.3 Amazon CodeCatalyst
Just like the first step, just open it for authorization.
5.2 Complete the conversation experience with Q
This is divided into three parts
Click [switch to Q chat] in the first part to start a conversation with him
5.2.1 Test expression ability
Q1:你是谁?你会中文吗?
5.2.2 Ability to understand and write code
Q2:请写一个冒泡排序用python
5.2.3 Code repair capability
url ="https://sxbaapp.zcj.jyt.henan.gov.cn/api/getApitoken.ashx"
response = requests.get(url)
print(response.text)
报错信息:Traceback (most recent call last):
File “C:\Users\MAC\Desktop\zxjy\demo.py”, line 2, in
response = requests.get(url)
NameError: name ‘requests’ is not defined
6 local access
6.1 Windows installation AWS CLI
Download and run the AWS CLI MSI installer for Windows (64-bit):
https://awscli.amazonaws.com/AWSCLIV2.msi
Alternatively, you can run the msiexec command to run the MSI installer.
Alternatively, you can run the msiexec command to run the MSI installer.
7 project development
7.1 Create a new GUI view
Create a new view in VB6 and convert the view into TK code through the plug-in. For those who don’t know about tk and packaging, you can refer to the previous article here "Python tkinter Rapid Visual Development GUI Interface Guide: Detailed Tutorial (With Tools)》
7.2 Code conversion
Through the plug-in we can quickly convert the view into TK code
The steps to use the plug-in are very simple and can be completed in three steps.
7.3 Get text box data
Next, we use the view layer and let Q combination write a method for us to get the data value of the view layer Text1Var.
self.Text1Var = StringVar(value='********')
self.Text1 = Entry(self.top, textvariable=self.Text1Var, font =('宋体',9))
self.Text1.place(relx=0.568, rely=0.018, relwidth=0.243, relheight=0.055)
me Want to get Text1Var data through python
Q's answer
current_value = self.Text1Var.get()
print(current_value)
7.4 Set up multi-threading
The script involves automated operations, so we need to process them through threads to avoid lags in the script.
self.style.configure('TCommand7.TButton', font=('宋体',9))
self.Command7 = Button(self.Frame3, text='一Key hangup', command=self.Command7_Cmd, style='TCommand7.TButton')
self.Command7.place(relx=0.646, rely=0.79, relwidth=0.3, relheight=0.176)< /span>
Write the Command7_Cmd method called by this code in a multi-threaded format
Q’s answer
Through practice, after the function is triggered, a thread is automatically allocated and created to make the call. For this, we can add a switch to close the end of the process loop execution.
from threading import Thread
def Command7_Cmd():
thread = Thread(target=long_running_task)
thread.start()
def long_running_task():
# put button click logic here
print("Performing task in background...")
By getting the value of the text box, and then requesting simulation through the request interface,Q可以帮助我们免去测试,节约了很多时间,加速了开发进度,
Since the following buttons are all threads and data acquisition, the core function is the thread given by Q, and other operations They are all the same, you just need to replace them with different interfaces, and other parts of the code will not be demonstrated
8 User experience
8.1 Advantages and Disadvantages
advantage | shortcoming |
---|---|
Key point tips will be returned | Chinese is not supported |
Automatic association of suggested questions | The plug-in experience also requires dual-window operation. Similar plug-ins already support one-click code transfer windows. |
Convenient authorization and authentication | The function is too weak and does not support a variety of data processing, such as Curl conversion |
The cost is cheap | Support less text |
8.2 Understanding and insights into Amazon Cloud Technology-Q
The combination of Amazon cloud computing and artificial intelligence is of great significance in today's technology field and will have a profound impact on the future development trend of cloud technology. It provides powerful infrastructure support for artificial intelligence and enables developers to build, train and deploy AI models more easily by providing flexible computing resources, storage and database services.
针对Q而言,希望能在处理复杂问题、语言识别、代码逻辑处理、优化算法和加密等方面发挥关键作用再升级,为人工智能领域带来新的突破。在实际使用过程中,由于语言的限制,以及Q功能的一些原因,体验没有超出我的预期。
The combination of Amazon cloud computing and artificial intelligence will continue to promote technological innovation in the future and provide more powerful and efficient solutions for various industries.