Request for Java-friendly support when customizing OkHttp (current implementation in Kotlin causes difficulties)
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ệ
- 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ả
📌 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
-
Language barrier
- Requires understanding of Kotlin syntax (
apply, null safety, extension functions, etc.). - Converting the code to Java requires additional work.
- Requires understanding of Kotlin syntax (
-
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
OpenAIOkHttpClientBuilderthat allows configuring Timeout, Dispatcher, Interceptors, etc.
- e.g., an
-
Option 2: Allow direct injection of an
OkHttpClientinstance 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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openai/openai-java
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openai/openai-java#890 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
openai/openai-java#886 · 2 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
openai/openai-java#802 · 2 bình luận · 3 reaction ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openai/openai-java#755 · 1 bình luận ·
-
bug sdk
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
openai/openai-java#652 · 2 bình luận ·
Tất cả issue của openai/openai-java
Issue tương tự
-
[Bug] 统计页面无法重置token和汇率 Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
AAswordman/Operit#1265 · 3 bình luận ·
-
The extension stopped working. Đang mởSource is down
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
keiyoushi/extensions-source#19317 ·
-
Tambahkan bahasa Indonesia Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
acristescu/OnlineGo#216 ·
-
Remove custom segment colors Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
libre-tube/LibreTube#8803 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100