Hello,
I have a question. We want to connect a LLM that answers incoming chat questions.
For this the answer of the LLM should be combined with the incoming question. From this a knowledge base article should be created.
What is the easiest way to create an article via API, I have the API "Create Document" but can't add a body - only title, categories, variations, visibility.
The title should be the question that was entered and the body the answer of the LLM's but I can't find a way to add the body except through the API Create a variation for a document. The goal is for our experts to be able to generate articles from the LLM's answers and for us to go the LLM route only if no corresponding article is found.
I haven't been able to track down an answer to this, but I'm still asking around. I have a hunch it has to do with POST /api/v2/knowledge/documentuploads, which gives you a signed URL to upload a file. The dots I can't connect are how that uploaded file becomes related to a document. The upload endpoint doesn't allow you to specify a document ID and the document endpoints don't allow you to specify a link to the uploaded file. If I don't respond back to this tomorrow, please open a case with Genesys Cloud Care to report missing documentation for the knowledge APIs as the current docs don't explain this concept.
Is it really the case that there isn't an html parser built into the SDKs? I looked at what it would take to build a variation and it is a pretty tedious lift to write yet another html parser just to load a document / document variation.
For example building a DocumentBody with the following components:
The SDKs are generated based on the API's definition; they only provide a language-specific implementation of the exact contract of the REST API. The variations endpoint above requires JSON content.
Do you know offhand beyond the autogenerated SDKs if there is a helper library that is able to generate the JSON from html using the SDKs api/json?
For example to make a simple DocumentVariation:
from lxml import html
from typing import List
import PureCloudPlatformClientV2
from PureCloudPlatformClientV2.models import m
from m import (
DocumentBody,
DocumentBodyBlock,
DocumentBodyImage,
DocumentBodyImageProperties,
DocumentBodyList,
DocumentBodyListBlock,
DocumentBodyListBlockProperties,
DocumentBodyListItemProperties,
DocumentBodyParagraph,
DocumentBodyParagraphProperties,
DocumentBodyTable,
DocumentBodyTableCaptionBlock,
DocumentBodyTableCaptionItem,
DocumentBodyTableCellBlock,
DocumentBodyTableCellBlockProperties,
DocumentBodyTableProperties,
DocumentBodyTableRowBlock,
DocumentBodyTableRowBlockProperties,
DocumentBodyVideo,
DocumentBodyVideoProperties,
)
dv = DocumentVariation()
dv.body = DocumentBody()
dv.body.blocks = []
block1 = DocumentBodyBlock()
block1.type = 'Paragraph'
block1.paragraph = DocumentBodyParagraph()
block1.paragraph.blocks = []
p1cont = DocumentContentBlock()
p1cont.type = 'Text'
p1cont.text = DocumentText()
p1cont.text = 'hello world'
block1.paragraph.blocks.append(p1cont)
dv.body.blocks.append(block1)
print(f"this seem like too much to be the right way to create a DocumentVariation: {dv}"
In the meantime, if you're up for the task, you could use something like rehype to parse your HTML and generate an AST to upload. Parsing the HTML with that tool is the easy part. Normalizing the AST to the same structure the Genesys API accepts is going to be a source of unending fun. Presumably the repo linked above will help take some of that fun off your plate in the future.