Skip to content

Merge develop into main #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Sep 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: AIのリソースを切り替えられるように変更
*今はgRPCのサーバのみ実装
mochi-yu committed Sep 10, 2023
commit d6ef59d26e9091c98e2628019f19c572415457dd
24 changes: 14 additions & 10 deletions cmd/suggest.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
"strings"

tea "github.com/charmbracelet/bubbletea"
"github.com/cocoide/commitify/internal/entity"
"github.com/cocoide/commitify/internal/gateway"
"github.com/cocoide/commitify/util"
"github.com/fatih/color"
@@ -21,17 +22,20 @@ type model struct {
}

func (m *model) Init() tea.Cmd {
// 本当はこう書きたい。今は一旦全てgrpcサーバに呼び出し
// switch conf.endpoint {
// case openai:
// ~~~
// case grpc_serve:
// ~~~
// }
// var gateway gatewayInterface
conf, err := entity.ReadConfig()
if err != nil {
log.Fatal("設定情報の取得に失敗: ", err)
}

var gi gateway.GatewayInterface
switch conf.AISource {
case int(entity.WrapServer):
gi = gateway.NewGrpcServeGateway()
default:
gi = gateway.NewGrpcServeGateway()
}

gsg := gateway.NewGrpcServeGateway()
messages, err := gsg.FetchCommitMessages()
messages, err := gi.FetchCommitMessages()
if err != nil {
log.Fatal("コミットメッセージの生成に失敗: ", err)
os.Exit(-1)
5 changes: 5 additions & 0 deletions internal/gateway/gateway_interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package gateway

type GatewayInterface interface {
FetchCommitMessages() ([]string, error)
}