Fix support for all markdown formatting
This commit is contained in:
parent
d619b495a4
commit
08cb9f35e2
26
src/bot.ts
26
src/bot.ts
|
@ -32,7 +32,7 @@ if (!allVarsFilled) {
|
|||
const session: Messages = checkFile("./messages.json", "utf-8", system.normal);
|
||||
console.log("Our conversation is:", session);
|
||||
|
||||
const THINKING = "[markdown]`Thinking...`[/markdown]";
|
||||
const THINKING = "[md]`Thinking...`[/md]";
|
||||
|
||||
const assistant = new OpenAI({
|
||||
baseURL: endpoint,
|
||||
|
@ -71,7 +71,7 @@ client.connect().then(async () => {
|
|||
await client.sendMessage({
|
||||
converseId: message.converseId,
|
||||
groupId: message.groupId,
|
||||
content: "[markdown]`Generating image...`[/markdown]",
|
||||
content: "[md]`Generating image...`[/md]",
|
||||
});
|
||||
|
||||
const imageRequest: ImageRequestData = {
|
||||
|
@ -108,7 +108,7 @@ client.connect().then(async () => {
|
|||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: `${username} said: Describe what you think is in this image.`,
|
||||
text: `${username} said: Describe what is in this image.`,
|
||||
},
|
||||
{
|
||||
type: "image_url",
|
||||
|
@ -137,12 +137,8 @@ client.connect().then(async () => {
|
|||
converseId: message.converseId,
|
||||
groupId: message.groupId,
|
||||
// @ts-ignore
|
||||
content: response.choices
|
||||
.at(0)
|
||||
// Replace all the ** at the beginning and end of texts with the corresponding Tailchat bold tags.
|
||||
// Tailchat doesn't support these tags. I'll probably implement a regex for the other tags later.
|
||||
.message.content.replaceAll(/([^\s\S]?)(\*\*)(?=\w)/g, " [b]")
|
||||
.replaceAll(/(\*\*)/g, "[/b]"),
|
||||
// Surround in [md] tags to support markdown formatting.
|
||||
content: `[md]${response.choices.at(0)}[/md]`,
|
||||
});
|
||||
|
||||
fs.writeFileSync("./messages.json", JSON.stringify(session), "utf8");
|
||||
|
@ -175,11 +171,8 @@ client.connect().then(async () => {
|
|||
converseId: message.converseId,
|
||||
groupId: message.groupId,
|
||||
// @ts-ignore
|
||||
content: response.choices
|
||||
.at(0)
|
||||
// Same as above. Replace ** with bold tags for Tailchat
|
||||
.message.content.replaceAll(/([^\s\S]?)(\*\*)(?=\w)/g, " [b]")
|
||||
.replaceAll(/(\*\*)/g, "[/b]"),
|
||||
// Same as above. Surround with [md] tags to support markdown formatting.
|
||||
content: `[md]${response.choices.at(0)}[/md]`,
|
||||
});
|
||||
|
||||
fs.writeFileSync("./messages.json", JSON.stringify(session), "utf8");
|
||||
|
@ -221,10 +214,7 @@ client.connect().then(async () => {
|
|||
await client.sendMessage({
|
||||
converseId: message.converseId,
|
||||
// @ts-ignore
|
||||
content: response.choices
|
||||
.at(0)
|
||||
.message.content.replaceAll(/([^\s\S]?)(\*\*)(?=\w)/g, " [b]")
|
||||
.replaceAll(/(\*\*)/g, "[/b]"),
|
||||
content: `[md]${response.choices.at(0)}[/md]`,
|
||||
});
|
||||
|
||||
fs.writeFileSync("./messages.json", JSON.stringify(session), "utf8");
|
||||
|
|
Loading…
Reference in a new issue