æ¨å¹´12æã«Cloudflare Worker + D1 + Hono + OpenAIã§LINE Botãä½ãã¨ããè¨äºãæ¸ããããã®æã¯Javascriptã§æ¸ãã¦ãããããã®æ¹é¢ã¯Pythonã§ç©äºãé²ããæ¹ãä½ãã¨ä¾¿å©ãªã®ã§ãä»åã¯FastAPI + ChatGPTã®APIã使ã£ã¦ä¼¼ããããªLINE Botãä½æãã¦ã¿ããã¾ããCloudflare Workerã§ã¯Pythonã®ã¢ããªãåãããªã(ãã«ãã)ã®ã§Fly.ioã§åããã®ã試ãã¦ã¿ãã以ä¸ã§ã¯ãã®ãã£ããã¨ããæµãã¨ã³ã¼ãã¨ã¡ã¢ã¿ãããªãã®ãæ¸ãã¦ããã â»ã¡ãªã¿ã«æ¦ã詳細ã¯Cloudflare Worker + D1 + Hono + OpenAIã§LINE Botãä½ãã¨è¢«ãé¨åãå¤ãã®ã§è²ã ã¨çç¥ãã¦ãã Echo Botãä½ã ã¨ããããã¯ã¾ãã¯LINEã§åãEcho Botãä½ãã¨ãããããã£ã¦ã¿ããä½äºãæ
ChatGPT APIã®ä½¿ãæ¹ å®éã«ChatGPT APIã使ã£ã¦ã¿ã¾ãããã openai-pythonã®ã¤ã³ã¹ãã¼ã« ä»åã¯OpenAIã®Pythonç¨ã©ã¤ãã©ãªã§ããopenai-pythonã使ãã¾ããpipãç¨ãã¦ãopenai-pythonãã¤ã³ã¹ãã¼ã«ãã¾ãããã pip install openai APIãªã¯ã¨ã¹ã ChatCompletion.createã§å¯¾è©±ãçæã§ãã¾ãããã¨ãã°ã以ä¸ã®ãããªã³ã¼ãã«ãªãã¾ãã import openai openai.api_key = "sk-..." # APIãã¼ completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[{"role": "user", "content": "ããã«ã¡ã¯ï¼"}] ) print(complet
èªåç¨ChatGPTã®ãããªãã®ãä½ãããã¨æãã¾ãããUIã®å®è£ ã¯ãStreamlitã使ãã¨æ¥½ã§ãããã§ãã ã§ãããã® ã¨ããã§ããã§ããããªæãã®ãã®ããµã¯ãã¨ä½ãã¾ããï¼æ°ããçºè¨ãä¸ã«è¡¨ç¤ºãããä»æ§ã§ãï¼ãUIã«ã¯åè¿°ã®éãStreamlitãããã¸ãã¯é¨åã«ã¯LangChainã使ã£ã¦ãã¾ãã ãããªãã¨ãã§ãã¾ãã ç 究ã¢ã·ã¹ã¿ã³ãã¨ãã¦æ¯ãèã ãã£ãã風ã®UIã§ä¼è©±ã§ãã ä¼è©±å±¥æ´ã«åºã¥ãã¦ä¼è©±ã§ãã ä»ã®ã¨ããã¯ãChatGPTã®Webçã使ãã®ã¨ãããªã«å¤ããã¾ãããã½ã¼ã¹ã³ã¼ãã¯ã以ä¸ã®ãªãã¸ããªã«ç½®ãã¦ããã¾ãã éçºããä¸ã§ããã£ãã㨠ãã£ããã®ãã¸ãã¯é¨åã«é¢ãã¦ã¯ããLangChain ã® ãã£ããã¢ãã« (ChatGPTã®æ°ããæ½è±¡å) ã試ãï½npakaããªã©ãåèã«ããã°ãç°¡åã«å®è£ ã§ããã§ãããã ä¼è©±å±¥æ´åºã¥ãã¦çºè¨ã§ããããã«ããããã«ã¯ãL
ããã«ã¡ã¯ å ¤ã§ãã 3æ1æ¥ã«ChatGPTã®APIãå ¬éããã¾ããã openai.com APIãå ¬éããããã¨ã§ChatGPTãæ´»ç¨ããã¢ããªãè²ã ç»å ´ãã¦çãä¸ãã£ã¦ãã¾ããï¼ ä»åã¯Pythonã®ã¿ã§ç°¡åã«Webã¢ããªãä½æã§ããStreamlitã¨ChatGPT APIãçµã¿åããã¦ç°¡åã«AIã¢ããªãä½æããæ¹æ³ããç´¹ä»ãã¾ãã Streamlitã«ã¤ã㦠Streamlitã¯ããã³ããããã¯ã¨ã³ããPythonã®ã¿ã®è¨è¿°ã§Webã¢ããªã±ã¼ã·ã§ã³ãä½æã§ãããã¬ã¼ã ã¯ã¼ã¯ã§ãã streamlit.io Webã¢ããªä½ããããã©ããã³ãã®ç¥èãå ¨ããªãããã¨ãã人ã§ãUIãç°¡åã«ä½æã§ããã®ã§ã¨ã¦ã便å©ã§ãã ãã¼ã¿å¯è¦åãæ©æ¢°å¦ç¿ã¢ãã«ã®å ±æãã¨ã¦ãç°¡åã«ã§ããã®ã§ãã¼ã¿ãµã¤ã¨ã³ã¹ã®é åã§ãã使ããã¦ãã¾ãã ä½æããã¢ã㪠ä»åã¯ãã®ChatGPT APIã¨Streaml
ããã«ã¡ã¯ã社å ãã¼ã¿ãµã¤ã¨ã³ã¹ãã¼ã YAMALEXã®@Ssk1029Takashiã§ãã æè¿ã¯ChatGPTãåºã¦æ³¨ç®ãæµ´ã³ãããBingã«ãChatGPTã®ããã«è³ªåå¿çãã¦ãããAIãæè¼ããããªã©ãOpenAIã®GPTã¢ãã«ãä¸ã®ä¸ãé¨ããã¦ãã¾ãã ç§ãChatGPT使ã£ã¦ã¿ã¾ããããåãçãèªä½ã¯äººãæ¸ãã¦ããæç« ã¨éè²ãªããæç« ã®èªåçæãããã¾ã§æ¥ããããã¨ããæãã§ããã ãããªChatGPTã®ç¹å¾´ã®ä¸ã¤ã¨ãã¦ãåçã«ã¯æã åãå«ã¾ããã¨ãããã®ãããã¾ãã ChatGPTèªä½ã¯ç¥èãæã£ã¦ããããã§ã¯ãªãã®ã§ãå¦ç¿ãã¼ã¿ã«ãªããã¨ãªã©ã¯ããã£ã½ããã©ã§ããããªåçãè¿ãã¦ãã¾ãã¾ãã ãã ããæè¿è¿½å ãããBingã®GPTã§ã¯ãChatGPTãããã¯ããã«æ£ç¢ºãªåçãè¿ã£ã¦ããããã«æãã¾ãã ç»é¢ãè¦ãã¨åçã®æ ¹æ ã¨ãªã£ã¦ãã詳細æ å ±ãåºã¦ãã¾ãã ããããæ¨æ¸¬ãã
2022å¹´11æ30æ¥ã«ãã¹ãçãå ¬éãããChatGPTã¯ãã¦ã¼ã¶ã¼ã®æ§ã ãªè³ªåã«æµæ¢ã«çããä¼è©±è½åã®ã»ãã«ããæ§ã ãªç¨®é¡ã®æç« ãããã°ã©ã ããªã¢ã«ã¿ã¤ã ã§çæãããã¨ãã§ãããã®æ§è½ã®é«ãã話é¡ã¨ãªãã¾ããã ããããChatGPTã«ã¯ããã©ãã¼ãã¦ããæ å ±ã2021å¹´ã¾ã§ã¨ããå¶éããããããæè¿ã®ãã¥ã¼ã¹ã話é¡ã«ã¯å¯¾å¿ã§ãã¾ããã ãã®åé¡ã解決ããããã«ãPythonã©ã¤ãã©ãªã®LangChainãå©ç¨ãã¦ãChatGPTï¼ã¯ãã¼ã³ï¼ã§Googleã®æ¤ç´¢çµæã使ããããã«ãã¦ã¿ã¾ããã â»ï¼2022å¹´12æ31æ¥è¿½è¨ï¼Googleã«ã¹ã¿ã æ¤ç´¢çChatGPTã¯ãã¼ã³ã®ã³ã¼ãã追å ãã¾ããã ï¼ï¼ChatGPTã®èª²é¡ãChatGPTã¯ãæ§ã ãªè³ªåã«å¯¾ãã¦ãã¦ã¼ã¶ã¼ãæãå½¢ã§åçãè¿ãã¦ãããé常ã«ä¾¿å©ãªå¯¾è©±ç¨AIã§ããã大ããªèª²é¡ãäºã¤ããã¾ãã äºå®ã¨è¦åããã¤ããªããã¿ã©ã¡ãª
æ¦è¦ OpenAIã®ã¢ãã«ãText davinciãã«è±ææ·»åããã¦ããã æå¤ã¨ä½¿ãç©ã«ãªãè±æãã§ããã åæ© è±èªã§ä½ããæ¸ããªãã¦ã¯ãªããªãã¨ãã«ããè©°ãã§ãã¾ãã Grammarlyãªã©ã®ãµã¼ãã¹ãããããç¡æçã§ã¯ææ³ééãã®ã¿ã®ææã ã¡ãã£ã¨ããè±æã®ãã©ãã·ã¥ã¢ããããããã ð§ Awesome ChatGPT Prompts å··ã沸ããã¦ããOpenAiã®ChatGPTã§ãããä¸çã®ããã人ããåªæéããã¾ã¨ãã¦ããã¦ãã¾ãã ð§ Awesome ChatGPT Prompts ãã®ä¸ã«"Act as an English Translator and Improver"ã¨ããé¢ç½ããã®ãããã¾ããã ããã¯ãChatGPTãè±èªæ師ã«æã代ãã£ã¦ææ¸æ¨æ²ãã¦ãããã¨ããé¡ã£ããå¶ã£ããã®åªæã§ãã Act as an English Translator and
ChatGPT ã使ç¨ãã Python ã¹ã¯ãªããã®ä½æ 次ã«ãPython ã¹ã¯ãªãããä½æãã¦ãChatGPT ãåæåããã³ãã³ãã©ã¤ã³ããæãå ¥åãã¦åãåãããããã® CLI ãã¼ã«ãä½æãã¾ãã import openai import os openai.api_key = os.environ["OPENAI_SECRET_KEY"] prompt = input("Enter a prompt: ") completions = openai.Completion.create( engine="text-davinci-002", prompt=prompt, max_tokens=1024, n=1, stop=None, temperature=0.5, ) for choice in completions.choices: print(choice.text)
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}