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

Enable batch prompts

Đang mở Phù hợp với người mới
#73 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
68/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
swift
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Bắt đầu từ struct CompletionsQuery, nơi thuộc tính prompt được định nghĩa là String. Thay đổi kiểu của nó để chấp nhận cả chuỗi lẫn mảng chuỗi, cập nhật phần tuân thủ Codable để mã hóa mảng chính xác và thêm các bài kiểm thử bao quát những yêu cầu prompt theo lô. Kiểm tra tài liệu OpenAI API để biết chính xác định dạng yêu cầu theo lô.

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

Mô tả

The OpenAI API seems to allow both strings and arrays of strings in order to batch requests:

Here’s the canonical example from the docs using Python:

import openai  # for making OpenAI API requests

num_stories = 10
prompts = ["Once upon a time,"] * num_stories
 
# batched example, with 10 story completions per request
response = openai.Completion.create(
    model="curie",
    prompt=prompts,
    max_tokens=20,
)
 
# match completions to prompts by index
stories = [""] * len(prompts)
for choice in response.choices:
    stories[choice.index] = prompts[choice.index] + choice.text
 
# print stories
for story in stories:
    print(story)

The source inline documentation seems to suggest that this functionality has been considered also for this library …

struct CompletionsQuery: Codable {
    // ...
    /// The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays.
    public let prompt: String
    // ...
}

… but the code itself seems to only implement strings but not arrays for prompts.

Batching seems like a great way to reduce load times based on my experimentation and I’d love to see it come to this library as well.

Thanks for all the amazing work!

Disclaimer: I'm 100% new to Swift.

Ngôn ngữ chính
Swift
Star
2.9k
Fork
519
Merge trung bình
2 ngày 20 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

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 MacPaw/OpenAI

Tất cả issue của MacPaw/OpenAI

Issue tương tự

Thêm issue về Swift

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.