new(security.gblib): SMS Auth.
This commit is contained in:
parent
eb260b54f9
commit
e4a4c127c9
3 changed files with 19 additions and 31 deletions
14
boot.mjs
14
boot.mjs
|
@ -9,18 +9,8 @@ import { GBUtil } from './dist/src/util.js';
|
||||||
|
|
||||||
// Displays version of Node JS being used at runtime and others attributes.
|
// Displays version of Node JS being used at runtime and others attributes.
|
||||||
|
|
||||||
await GBUtil.sleep(80);
|
console.log(`General Bots is loading source code files...`);
|
||||||
console.log(``);
|
|
||||||
console.log(``);
|
|
||||||
console.log(``);
|
|
||||||
await chalkAnimation.karaoke(`
|
|
||||||
█████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ®
|
|
||||||
██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █
|
|
||||||
██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██
|
|
||||||
██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █
|
|
||||||
█████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███
|
|
||||||
`,1000);
|
|
||||||
await GBUtil.sleep(80);
|
|
||||||
var __dirname = process.env.PWD || process.cwd();
|
var __dirname = process.env.PWD || process.cwd();
|
||||||
try {
|
try {
|
||||||
var run = () => {
|
var run = () => {
|
||||||
|
|
|
@ -67,9 +67,7 @@ import { ChatGeneration, Generation } from "@langchain/core/outputs";
|
||||||
export interface CustomOutputParserFields { }
|
export interface CustomOutputParserFields { }
|
||||||
|
|
||||||
// This can be more generic, like Record<string, string>
|
// This can be more generic, like Record<string, string>
|
||||||
export type ExpectedOutput = {
|
export type ExpectedOutput = string;
|
||||||
greeting: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
function isChatGeneration(
|
function isChatGeneration(
|
||||||
llmOutput: ChatGeneration | Generation
|
llmOutput: ChatGeneration | Generation
|
||||||
|
@ -178,11 +176,7 @@ export class ChatServices {
|
||||||
const context = min['vectorStore'];
|
const context = min['vectorStore'];
|
||||||
|
|
||||||
const modelWithTools = model.bind({
|
const modelWithTools = model.bind({
|
||||||
tools: tools.map(convertToOpenAITool),
|
tools: tools.map(convertToOpenAITool)
|
||||||
tool_choice: {
|
|
||||||
type: "function",
|
|
||||||
function: { name: "multiply" },
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function for dynamically constructing the end of the chain based on the model-selected tool.
|
// Function for dynamically constructing the end of the chain based on the model-selected tool.
|
||||||
|
@ -209,7 +203,13 @@ export class ChatServices {
|
||||||
|
|
||||||
const questionGeneratorTemplate = ChatPromptTemplate.fromMessages([
|
const questionGeneratorTemplate = ChatPromptTemplate.fromMessages([
|
||||||
AIMessagePromptTemplate.fromTemplate(
|
AIMessagePromptTemplate.fromTemplate(
|
||||||
"Given the following conversation about a codebase and a follow up question, rephrase the follow up question to be a standalone question."
|
`Answer the question without calling any tool, but if there is a need to call:
|
||||||
|
|
||||||
|
|
||||||
|
You have access to the following set of tools. Here are the names and descriptions for each tool:
|
||||||
|
|
||||||
|
${toolsAsText}
|
||||||
|
`
|
||||||
),
|
),
|
||||||
new MessagesPlaceholder("chat_history"),
|
new MessagesPlaceholder("chat_history"),
|
||||||
AIMessagePromptTemplate.fromTemplate(`Follow Up Input: {question}
|
AIMessagePromptTemplate.fromTemplate(`Follow Up Input: {question}
|
||||||
|
@ -221,9 +221,7 @@ export class ChatServices {
|
||||||
`Use the following pieces of context to answer the question at the end.
|
`Use the following pieces of context to answer the question at the end.
|
||||||
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
||||||
\n\n{context}\n\n
|
\n\n{context}\n\n
|
||||||
You have the following tools to call:
|
`
|
||||||
${toolsAsText}`
|
|
||||||
|
|
||||||
),
|
),
|
||||||
new MessagesPlaceholder("chat_history"),
|
new MessagesPlaceholder("chat_history"),
|
||||||
HumanMessagePromptTemplate.fromTemplate("Question: {question}"),
|
HumanMessagePromptTemplate.fromTemplate("Question: {question}"),
|
||||||
|
@ -243,7 +241,7 @@ export class ChatServices {
|
||||||
},
|
},
|
||||||
combineDocumentsPrompt,
|
combineDocumentsPrompt,
|
||||||
modelWithTools,
|
modelWithTools,
|
||||||
new CustomLLMOutputParser(),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const conversationalQaChain = RunnableSequence.from([
|
const conversationalQaChain = RunnableSequence.from([
|
||||||
|
@ -256,12 +254,9 @@ export class ChatServices {
|
||||||
},
|
},
|
||||||
questionGeneratorTemplate,
|
questionGeneratorTemplate,
|
||||||
modelWithTools,
|
modelWithTools,
|
||||||
new StringOutputParser(),
|
new CustomLLMOutputParser()
|
||||||
combineDocumentsChain,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const systemPrompt = user['systemPrompt'];
|
const systemPrompt = user['systemPrompt'];
|
||||||
|
|
||||||
let result = await conversationalQaChain.invoke({
|
let result = await conversationalQaChain.invoke({
|
||||||
|
@ -283,7 +278,7 @@ export class ChatServices {
|
||||||
|
|
||||||
private static getToolsAsText(tools) {
|
private static getToolsAsText(tools) {
|
||||||
return Object.keys(tools)
|
return Object.keys(tools)
|
||||||
.map((toolname) => `${tools[toolname].name}: ${tools[toolname].description}`)
|
.map((toolname) => `- ${tools[toolname].name}: ${tools[toolname].description}`)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -802,6 +802,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
id = req.from.split('@')[0];
|
id = req.from.split('@')[0];
|
||||||
senderName = req._data.notifyName;
|
senderName = req._data.notifyName;
|
||||||
text = req.body;
|
text = req.body;
|
||||||
|
botId=botId?? this.botId;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -814,6 +815,8 @@ export class WhatsappDirectLine extends GBService {
|
||||||
p => p.instance.botId.toLowerCase() === text.toLowerCase()
|
p => p.instance.botId.toLowerCase() === text.toLowerCase()
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
|
|
||||||
|
botId = botId??GBServer.globals.minBoot.botId;
|
||||||
GBLog.info(`A WhatsApp mobile requested instance for: ${botId}.`);
|
GBLog.info(`A WhatsApp mobile requested instance for: ${botId}.`);
|
||||||
|
|
||||||
let urlMin: any = GBServer.globals.minInstances.filter(p => p.instance.botId === botId)[0];
|
let urlMin: any = GBServer.globals.minInstances.filter(p => p.instance.botId === botId)[0];
|
||||||
|
|
Loading…
Add table
Reference in a new issue