๋ณธ๋ฌธ

[์‹ค์Šต] Telegram AI ์ฑ—๋ด‡ ๋งŒ๋“ค๊ธฐ (๋กœ์ปฌPC)

๋ฐ˜์‘ํ˜•

โœ…  ์‹ค์Šต ์ค€๋น„๋ฌผ: apikey

https://server-engineer.tistory.com/983

 

[์‹ค์Šต] OpenAI apikey ๋ฐœ๊ธ‰ ๋ฐ ์‚ฌ์šฉํ•˜๊ธฐ

1. ํšŒ์›๊ฐ€์ž…ํ•˜๊ธฐ ๋จผ์ € OpenAI ํ”Œ๋žซํผ์— ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค. (๋ฐ”๋กœ๊ฐ€๊ธฐ) ํ™ˆํŽ˜์ด์ง€์—์„œ ํšŒ์›๊ฐ€์ž… ์ ˆ์ฐจ๋ฅผ ์™„๋ฃŒํ•ด์ฃผ์„ธ์š”. 2. API ํ‚ค ๋ฐœ๊ธ‰ ๋ฐ›๊ธฐ ๋กœ๊ทธ์ธ ํ›„, ์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ์— ์žˆ๋Š” 'View API Keys'๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. ์ง์ ‘ ๋ง

server-engineer.tistory.com


 

ChatGPT๋กœ ์งˆ์˜์‘๋‹ต ๋ฐ DALLE.2 ๋ชจ๋ธ๊ธฐ๋ฐ˜ ๊ทธ๋ฆผ์„ ๊ทธ๋ ค์ฃผ๋Š” AI ์ฑ—๋ด‡์„ ๋งŒ๋“ค์–ด๋ณด์ž

์„œ๋น„์Šค ๊ตฌ์„ฑ๋„



โœ… ๋™์ž‘ ์ˆœ์„œ

  • python script(telegramebot.py)๋ฅผ ์‹คํ–‰ํ•˜์—ฌ FastAPI ์„œ๋ฒ„๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
    • fastapi ๋‹จ๋…์œผ๋กœ๋Š” ์›น๊ฐœ๋ฐœ์„ ํ•  ์ˆ˜ ์—†๋‹ค. ๋”ฐ๋ผ์„œ ๋น„๋™๊ธฐ ์„œ๋ฒ„๋ฅผ ์ƒ์„ฑํ•˜๋Š” uvicorn์„ ์ถ”๊ฐ€๋กœ ์„ค์น˜ํ•œ๋‹ค.
    • pip install fastapi
    • pip install 'uvicorn[standard]'
  • ngrok๋ฅผ ์ด์šฉํ•ด์„œ '์™ธ๋ถ€์—์„œ ๋กœ์ปฌ์„œ๋ฒ„๋กœ ์ ‘์†ํ•˜๊ธฐ ์œ„ํ•œ ์ฃผ์†Œ๋ฅผ ๋ฐœ๊ธ‰' ๋ฐ›๋Š”๋‹ค.
    • ngrok ์‚ฌ์šฉ๋ฐฉ๋ฒ•(์™ธ๋ถ€์—์„œ Localhost ์ ‘์†ํ•˜๋Š” ๋ฐฉ๋ฒ•): https://bit.ly/about-ngrok
  • ๋ฐœ๊ธ‰๋ฐ›์€ ์ฃผ์†Œ๋ฅผ telegram api์˜ ์›นํ›…๊ณผ ์—ฐ๊ฒฐํ•œ๋‹ค.
    • telegram api์˜ ์›นํ›…์„ ์‚ฌ์šฉํ•˜์—ฌ ํ…”๋ ˆ๊ทธ๋žจ ์„œ๋ฒ„์™€ ๋กœ์ปฌ์„œ๋ฒ„๋ฅผ ์—ฐ๊ฒฐํ•œ๋‹ค.    



โœ… service spec

  • fast api, ngrok, telegram api
  • langchain, gpt-3.5-turbo, gpt-DALL.E 2

โš ๏ธ ์œ ์˜์‚ฌํ•ญ
์‹ค์Šต์„ ์ง„ํ–‰ํ•˜๋ ค๋ฉด PC๋‚˜ ๊ฐœ์ธ ํœด๋Œ€์ „ํ™”์—์„œ ํ…”๋ ˆ๊ทธ๋žจ์„ ์„ค์น˜ํ•˜๊ณ , ํšŒ์›๊ฐ€์ž… ๋ฐ ๋กœ๊ทธ์ธ์ด ์™„๋ฃŒ๋œ ์ƒํƒœ์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.


๐Ÿ™‹‍โ™‚๏ธ ๋”ฐ๋ผํ•˜๊ธฐ

https://github.com/i-am-shuan/LLM-telegram-chatbot/tree/main

 

GitHub - i-am-shuan/LLM-telegram-chatbot

Contribute to i-am-shuan/LLM-telegram-chatbot development by creating an account on GitHub.

github.com

 

  • ์ƒˆ๋กœ์šด ์ฑ—๋ด‡์„ ์ƒ์„ฑํ•œ๋‹ค: /newvot

 

  • 'bot'์œผ๋กœ ๋๋‚˜๋Š” ์ฑ—๋ด‡ ์ž…๋ ฅํ•˜์—ฌ ์ƒˆ๋กœ์šด ์ฑ—๋ด‡์„ ์ƒ์„ฑํ•œ๋‹ค.
  • ๋ฐœ๊ธ‰๋ฐ›์€ access token ์ •๋ณด๋ฅผ ๋ณด๊ด€ํ•œ๋‹ค.

 

  • ํ…”๋ ˆ๊ทธ๋žจ API URL ์–‘์‹: https://api.telegram.org/bpt<token>/METHOD_NAME
    • ๋ฉ”์„ธ์ง€ ์ „์†ก: https://api.telegram.org/bot<token>/sendMessage
    • ์‚ฌ์ง„ ์ „์†ก: https://api.telegram.org/bot<token>/sendPhoto

๐Ÿ‘€ ๊ฒฐ๊ณผ

  • GPT์—๊ฒŒ ์งˆ๋ฌธํ•˜๊ธฐ
    • ๋ช…๋ น์–ด: /ask

 

  • DALL-E์—๊ฒŒ ์ด๋ฏธ์ง€ ์ž‘์„ฑ ์š”์ฒญํ•˜๊ธฐ
    • ๋ช…๋ น์–ด: /img

๋ฐ˜์‘ํ˜•

๊ณต์œ 

๋Œ“๊ธ€