nanoMMO
0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
storyteller.h
Go to the documentation of this file.
1
#ifndef NANOMMO_SERVER_STORYTELLER_H_
2
#define NANOMMO_SERVER_STORYTELLER_H_
3
4
#include <cstdint>
5
#include <functional>
6
#include <string>
7
8
#include "absl/status/statusor.h"
9
#include "asio/io_context.hpp"
10
#include "asio/thread_pool.hpp"
11
12
namespace
nanommo
{
13
14
/// Asks mvGPT's completions API, the storyteller service, for stories, on
15
/// threads of its own, so that a tick never waits for the model.
16
class
Storyteller
{
17
public
:
18
static
constexpr
uint16_t
kPort
= 8000;
19
20
/// Gets the story, or why there isn't one.
21
using
Told
= std::function<void(absl::StatusOr<std::string>)>;
22
23
Storyteller
(asio::io_context& io, std::string host);
24
25
/// Asks for a story that goes on from the prompt, and calls told with it on
26
/// the io_context's thread, where the rest of the server runs.
27
void
Tell
(std::string prompt,
Told
told);
28
29
private
:
30
absl::StatusOr<std::string> Complete(
const
std::string& prompt)
const
;
31
32
asio::io_context& io_;
33
std::string host_;
34
asio::thread_pool threads_;
35
};
36
37
}
// namespace nanommo
38
39
#endif
// NANOMMO_SERVER_STORYTELLER_H_
nanommo::Storyteller::Told
std::function< void(absl::StatusOr< std::string >)> Told
Gets the story, or why there isn't one.
Definition
storyteller.h:21
nanommo::Storyteller::Storyteller
Storyteller(asio::io_context &io, std::string host)
Definition
storyteller.cc:30
nanommo::Storyteller::Tell
void Tell(std::string prompt, Told told)
Definition
storyteller.cc:33
nanommo::Storyteller::kPort
static constexpr uint16_t kPort
Definition
storyteller.h:18
nanommo
Definition
chat.cc:9
server
storyteller.h
Generated by
1.15.0