ID:
PW:

     0 ºÐ
     23 ºÐ

¿£Áö´Ï¾î µ¹Á¾
  dolljong
ÇÁ·Î±×·¡¹Ö Tips
ÇÁ·Î±×·¡¹Ö¿¡ °üÇÑ TipÀ» °øÀ¯ÇÏ´Â °÷ÀÔ´Ï´Ù.


[ÆÄÀ̽ã] ÆÄÀ̽ãÀ¸·Î chatGPT API ÀÌ¿ëÇϱâ
À̼®Á¾  2023-04-11 17:32:11, Á¶È¸ : 470, Ãßõ : 92

1. openai.com°¡ÀÔÇϱâ
openai.com¿¡ Á¢¼ÓÇؼ­ ȸ¿ø°¡ÀÔÇϱâ.
À̸ÞÀÏ ÁÖ¼Ò¿Í ÀüÈ­¹øÈ£¸¦ ÀÔ·ÂÇÏ°í °¡ÀÔÇϸé 3°³¿ùµ¿¾È 5´Þ·¯ÀÇ »ç¿ë±ÇÇÑÀ» ÁØ´Ù.

2. API key ¹Þ±â
https://platform.openai.com/docs/api-reference Á¢¼Ó

¿ìÃø personalÀ» Ŭ¸¯Çϸé View API key¸¦ ¼±ÅÃÇÏ¸é ¾Æ·¡ÀÇ ÁÖ¼Ò·Î ¿¬°áµÈ´Ù.
https://platform.openai.com/account/api-keys



create new secret key¸¦ ¼±ÅÃÇؼ­ key»ý¼º
ºñ¹Ð¹øÈ£¿Í °°Àº °ÍÀ̹ǷΠ´Ù¸¥ »ç¶÷¿¡°Ô ³ëÃâµÇÁö ¾Êµµ·Ï ÀúÀåÇÑ´Ù.

3. openai¼³Ä¡Çϱâ
cmd»óÅ¿¡¼­ pip install openai¸¦ ÀÔ·ÂÇؼ­ openai ¼³Ä¡

4. ÄÚµùÇϱâ
ÁÖÇÇÅÍ ³ëÆ®ºÏÀ¸·Î ¾Æ·¡ÀÇ Äڵ带 ½ÇÇà.
ÀÌ Äڵ忡¼­ "¹ß±Þ¹ÞÀº Å°"´Â 2´Ü°è¿¡¼­ ¹ß±Þ¹ÞÀº API key´Ù.
¾Æ·¡ÀÇ chatÇÔ¼ö´Â »ç¿ëÀÚ¿¡°Ô¼­ Áú¹®À» ¹Þ¾Æ¼­ ´äº¯À» Ãâ·ÂÇØÁÖ´Â ÇÔ¼ö´Ù.

import openai
openai.api_key = "¹ß±Þ¹ÞÀº Å°"
database=""
def chat(message):
  response = openai.ChatCompletion.create(
      model = "gpt-3.5-turbo",
      messages = [
          {"role":"system","content":database},
          {"role":"user","content":message}
      ],
  )
  print(response.choices[0]["message"]["content"])

À§ ºí·°À» ½ÇÇàÇϸé chatÇÔ¼ö°¡ Á¤ÀÇµÈ °ÍÀ̹ǷÎ
¾Æ·¡ ºí·°À» Ãß°¡ÇÏ¿© ´ëÈ­¸¦ ÇÏ¸é µÊ.

chat("Hi")
chat("ÇÑ°­ ±³·® Áß ÁÖÁö°£ÀåÀÌ °¡Àå ±ä ±³·®Àº?")


  ÃßõÇÏ±â   ¸ñ·Ïº¸±â

Copyright 1999-2024 Zeroboard / skin by zero
±¸Á¶¼³°èÀÇ ¹Ì·¡¸¦ ÁغñÇÏ´Â ¸ðÀÓ [±¸Á¶¼³°è¹Ì·¡Æ÷·³]