Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Conversation

@louis-jan
Copy link
Contributor

@louis-jan louis-jan commented Feb 28, 2024

Descriptions

There are so many structs defined in controllers which should be decoupled.

namespace v1 {

class audio : public drogon::HttpController<audio>,
              public BaseModel,
              public BaseAudio {
 public:
  audio();
  ~audio();
  METHOD_LIST_BEGIN

  METHOD_ADD(audio::LoadModel, "load_model", Post);
  METHOD_ADD(audio::UnloadModel, "unload_model", Post);
  METHOD_ADD(audio::ListModels, "list_model", Get);
  METHOD_ADD(audio::ModelStatus, "model_status", Get);
  METHOD_ADD(audio::CreateTranscription, "transcriptions", Post);
  METHOD_ADD(audio::CreateTranslation, "translations", Post);

  METHOD_LIST_END
  void LoadModel(
      const HttpRequestPtr& req,
      std::function<void(const HttpResponsePtr&)>&& callback) override;

  void UnloadModel(
      const HttpRequestPtr& req,
      std::function<void(const HttpResponsePtr&)>&& callback) override;

  // TODO: Add to the BaseModel interface
  void ListModels(const HttpRequestPtr& req,
                  std::function<void(const HttpResponsePtr&)>&& callback);

  // TODO: Unimplemented
  void ModelStatus(
      const HttpRequestPtr& req,
      std::function<void(const HttpResponsePtr&)>&& callback) override;

  void CreateTranscription(
      const HttpRequestPtr& req,
      std::function<void(const HttpResponsePtr&)>&& callback) override;

  void CreateTranslation(
      const HttpRequestPtr& req,
      std::function<void(const HttpResponsePtr&)>&& callback) override;

 private:
  std::unordered_map<std::string, whisper_server_context> whispers;

  std::optional<std::string> ParseModelId(
      const std::shared_ptr<Json::Value>& jsonBody,
      const std::function<void(const HttpResponsePtr&)>& callback);

  void TranscriptionImpl(const HttpRequestPtr& req,
                         std::function<void(const HttpResponsePtr&)>&& callback,
                         bool translate);
};
}  // namespace v1

#454

@louis-jan louis-jan requested review from hiro-v and tikikun February 28, 2024 17:05
@louis-jan louis-jan force-pushed the refactor/model-context-should-not-be-in-controllers branch from 307651b to 4bb28f1 Compare February 28, 2024 17:06
Copy link
Contributor

@tikikun tikikun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good implementation, merge

@tikikun tikikun merged commit 97d821d into main Feb 29, 2024
@louis-jan louis-jan deleted the refactor/model-context-should-not-be-in-controllers branch May 24, 2024 03:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants