MindsDB - 트위터 AI 챗봇 튜토리얼 따라하기

이진나무·2023년 7월 7일
0

MindsDB

목록 보기
1/2

MindsDB가 @SnoopStein 이란 래퍼 겸 물리학자 챗봇을 만들었다.

공식 튜토리얼


진행사항

일단 이걸 따라하려면 선행되어야 하는 작업이 몇단계 있다.

  1. 트위터 개발 계정이 필요함
  2. MindsDB 계정을 만들어야 한다.

트위터 개발 계정 만들기

  • https://developer.twitter.com/en 에 들어가서 내가 트위터 API로 뭔 프로젝트를 할건지 적어서 제출했다. 제출하고 하루 이틀 이상 기다리면 승인 메일을 받는 걸로 알고 있는데, 난 그냥 Developer Portal에서 내가 신청한 프로젝트랑 key를 다 확인 할 수 있는 것 같다 (뭐지?)

MindsDB 공식 문서에서 필요하다고 가이드한 트위터 개발 계정 key가 아래와 같이 5개인데, 내 트위터 개발 포털 대쉬보드에서 다 확인가능하다. (뭐지?)

CREATE DATABASE my_twitter_v2
WITH
  ENGINE = 'twitter',
  PARAMETERS = {
   "consumer_key": "your twitter App API key",
   "consumer_secret": "your twitter App API key secret",
   "bearer_token": "your twitter App bearer TOKEN",
   "access_token": "your twitter App Access Token",
   "access_token_secret": "your twitter App Access Token Secret"
  };

MindsDB

MindsDB SQL Editor

MindsDB 계정 만들기

첫번째로, MindsDB SQL Editor 로 이동한다.

  • first name, email, 비번 입력하면 간단하게 sign up 된다.
  • 나는 일단 무료 demo 버젼으로. 유료버젼은 0.7$ per hour 이다.

sign up 이후 아래와 같은 인터페이스를 확인할 수 있다.

GPT 모델 생성

GPT 모델 생성하는 예제 코드

PREDICT response
USING
engine = 'openai',
-- api_key = 'your openai key', -- in MindsDB cloud accounts we provide a default key 
model_name = 'gpt-4', -- you can also use 'text-davinci-003' or 'gpt-3.5-turbo'
prompt_template = 'respond to {{text}} by {{author_username}}'; 

각 명령어가 수행하능 기능

  • CREATE MODEL mindsdb.gpt_model : gpt_model 이라는 이름의 머신 러닝 모델 생성
  • PREDICT response : 모델이 prompt에 기반하여 응답을 예측하도록 함
  • USING engine = 'openai' : OpenAI 엔진을 사용하도록 함
  • prompt_template : GPT의 응답양식 지정

결과화면

생성한 GPT 모델에 응답을 요청해보자

  1. 튜토리얼 문서와 동일한 질문
    "why is gravity so different on the sun?"
SELECT response
FROM mindsdb.gpt_model
WHERE author_username = "mindsdb"
AND text = "why is gravity so different on the sun?";

결과화면 - 공식 튜토리얼와 동일한 결과를 확인할 수 있다.

  1. 개인 테스트용 질문들
    "Explain about cubic bezier curve"
    결과 화면

트위터 Dev Account와 연동

WITH
  ENGINE = 'twitter',
  PARAMETERS = {
   "consumer_key": "your twitter App API key",
   "consumer_secret": "your twitter App API key secret",
   "bearer_token": "your twitter App bearer TOKEN",
   "access_token": "your twitter App Access Token",
   "access_token_secret": "your twitter App Access Token Secret"
  };

버그
MindsDB 공식 리포의 버그 리포트링크텍스트

Twitter의 Elevated Access 정책이 업데이트 되며 튜토리얼 문서대로 하면 아래와 같은 이슈를 만나게 된다.

Can't connect to db: 403 Forbidden
When authenticating requests to the Twitter API v2 endpoints, you must use keys and tokens from a Twitter developer App that is attached to a Project. You can create a project via the developer portal.

해당 이슈는 "bearer_token" 을 제거하면 해결된다는 결론과 함께 closed 상태이다. 하지만 나는 동일한 에러 메시지를 만나고 있다...
추가 문의를 위한 comment 를 남겼으니 내부 기여자들의 답변을 기다리는 수밖에.


MindsDB 커뮤니티 기여 방안들

Here is what you can do:

Go ahead and try out MindsDB by following our tutorials, and in case of problems, you can always report an issue here.

Are you familiar with Python? You can then help us out in resolving open issues. At first, have a look at issues labeled with the good first issue tag, as these should be easy to start.

You can also help us with documentation and tutorials. Here is how you can contribute by writing documentation and tutorials. Don’t forget to follow the style guide.

Share with your friends and spread the word about MindsDB.

profile
그냥 합니다

0개의 댓글

관련 채용 정보