24 lines
671 B
C++
24 lines
671 B
C++
#pragma once
|
|
|
|
// Legacy POST /completions (gpt-3.5-turbo-instruct, davinci-002, babbage-002).
|
|
|
|
#include <functional>
|
|
|
|
#include "openai/core/chat_request.h"
|
|
#include "openai/core/service.h"
|
|
|
|
namespace molo::openai::core {
|
|
|
|
class CompletionsService : public OpenaiService {
|
|
public:
|
|
using ChunkHandler = std::function<bool(const clients::body::Json& chunk)>; // false: stop
|
|
|
|
using OpenaiService::OpenaiService;
|
|
|
|
clients::body::Json create(const CompletionRequest& request);
|
|
// Each streamed text_completion chunk reaches the handler; [DONE] ends.
|
|
void stream(const CompletionRequest& request, const ChunkHandler& handler);
|
|
};
|
|
|
|
} // namespace molo::openai::core
|