Skip to content

Commit 59d0a6d

Browse files
committed
add: updated_at sort method
1 parent ef993b6 commit 59d0a6d

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

main.go

+13-8
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,23 @@ func OpenaiRequest(prompt string) string {
5353
option.WithBaseURL(LLMBASEURL),
5454
}
5555
client := openai.NewClient(a...)
56-
chatCompletion, err := client.Chat.Completions.New(context.TODO(), openai.ChatCompletionNewParams{
57-
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
58-
openai.UserMessage(`我有一个标过star的github库需要进行分类和标记,给出最相关的8个标记。我会给你它的的readme文件,请你分析后给出一个json结构的标签,
56+
chatCompletion, err := client.Chat.Completions.New(
57+
context.TODO(),
58+
openai.ChatCompletionNewParams{
59+
Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
60+
openai.UserMessage(
61+
`我有一个标过star的github库需要进行分类和标记,给出最相关的8个标记。我会给你它的的readme文件,请你分析后给出一个json结构的标签,
5962
限制:只给出严格的json结果,其他内容比如json标签等不需要。
6063
输出格式严格如下
6164
{
6265
"tags": []
63-
}`),
64-
openai.UserMessage(prompt),
65-
}),
66-
Model: openai.F("deepseek-chat"),
67-
})
66+
}`,
67+
),
68+
openai.UserMessage(prompt),
69+
}),
70+
Model: openai.F("deepseek-chat"),
71+
},
72+
)
6873
if err != nil {
6974
fmt.Println(prompt)
7075
return ""

model/star_model.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
package model
22

3+
import "time"
4+
35
type StarInfo struct {
4-
Name string `json:"name"`
5-
FullName string `json:"full_name"`
6-
Url string `json:"url"`
7-
HtmlUrl string `json:"html_url"`
8-
Description *string `json:"description"`
9-
Homepage *string `json:"homepage"`
10-
Language *string `json:"language"`
11-
Topics []string `json:"topics"`
12-
StargazersCount int `json:"stargazers_count"`
13-
AI_tag AI_tag `json:"ai_tag"`
6+
Name string `json:"name"`
7+
FullName string `json:"full_name"`
8+
Url string `json:"url"`
9+
HtmlUrl string `json:"html_url"`
10+
Description *string `json:"description"`
11+
Homepage *string `json:"homepage"`
12+
Language *string `json:"language"`
13+
Topics []string `json:"topics"`
14+
StargazersCount int `json:"stargazers_count"`
15+
UpdatedAt time.Time `json:"updated_at"`
16+
AI_tag AI_tag `json:"ai_tag"`
1417
}
1518
type ReadmeData struct {
1619
Name string `json:"name"`

web/src/App.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const ProjectShowcase = () => {
129129
return Object.entries(tagFrequency)
130130
.sort((a, b) => b[1] - a[1])
131131
.slice(0, 30)
132-
.map(([tag]) => tag);
132+
.map(([tag]) => tag);
133133
}, [tagFrequency]);
134134

135135
// Fuzzy search setup
@@ -170,6 +170,12 @@ const ProjectShowcase = () => {
170170
);
171171
}
172172

173+
if (sortMethod === 'updated-time') {
174+
result = [...result].sort((a, b) =>
175+
new Date(b.updated_at) - new Date(a.updated_at)
176+
);
177+
}
178+
173179
return result;
174180
}, [projects, searchTerm, selectedTags, sortMethod, fuse]);
175181

@@ -227,6 +233,7 @@ const ProjectShowcase = () => {
227233
>
228234
<option value="default">Default</option>
229235
<option value="stars">Star Count</option>
236+
<option value="updated-time">Updated Time</option>
230237
</select>
231238
</div>
232239
</div>
@@ -269,4 +276,4 @@ const ProjectShowcase = () => {
269276
);
270277
};
271278

272-
export default ProjectShowcase;
279+
export default ProjectShowcase;

0 commit comments

Comments
 (0)