mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -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 { 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 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{
|
||||
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."))
|
||||
|
||||
let summaries = [];
|
||||
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'))
|
||||
let summaries = res.response.body.summaries.map((m)=>m.split('\n')[0]);
|
||||
|
||||
return editOrReply(context, createEmbed("defaultNoFooter", context, {
|
||||
author: {
|
||||
iconUrl: STATIC_ICONS.ai_summary,
|
||||
name: res.response.body.title || 'Key points from the page',
|
||||
name: 'Key points about the page',
|
||||
url: webUrl[0]
|
||||
},
|
||||
description: '- ' + summaries.join('\n- '),
|
||||
|
|
|
@ -12,6 +12,8 @@ const ObeliskApi = Object.freeze({
|
|||
|
||||
GENERATIVEIMAGES_MODELS_IMAGEN: "/generativeimages/v1/models/imagen",
|
||||
|
||||
SPARK_WEB_SUMMARIZE: "/spark-pa/v1/web:summarize",
|
||||
|
||||
WOLFRAM_QUERY_COMPUTE: "/wolfram/v1/query:compute",
|
||||
|
||||
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){
|
||||
return await request(ObeliskApi.WOLFRAM_QUERY_COMPUTE, "POST", {}, {
|
||||
query
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue