mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 14:13:02 -04:00
migrate summaries to mono2
This commit is contained in:
parent
93a95a0523
commit
d13e56324b
3 changed files with 12 additions and 6 deletions
|
@ -5,7 +5,7 @@ const { iconPill, smallIconPill, citation } = require('../../../labscore/utils/m
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
const { STATIC_ICONS } = require('../../../labscore/utils/statics');
|
const { STATIC_ICONS } = require('../../../labscore/utils/statics');
|
||||||
const { summarizeWebpage } = require('../../../labscore/api/obelisk');
|
const { SparkWebSummarize } = require('../../../labscore/api/obelisk');
|
||||||
const { hasFeature } = require('../../../labscore/utils/testing');
|
const { hasFeature } = require('../../../labscore/utils/testing');
|
||||||
|
|
||||||
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([^> \n]*)/
|
const URL_REGEX = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([^> \n]*)/
|
||||||
|
@ -43,17 +43,15 @@ module.exports = {
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_custom", "Generating page summary...", STATIC_ICONS.ai_summary))
|
await editOrReply(context, createEmbed("ai_custom", "Generating page summary...", STATIC_ICONS.ai_summary))
|
||||||
|
|
||||||
let res = await summarizeWebpage(context, webUrl[0])
|
let res = await SparkWebSummarize(context, webUrl[0])
|
||||||
if(!res.response.body.summaries) return editOrReply(context, createEmbed("error", context, "Summary generation failed."))
|
if(!res.response.body.summaries) return editOrReply(context, createEmbed("error", context, "Summary generation failed."))
|
||||||
|
|
||||||
let summaries = [];
|
let summaries = res.response.body.summaries.map((m)=>m.split('\n')[0]);
|
||||||
if(res.response.body.summary_type == 0) summaries = res.response.body.summaries
|
|
||||||
else if (res.response.body.summary_type == 1) summaries = res.response.body.summaries.map((s, i)=>s.content + citation(i + 1, s.reference, 'Reference'))
|
|
||||||
|
|
||||||
return editOrReply(context, createEmbed("defaultNoFooter", context, {
|
return editOrReply(context, createEmbed("defaultNoFooter", context, {
|
||||||
author: {
|
author: {
|
||||||
iconUrl: STATIC_ICONS.ai_summary,
|
iconUrl: STATIC_ICONS.ai_summary,
|
||||||
name: res.response.body.title || 'Key points from the page',
|
name: 'Key points about the page',
|
||||||
url: webUrl[0]
|
url: webUrl[0]
|
||||||
},
|
},
|
||||||
description: '- ' + summaries.join('\n- '),
|
description: '- ' + summaries.join('\n- '),
|
||||||
|
|
|
@ -12,6 +12,8 @@ const ObeliskApi = Object.freeze({
|
||||||
|
|
||||||
GENERATIVEIMAGES_MODELS_IMAGEN: "/generativeimages/v1/models/imagen",
|
GENERATIVEIMAGES_MODELS_IMAGEN: "/generativeimages/v1/models/imagen",
|
||||||
|
|
||||||
|
SPARK_WEB_SUMMARIZE: "/spark-pa/v1/web:summarize",
|
||||||
|
|
||||||
WOLFRAM_QUERY_COMPUTE: "/wolfram/v1/query:compute",
|
WOLFRAM_QUERY_COMPUTE: "/wolfram/v1/query:compute",
|
||||||
|
|
||||||
GOOGLE_BARD: "/parrot/v1/google:bard",
|
GOOGLE_BARD: "/parrot/v1/google:bard",
|
||||||
|
|
|
@ -62,6 +62,12 @@ module.exports.GenerativeImagesModelsImagen = async function(context, prompt){
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.SparkWebSummarize = async function(context, url){
|
||||||
|
return await request(ObeliskApi.SPARK_WEB_SUMMARIZE, "POST", {}, {
|
||||||
|
url
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
module.exports.WolframQueryCompute = async function(context, query){
|
module.exports.WolframQueryCompute = async function(context, query){
|
||||||
return await request(ObeliskApi.WOLFRAM_QUERY_COMPUTE, "POST", {}, {
|
return await request(ObeliskApi.WOLFRAM_QUERY_COMPUTE, "POST", {}, {
|
||||||
query
|
query
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue