Skip to content

Commit

Permalink
Merge pull request #210 from ubiquity-os-marketplace/development
Browse files Browse the repository at this point in the history
Merge development into main
  • Loading branch information
gentlementlegen authored Dec 12, 2024
2 parents 2fd5ed2 + 5aaeaea commit efcb4be
Show file tree
Hide file tree
Showing 22 changed files with 735 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"mswjs",
"Rpcs",
"sonarjs",
"pico"
"pico",
"timespan"
],
"dictionaries": ["typescript", "node", "software-terms"],
"import": [
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** linguist-generated
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ with:
relevance: 1
userExtractor:
redeemTask: true
dataPurge: {}
dataPurge:
skipCommentsWhileAssigned: all
formattingEvaluator:
wordCountExponent: 0.85
multipliers:
Expand Down
Binary file modified bun.lockb
Binary file not shown.
32 changes: 16 additions & 16 deletions dist/index.js

Large diffs are not rendered by default.

57 changes: 56 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
"properties": {
"evmNetworkId": {
"default": 100,
"description": "Network ID to run in, default to 100",
"examples": ["100"],
"type": "number"
},
"evmPrivateEncrypted": {
"description": "The encrypted key to use for permit generation",
"examples": ["0x000..."],
"type": "string"
},
"erc20RewardToken": {
Expand All @@ -22,10 +26,13 @@
"type": "object",
"properties": {
"file": {
"description": "Specify a file to write the results in",
"examples": ["./result.json"],
"type": "string"
},
"requirePriceLabel": {
"default": true,
"description": "If set to false, the plugin runs even if the price label is missing, and will evaluate comments.",
"type": "boolean"
},
"limitRewards": {
Expand All @@ -45,11 +52,15 @@
"properties": {
"model": {
"default": "gpt-4o-2024-08-06",
"description": "OpenAI model, e.g. gpt-4o",
"examples": ["gpt-4o"],
"type": "string"
},
"endpoint": {
"default": "https://api.openai.com/v1",
"pattern": "^(https?:\\/\\/[^\\s$.?#].\\S*)$",
"description": "OpenAI endpoint for requests",
"examples": ["https://api.openai.com/v1"],
"type": "string"
}
}
Expand All @@ -61,11 +72,14 @@
"relevance": 1
}
],
"description": "Multipliers applied to different types of comments",
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"description": "Roles that this multiplier applies to",
"examples": ["[\"PULL_ASSIGNEE\", \"PULL_AUTHOR\", \"PULL_COLLABORATOR\"]"],
"type": "array",
"items": {
"anyOf": [
Expand Down Expand Up @@ -233,6 +247,8 @@
}
},
"relevance": {
"description": "Relevance multiplier for this role",
"examples": ["2"],
"type": "number"
}
},
Expand All @@ -254,6 +270,7 @@
"properties": {
"redeemTask": {
"default": true,
"description": "Is the task redeemable, e.g. can the user collect the bounty?",
"type": "boolean"
}
}
Expand All @@ -268,7 +285,27 @@
"anyOf": [
{
"type": "object",
"properties": {}
"properties": {
"skipCommentsWhileAssigned": {
"default": "all",
"description": "Configures how user comments are included in the rewards calculation when they are assigned to a GitHub issue:\n\n- 'all': Excludes all comments made between the first assignment start and the last assignment end, discouraging gaming by un-assigning and commenting for rewards.\n- 'exact': Excludes only comments made during precise assignment periods, targeting times when the user is actively assigned.\n- 'none': Includes all comments, regardless of assignment status or timing.",
"examples": ["all", "exact", "none"],
"anyOf": [
{
"const": "all",
"type": "string"
},
{
"const": "exact",
"type": "string"
},
{
"const": "none",
"type": "string"
}
]
}
}
},
{
"type": "null"
Expand All @@ -283,6 +320,7 @@
"type": "object",
"properties": {
"multipliers": {
"description": "Multipliers applied to different parts of the comment according the role of the author",
"default": [
{
"role": ["ISSUE_SPECIFICATION"],
Expand Down Expand Up @@ -1181,6 +1219,8 @@
"properties": {
"role": {
"minItems": 1,
"description": "The list of roles this multiplier applies to",
"examples": ["[\"PULL_ASSIGNEE\", \"PULL_AUTHOR\", \"PULL_COLLABORATOR\"]"],
"type": "array",
"items": {
"anyOf": [
Expand Down Expand Up @@ -1348,13 +1388,16 @@
}
},
"multiplier": {
"examples": ["1"],
"description": "Multiplier for the given list of roles",
"type": "number"
},
"rewards": {
"default": {},
"type": "object",
"properties": {
"html": {
"description": "Attributed score per HTML entity",
"default": {
"br": {
"score": 0,
Expand Down Expand Up @@ -1443,10 +1486,13 @@
"type": "object",
"properties": {
"score": {
"description": "Score per word in the entity",
"examples": ["0.1"],
"type": "number"
},
"countWords": {
"default": true,
"description": "Whether to count words in the entity",
"type": "boolean"
}
},
Expand All @@ -1456,6 +1502,7 @@
},
"wordValue": {
"default": 0.1,
"description": "Value multiplier for each word",
"type": "number"
}
}
Expand All @@ -1466,6 +1513,8 @@
},
"wordCountExponent": {
"default": 0.85,
"description": "Exponent applied to the word count total",
"examples": ["0.85"],
"type": "number"
}
}
Expand Down Expand Up @@ -1496,10 +1545,12 @@
"properties": {
"post": {
"default": true,
"description": "Enables posting to the related GitHub Issue",
"type": "boolean"
},
"debug": {
"default": false,
"description": "Enables debug by creating a local html file of the rendered comment",
"type": "boolean"
}
}
Expand All @@ -1518,11 +1569,15 @@
"maxAttempts": {
"default": 10,
"minimum": 1,
"description": "The maximum amount of retries on failure",
"examples": ["10"],
"type": "number"
},
"delayMs": {
"default": 1000,
"minimum": 100,
"description": "The delay between each retry, in milliseconds",
"examples": ["1000"],
"type": "number"
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@supabase/supabase-js": "2.42.0",
"@ubiquity-dao/rpc-handler": "1.3.0",
"@ubiquity-os/permit-generation": "^2.0.6",
"@ubiquity-os/plugin-sdk": "^1.1.0",
"@ubiquity-os/plugin-sdk": "^1.1.1",
"@ubiquity-os/ubiquity-os-logger": "^1.3.2",
"decimal.js": "10.4.3",
"ethers": "^5.7.2",
Expand Down
21 changes: 17 additions & 4 deletions src/configuration/content-evaluator-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ const openAiType = Type.Object(
/**
* AI model to use for comment evaluation.
*/
model: Type.String({ default: "gpt-4o-2024-08-06" }),
model: Type.String({
default: "gpt-4o-2024-08-06",
description: "OpenAI model, e.g. gpt-4o",
examples: ["gpt-4o"],
}),
/**
* Specific endpoint to send the comments to.
*/
endpoint: Type.String({ default: "https://api.openai.com/v1", pattern: /^(https?:\/\/[^\s$.?#].\S*)$/i.source }),
endpoint: Type.String({
default: "https://api.openai.com/v1",
pattern: /^(https?:\/\/[^\s$.?#].\S*)$/i.source,
description: "OpenAI endpoint for requests",
examples: ["https://api.openai.com/v1"],
}),
},
{ default: {} }
);
Expand All @@ -22,8 +31,11 @@ export const contentEvaluatorConfigurationType = Type.Object({
*/
multipliers: Type.Array(
Type.Object({
role: Type.Array(commentType),
relevance: Type.Optional(Type.Number()),
role: Type.Array(commentType, {
description: "Roles that this multiplier applies to",
examples: ['["PULL_ASSIGNEE", "PULL_AUTHOR", "PULL_COLLABORATOR"]'],
}),
relevance: Type.Optional(Type.Number({ description: "Relevance multiplier for this role", examples: ["2"] })),
}),
{
default: [
Expand All @@ -32,6 +44,7 @@ export const contentEvaluatorConfigurationType = Type.Object({
relevance: 1,
},
],
description: "Multipliers applied to different types of comments",
}
),
});
Expand Down
14 changes: 12 additions & 2 deletions src/configuration/data-collection-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ export const dataCollectionConfigurationType = Type.Object(
/**
* The maximum amount of retries on failure.
*/
maxAttempts: Type.Number({ default: 10, minimum: 1 }),
maxAttempts: Type.Number({
default: 10,
minimum: 1,
description: "The maximum amount of retries on failure",
examples: ["10"],
}),
/**
* The delay between each retry, in milliseconds.
*/
delayMs: Type.Number({ default: 1000, minimum: 100 }),
delayMs: Type.Number({
default: 1000,
minimum: 100,
description: "The delay between each retry, in milliseconds",
examples: ["1000"],
}),
},
{ default: {} }
);
Expand Down
12 changes: 11 additions & 1 deletion src/configuration/data-purge-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { Type, Static } from "@sinclair/typebox";

export const dataPurgeConfigurationType = Type.Object({});
export const dataPurgeConfigurationType = Type.Object({
skipCommentsWhileAssigned: Type.Union([Type.Literal("all"), Type.Literal("exact"), Type.Literal("none")], {
default: "all",
description:
"Configures how user comments are included in the rewards calculation when they are assigned to a GitHub issue:\n\n" +
"- 'all': Excludes all comments made between the first assignment start and the last assignment end, discouraging gaming by un-assigning and commenting for rewards.\n" +
"- 'exact': Excludes only comments made during precise assignment periods, targeting times when the user is actively assigned.\n" +
"- 'none': Includes all comments, regardless of assignment status or timing.",
examples: ["all", "exact", "none"],
}),
});

export type DataPurgeConfiguration = Static<typeof dataPurgeConfigurationType>;
22 changes: 16 additions & 6 deletions src/configuration/formatting-evaluator-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ export const wordRegex = /\b\w+\b/;
export const urlRegex = /https?:\/\/\S+/g;

const htmlEntity = Type.Object({
score: Type.Number(),
countWords: Type.Boolean({ default: true }),
score: Type.Number({ description: "Score per word in the entity", examples: ["0.1"] }),
countWords: Type.Boolean({ default: true, description: "Whether to count words in the entity" }),
});

/**
* Attributed score per HTML entity
*/
const htmlType = Type.Record(Type.String(), htmlEntity, {
description: "Attributed score per HTML entity",
default: {
br: { score: 0, countWords: true },
code: { score: 5, countWords: false },
Expand Down Expand Up @@ -53,7 +54,7 @@ const htmlType = Type.Record(Type.String(), htmlEntity, {
const rewardsType = Type.Object(
{
html: htmlType,
wordValue: Type.Number({ default: 0.1 }),
wordValue: Type.Number({ default: 0.1, description: "Value multiplier for each word" }),
},
{ default: {} }
);
Expand All @@ -66,11 +67,16 @@ export const formattingEvaluatorConfigurationType = Type.Object(
multipliers: Type.Transform(
Type.Array(
Type.Object({
role: Type.Array(commentType, { minItems: 1 }),
multiplier: Type.Number(),
role: Type.Array(commentType, {
minItems: 1,
description: "The list of roles this multiplier applies to",
examples: ['["PULL_ASSIGNEE", "PULL_AUTHOR", "PULL_COLLABORATOR"]'],
}),
multiplier: Type.Number({ examples: ["1"], description: "Multiplier for the given list of roles" }),
rewards: rewardsType,
}),
{
description: "Multipliers applied to different parts of the comment according the role of the author",
default: [
{
role: ["ISSUE_SPECIFICATION"],
Expand Down Expand Up @@ -140,7 +146,11 @@ export const formattingEvaluatorConfigurationType = Type.Object(
.Encode((value) => {
return value;
}),
wordCountExponent: Type.Number({ default: 0.85 }),
wordCountExponent: Type.Number({
default: 0.85,
description: "Exponent applied to the word count total",
examples: ["0.85"],
}),
},
{ default: {} }
);
Expand Down
7 changes: 5 additions & 2 deletions src/configuration/github-comment-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ export const githubCommentConfigurationType = Type.Object(
/**
* Enables posting to the related GitHub Issue
*/
post: Type.Boolean({ default: true }),
post: Type.Boolean({ default: true, description: "Enables posting to the related GitHub Issue" }),
/**
* Enables debug by creating a local html file of the rendered comment
*/
debug: Type.Boolean({ default: false }),
debug: Type.Boolean({
default: false,
description: "Enables debug by creating a local html file of the rendered comment",
}),
},
{ default: {} }
);
Expand Down
Loading

0 comments on commit efcb4be

Please sign in to comment.