패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.1.0

flutter_chatgpt_api

비공식 ChatGPT API용 ChatGPT 주변의 Flutter/Dart API.

AndroidiOSmacOSWindowsLinux
30일 다운로드
93
좋아요
100
Pub 점수
130

패키지 설치

flutter pub add flutter_chatgpt_api

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

비공식 ChatGPT API를 위한 간단한 API 래퍼를 제공하는 Flutter/Dart 패키지로, 개발자가 Flutter 애플리케이션에 ChatGPT 기능을 통합할 수 있도록 합니다. Android, iOS, macOS, Windows, Linux 등 여러 플랫폼을 지원합니다. 저수준 HTTP 상호작용을 추상화하여 ChatGPT에 메시지를 보내고 응답을 받는 것을 쉽게 사용할 수 있는 인터페이스를 제공합니다. 공식 API에 의존하지 않고 대화형 AI 기능이 필요한 앱에 적합합니다.

사용 사례

  • 모바일 앱에 챗봇 통합하기
  • AI 기반 고객 지원 도구 구축
  • 상호작용형 학습 애플리케이션 만들기
  • 앱에서 실시간 텍스트 생성 활성화

주요 기능

  • 비공식 ChatGPT API 통합
  • 크로스 플랫폼 지원
  • 간단한 동기 및 비동기 메시지 처리
  • 내장된 오류 처리
  • 가볍고 설치하기 쉬움

적합한 대상

  • AI 챗 기능을 구축하는 개발자
  • 생성형 AI 애플리케이션 프로토타이핑
  • ChatGPT와 유사한 응답에 빠르게 접근이 필요한 앱

고려 사항

  • 비공식 API에 의존합니다(불안정하거나 중단될 수 있음)
  • 공식적인 구글/애플 승인 없음
  • 레이트 제한 및 잠재적인 IP 차단
  • 유효한 인증 토큰이 필요합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Flutter ChatGPT API

This package is a Flutter/Dart API around ChatGPT by OpenAI.

This package requires a valid session token from ChatGPT to access its unofficial REST API.

This version have been updated to use Puppeteer to log in to ChatGPT and extract the Cloudflare cf_clearance cookie and OpenAI session token. 🔥 Thanks to Node.js ChatGPT API (unofficial)

:warning: Be Careful!

  • Your user-agent and IP address must match from the real browser window you're logged in with to the one you're using for ChatGPTAPI.
    • This means that you currently can't log in with your laptop and then run the bot on a server or proxy somewhere.
  • Please check defaultHeaders

Demo

Installation

dependencies:
  flutter_chatgpt_api: ^1.0.0

Usage


import 'package:flutter_chatgpt_api/flutter_chatgpt_api.dart';

 _api = ChatGPTApi(
       sessionToken: SESSION_TOKEN,
       clearanceToken: CLEARANCE_TOKEN,
     );

setState(() {
  _messages.add(
    ChatMessage(
      text: _textController.text,
      chatMessageType: ChatMessageType.user,
    ),
  );
  isLoading = true;
});  

var newMessage = await _api.sendMessage(
  input,
  conversationId: _conversationId,
  parentMessageId: _parentMessageId,
);

setState(() {
  _conversationId = newMessage.conversationId;
  _parentMessageId = newMessage.messageId;
  isLoading = false;
  _messages.add(
    ChatMessage(
      text: newMessage.message,
      chatMessageType: ChatMessageType.bot,
    ),
  );
});

SessionToken

To get a session token:

  1. Go to https://chat.openai.com/chat and log in or sign up.
  2. Open dev tools.
  3. Open Application > Cookies (Storage > Cookies)

image

  1. Create these files and add your session token to run the tests and example respectively:

Copy the value for __Secure-next-auth.session-token and save it to your environment.example/lib/session_token.dart

Copy the value for cf_clearance and save it to your environment. example/lib/clearance_token.dart

Should look something like this:

const SESSION_TOKEN = '__Secure-next-auth.session-token from https://chat.openai.com/chat';
const CLEARANCE_TOKEN = 'cf_clearance token from https://chat.openai.com/chat';

Credit

License

MIT Copyright (c) 2022, Emre Coşkunçay

If you found this project interesting, please consider supporting my open source work by sponsoring me or following me on twitter twitter

카테고리

의존성

의존성 목록 2 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.