chatgpt  by asleepyfish

SDK for continuous ChatGPT conversations and streaming outputs

created 2 years ago
257 stars

Top 98.8% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a Java SDK for interacting with the OpenAI API, specifically designed for continuous conversation and streaming output. It targets Java developers looking to integrate ChatGPT capabilities into their Spring Boot applications or standalone Java projects, offering features like chat completion, image generation, text embeddings, audio transcription/translation, and account billing queries.

How It Works

The library leverages Spring Boot and Vue.js for its web-based demos, abstracting OpenAI API calls through a OpenAiUtils class and a configurable OpenAiProxyService. It supports continuous conversation by managing session expiration times and allows for custom OkHttpClient configurations, including proxy authentication and connection pooling. Streaming output is handled by passing an OutputStream to the relevant methods, enabling real-time responses in web applications.

Quick Start & Requirements

  • Install: Add the Maven dependency:
    <dependency>
      <groupId>io.github.asleepyfish</groupId>
      <artifactId>chatgpt</artifactId>
      <version>Latest Version</version>
    </dependency>
    
  • Configuration: Configure application.yml with your OpenAI API token and optional proxy settings. For Spring Boot integration, add @EnableChatGPT to your main application class.
  • Demo: See https://github.com/asleepyfish/chatgpt-demo and https://github.com/asleepyfish/chatgpt-vue.

Highlighted Details

  • Supports streaming chat responses to console or web clients.
  • Includes methods for image generation, text embeddings, and audio transcription/translation.
  • Provides functionality to query OpenAI billing usage and subscription details.
  • Allows customization of baseUrl, OkHttpClient, and token management strategies.
  • Offers features like system-level prompts and token consumption calculation.

Maintenance & Community

The project is actively maintained, with recent updates adding features like model listing, file management, fine-tuning capabilities, and improved token strategies. Links to demos and example usage are provided.

Licensing & Compatibility

The README does not explicitly state a license. Compatibility for commercial use or closed-source linking is not specified.

Limitations & Caveats

The project requires users to have an OpenAI API key. Some features, like audio transcription and translation, may have specific format requirements. The README mentions that mainland China users often need to configure proxy settings.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
3 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.