如何在VS Code中安装和使用CodeGPT

如何在VS Code中安装和使用CodeGPT

VS Code ili ndi zowonjezera zingapo zomwe zimathandizira magwiridwe antchito ake ndikupereka mawonekedwe akuyenda kwachitukuko. Chimodzi mwazowonjezerazi ndi CodeGPT, yomwe imabweretsa mphamvu yanzeru zopangira ku VS Code.

CodeGPT imakulolani kuti musinthe ma code anu mosavuta. Mutha kuyigwiritsa ntchito kupanga ma code kuchokera ku ndemanga, kuyisinthanso, kuyisintha, kuyilemba, kapena kufotokozera zomwe gulu lina la code limachita.

Kukhazikitsa ndi Kusintha CodeGPT

Kuti muyike CodeGPT, yambitsani VS Code. Kenako dinani chizindikiro chazowonjezera kumanzere kwa zenera lanu. Kenako fufuzani Kodi GPT. Iyenera kukhala yoyamba pazotsatira zakusaka. Onetsetsani kuti ili ndi baji yotsimikizira ya buluu.

Kukulitsa kwa CodeGPT mu VSCode EXTENSIONS: MARKETPLACE

Dinani pa Ikani batani kuti muwonjezere ku VS Code. Mutayika CodeGPT, muyenera kuyilumikiza ku mtundu waukulu wachilankhulo. Chitsanzo ichi ndi chomwe chimapatsa mphamvu zake zopangira.

Kuti mukhazikitse kulumikizana pakati pa CodeGPT ndi mtundu wawukulu wachilankhulo, mufunika Kiyi ya API. Mu bukhuli, mukhala mukugwiritsa ntchito OpenAI API. Kuti mupeze imodzi kupita ku OpenAI API nsanja ndikulowa. Ngati mulibe akaunti, lembani imodzi. Pambuyo kulowa, kusankha API njira patsamba lomwe likuwonekera.

Tsamba losankha ntchito za OpenAI API

Izi zidzakutengerani kutsamba lofikira la API. Pamwamba pomwe ngodya, alemba mbiri yanu ndi kusankha Onani makiyi a API mwina.

Tsamba lofikira la OpenAI API

Tsopano, mudzawongoleredwa ku Makiyi a API tsamba. Dinani pa Pangani kiyi yatsopano yachinsinsi mwina. Kenako, tchulani ndikupanga kiyi yanu yachinsinsi.

OpenAI API key name

Ichi ndi kiyi ya API yomwe mungagwiritse ntchito kulumikiza OpenAI chilankhulo chachikulu ku CodeGPT. Koperani pa bolodi lanu.

Pitani ku VS Code ndikupita ku Zokonda> Zowonjezera> CodeGPT.

Tsamba losintha la CodeGPT mu VSCode

Kuchokera patsambali, mutha kukonza momwe CodeGPT imalumikizirana ndi chilankhulo chachikulu. Mutha kusankha yanu Wopereka AI, Max Tokens pa pempho lililonse, ndi Chitsanzo kugwiritsa ntchito. Komanso, pamene inu Mpukutu mopitirira pansi mukhoza kukhazikitsanso Kutentha mtengo.

Max Tokens kukuthandizani kuwongolera kutalika kwa mawu opangidwa. The Kutentha mtengo womwe uli pakati pa 0 ndi 1 umakuthandizani kuti muzitha kuwongolera kusasintha kwa mawu muzotulutsa zachitsanzo. Simuli ndi OpenAI LLM yokha. Mutha kugwiritsa ntchito mitundu yonse ya zilankhulo mu Wopereka AI kusankha, ngati muli ndi API Key yawo.

Kuti mulowetse API Key yanu, dinani Cmd + Shift + P pa Mac kapena Ctrl + Shift + P pa Windows kuti mutsegule phale lalamulo. Kenako fufuzani CodeGPT ndikusankha CodeGPT: Khazikitsani API KEY.

In relation :  为什么你不应该信任ChatGPT来总结你的文本
Lamulo la CodeGPT API pa VSCode command palette

Dinani pa izo ndikuyika kiyi yanu ya API pazomwe zikuwonekera. Sungani mwa kukanikiza Lowani. Pomaliza, tsegulaninso VS Code kuti muyambe kugwiritsa ntchito CodeGPT.

Kupanga Code Ndi CodeGPT

Kuti muwonetse mawonekedwe opangira ma code CodeGPT, mupanga pulogalamu yowerengera pogwiritsa ntchito Python.

Mutha kupanga ma code ndi CodeGPT pogwiritsa ntchito ndemanga kapena kugwiritsa ntchito macheza macheza a CodeGPT zenera. Kuti mupange ma code kuchokera ku ndemanga lembani ndemanga pazomwe mungafune kuti CodeGPT ichite mu script yanu. Kenako ndi cholozera kumapeto kwa ndemanga, dinani Ctrl + Shift + I. CodeGPT idzakonza zopemphazo ndikutsegula zenera latsopano ndi zotsatira.

CodeGPT yopanga code kuchokera ku ndemanga

Kenako mukhoza kukopera ndi kumata kachidindo mu script yanu. Njirayi siili bwino chifukwa yankho lili ndi mawu.

Kuti mupange kachidindo pocheza ndi CodeGPT, dinani chizindikiro cha macheza cha CodeGPT chakumanzere chakumanzere. Izi zidzatsegula zenera la macheza.

Zenera la macheza la CodeGPT

