Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz committed Feb 24, 2025
1 parent 0cfdc69 commit 482d053
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
20 changes: 20 additions & 0 deletions config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,31 @@ filter = "(now() - item.Timestamp).Hours() < 168"
# # embedding: recommend by Euclidean distance of embeddings.
# # tags: recommend by number of common tags.
# # users: recommend by number of common users.
# # chat: recommend by chat completion model.
# type = "embedding"

# # The column of the item embeddings. Leave blank if type is "users".
# column = "item.Labels.embedding"

# [[recommend.item-to-item]]

# # The name of the item-to-item recommender.
# name = "chat_recommend"

# # The type of the item-to-item recommender.
# type = "chat"

# # The column of the item embeddings. Leave blank if type is "users".
# column = "item.Labels.embedding"

# # The prompt for the chat completion model.
# prompt = """
# This is the description of GitHub repository https://github.com/{{ item.ItemId | replace(':','/') }}:
# {{ item.Comment }}
# Please find some similar repositores on GitHub and provide a brief description for each of them.
# The output should be a JSON array.
# """

[recommend.user_neighbors]

# The type of neighbors for users. There are three types:
Expand Down
2 changes: 2 additions & 0 deletions logics/item_to_item.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ func (g *chatItemToItem) PopAll(i int) []cache.Score {
return nil
}
messages := parseMessage(resp.Choices[0].Message.Content)
log.Logger().Debug("chat based item-to-item recommendation",
zap.String("prompt", buf.String()), zap.Strings("response", messages))
// message embedding
embeddings := make([][]float32, len(messages))
for i, message := range messages {
Expand Down
4 changes: 0 additions & 4 deletions storage/cache/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ const (
UserToUserUpdateTime = "user-to-user_update_time"
Neighbors = "neighbors"

Chat = "chat"
ChatDigest = "chat_digest"
ChatUpdateTime = "chat_update_time"

// ItemCategories is the set of item categories. The format of key:
// Global item categories - item_categories
ItemCategories = "item_categories"
Expand Down

0 comments on commit 482d053

Please sign in to comment.