-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' of github.com:ecodeclub/webook into mitten_add_cor…
…rect_post
- Loading branch information
Showing
79 changed files
with
4,628 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
internal/ai/internal/service/llm/handler/biz/case_examine.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package biz | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"unicode/utf8" | ||
|
||
"github.com/ecodeclub/webook/internal/ai/internal/domain" | ||
"github.com/ecodeclub/webook/internal/ai/internal/service/llm/handler" | ||
) | ||
|
||
type CaseExamineBizHandlerBuilder struct { | ||
} | ||
|
||
func NewCaseExamineBizHandlerBuilder() *CaseExamineBizHandlerBuilder { | ||
return &CaseExamineBizHandlerBuilder{} | ||
} | ||
|
||
func (h *CaseExamineBizHandlerBuilder) Next(next handler.Handler) handler.Handler { | ||
return handler.HandleFunc(func(ctx context.Context, req domain.LLMRequest) (domain.LLMResponse, error) { | ||
title := req.Input[0] | ||
userInput := req.Input[1] | ||
userInputLen := utf8.RuneCount([]byte(userInput)) | ||
|
||
if userInputLen > req.Config.MaxInput { | ||
return domain.LLMResponse{}, fmt.Errorf("输入太长,最常不超过 %d,现有长度 %d", req.Config.MaxInput, userInputLen) | ||
} | ||
// 把 input 和 prompt 结合起来 | ||
prompt := fmt.Sprintf(req.Config.PromptTemplate, title, userInput) | ||
req.Prompt = prompt | ||
return next.Handle(ctx, req) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.