Kenako lowetsani zomwe mukufuna ndikudina Tumizani. Pankhaniyi, pempho ndi losavuta calculator. CodeGPT ikonza zopempha zanu ndikupanga khodi yanu pazenera lochezera.

Kupanga khodi ya CodeGPT pawindo lochezera

Dinani pa muvi wa “insert code” kuti mungoyimitsa kachidindoyo muzolemba zanu. Monga mukuwonera, njira iyi ndiyosavuta. Code yopangidwa ikuwonetsedwa pansipa:

def

onjezani(x, y):
kubwerera x +y ndi
def chepetsa(x, y):
kubwerera x ndi y
def chulukitsa(x, y):
kubwerera x*y ndi
def gawani(x, y):
ngati y! = 0:
kubwerera x /y ndi
zina:
kubwerera “Zolakwika: sangathe kugawa ndi ziro”
sindikiza (“Sankhani ntchito:”)
sindikiza (“1. Kuwonjezera”)
sindikiza (“2. Kuchotsa”)
sindikiza (“3. Kuchulukitsa”)
sindikiza (“4. Division”)
choice = input(“Lowani zomwe mwasankha (1-4): “)
num1 = float(input(“Lowani nambala yoyamba: “))
num2 = float(input(“Lowani nambala yachiwiri: “))
ngati kusankha == ‘1’:
sindikiza (nambala1, “+”, nambala2, “=”, kuwonjezera(nambala1, nambala2))
elif kusankha == ‘2’:
sindikiza (nambala1, “-“, nambala2, “=”, chotsani(nambala1, nambala2))
elif kusankha == ‘3’:
sindikiza (nambala1, “*”, num2, “=”, chulukitsa (nambala1, nambala2))
elif kusankha == ‘4’:
sindikizani(nambala1, “/”, num2, “=”, gawani (nambala1, nambala2))
zina:
print(“Zolemba zolakwika. Chonde yesaninso.”)

Mukayendetsa code imagwira ntchito bwino. Mwachidziwitso chimodzi chokha, munatha kupanga chowerengera chosavuta.

Kusintha Ma Code Anu Ndi CodeGPT

Kuti musinthe nambala yanu, sankhani nambala yomwe mukufuna kuyisintha, kenako dinani pomwepa ndikusankha Refactor CodeGPT. Mu Refactor CodeGPT dialog box, lowetsani zomwe mukufuna kufotokozera zomwe mukufuna kuchita. Mwachitsanzo, mutha kulowa “refactor code iyi kuti mugwiritse ntchito loop m’malo mwa loop kwakanthawi”.

CodeGPT ipanga nambala yatsopano yomwe imagwiritsa ntchito kukonzanso komwe kwafunsidwa.

Kufotokozera Khodi Yanu Ndi CodeGPT

Kuti mufotokoze nambala yanu, sankhani nambala yomwe mukufuna kuti CodeGPT ifotokoze. Kenako dinani kumanja pa code anatsindika ndi kusankha Fotokozani CodeGPT mwina.

In relation :  开发人员认为AI将如何影响他们的工作流程
Kufotokozera kwa codeGPT pawindo lochezera

CodeGPT ifotokoza zomwe code imachita pazenera lochezera.

Kulemba Ma Code Anu Pogwiritsa Ntchito CodeGPT

Kulemba khodi yanu kumathandiza okonza ena kuwerenga ndikumvetsetsa khodi yanu. Itha kukuthandizaninso kumvetsetsa khodi yanu m’tsogolomu.

Kuti mulembe khodi yanu, sankhani nambala yomwe mukufuna kulemba, kenako dinani pomwepa ndikusankha Document CodeGPT mwina. CodeGPT ipanga zolembedwa zama code pazenera lochezera. Kenako mutha kukopera ndi kumata malongosoledwewo muzolemba zanu.

Pa ndemanga zapaintaneti, gwiritsani ntchito zenera la macheza kuti mulangize CodeGPT kuti iyike ndemanga zapaintaneti zofunika mu code yanu. Kulangiza CodeGPT kuti ikhazikitse ndemanga zam’munsi pazomwe zili mu pulogalamu yowerengera kumapanga zotsatirazi:

def

onjezani(x, y):
kubwerera x + y # imabweretsanso kuchuluka kwa x ndi y

def chepetsa(x, y):
kubwerera x – y # imabweretsanso kusiyana pakati pa x ndi y

def chulukitsa(x, y):
kubwerera x * y # imabweretsa katundu wa x ndi y

def gawani(x, y):
ngati y! = 0:
kubwerera x / y # imabweretsa zotsatira zogawanika za x ndi y
zina:
# imabweretsanso uthenga wolakwika ngati y ndi zero (kugawa ndi ziro sikuloledwa)
kubwerera “Zolakwika: sangathe kugawa ndi ziro”

Awa ndi ndemanga zomveka bwino komanso zolondola.

Kumvetsetsa Momwe Generative AI Imagwirira Ntchito

CodeGPT imagwiritsa ntchito mphamvu ya AI yopangira mawonekedwe ake onse. Sizingapereke zambiri zolondola nthawi zonse. Chifukwa chake, muyenera kutsimikizira ngati zotsatira zake ndi zolondola. Kumvetsetsa momwe AI yopangira imagwirira ntchito kukuthandizani kuti mudziwe mphamvu ndi zofooka zake.

Moyens I/O 员工激励了您,为您提供技术、个人发展、生活方式和策略方面的建议,对您有所帮助。