-
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.
* 添加案例集 * 添加候选案例 * 为案例集添加进度 * maka check * 添加githubrepo
- Loading branch information
1 parent
4ea6f7b
commit 0a37181
Showing
44 changed files
with
3,708 additions
and
426 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package domain | ||
|
||
import "github.com/ecodeclub/ekit/slice" | ||
|
||
type CaseSet struct { | ||
ID int64 | ||
Uid int64 | ||
// 标题 | ||
Title string | ||
// 描述 | ||
Description string | ||
Biz string | ||
BizId int64 | ||
Cases []Case | ||
Utime int64 | ||
} | ||
|
||
func (set CaseSet) Cids() []int64 { | ||
return slice.Map(set.Cases, func(idx int, src Case) int64 { | ||
return src.Id | ||
}) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package domain | ||
|
||
var ( | ||
DefaultBiz = "baguwen" | ||
) |
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,31 @@ | ||
package domain | ||
|
||
type ExamineCaseResult struct { | ||
Cid int64 | ||
Result CaseResult | ||
// 原始回答,源自 AI | ||
RawResult string | ||
|
||
// 使用的 token 数量 | ||
Tokens int64 | ||
// 花费的金额 | ||
Amount int64 | ||
Tid string | ||
} | ||
|
||
type CaseResult uint8 | ||
|
||
func (r CaseResult) ToUint8() uint8 { | ||
return uint8(r) | ||
} | ||
|
||
const ( | ||
// ResultFailed 完全没通过,或者完全没有考过,我们不需要区别这两种状态 | ||
ResultFailed CaseResult = iota | ||
// ResultBasic 只回答出来了 15K 的部分 | ||
ResultBasic | ||
// ResultIntermediate 回答了 25K 部分 | ||
ResultIntermediate | ||
// ResultAdvanced 回答出来了 35K 部分 | ||
ResultAdvanced | ||
) |
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
Oops, something went wrong.