Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Request for Java-friendly support when customizing OkHttp (current implementation in Kotlin causes difficulties)

Đang mở
#574 2 bình luận 9 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
30/100
Loại issue
Tính năng
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
java, kotlin
Lĩnh vực
developer-experience

Hướng nghiên cứu

Bắt đầu bằng cách đọc triển khai Kotlin hiện tại trong openai-java-client-okhttp và điểm vào OpenAIClientImpl.builder. Xác định cách tiếp cận tùy chỉnh thân thiện với Java nào nên được hỗ trợ, sau đó xác minh rằng các dự án Java có thể cấu hình hoặc inject một OkHttp client tùy chỉnh mà không cần các dependency build của Kotlin.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement sdk
📌 Background

Currently, to customize the OkHttp client, the recommended approach is to copy the OkHttpClient implementation from openai-java-client-okhttp and modify it.
However, since the implementation is written in Kotlin, this process is difficult for developers working in pure Java projects.


⚠ Problems
  1. Language barrier

    • Requires understanding of Kotlin syntax (apply, null safety, extension functions, etc.).
    • Converting the code to Java requires additional work.
  2. Build environment overhead

    • Pure Java projects need to add the Kotlin build plugin to use the copied code.
    • This introduces extra build configuration and dependency management burden.

💡 Suggestions
  • Option 1: Provide a Java-friendly abstraction layer

    • e.g., an OpenAIOkHttpClientBuilder that allows configuring Timeout, Dispatcher, Interceptors, etc.
  • Option 2: Allow direct injection of an OkHttpClient instance via factory methods

    • Example:

      OpenAIClient client = OpenAIClientImpl.builder()
          .apiKey("...")
          .httpClient(customOkHttpClient) // Built via OkHttpClient.Builder
          .build();
      
  • Option 3: Provide a Java version of the current Kotlin implementation as a sample

    • So Java developers can copy and modify it without Kotlin dependencies.

✅ Expected benefits
  • Java developers can customize OkHttp without learning Kotlin.
  • Significantly lowers the barrier compared to the current “copy-and-modify” approach.
  • Improves flexibility for adapting to different network environments.
Ngôn ngữ chính
Kotlin
Star
1.5k
Fork
264
Merge trung bình
13 giờ 31 phút
Pull request đã merge (30 ngày)
89

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/openai-java

Tất cả issue của openai/openai-java

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.