Natural language goal determination
A method for a chat bot includes receiving multiple instruction sets corresponding to multiple goals, each instruction set defining a prompt to a large language model (LLM) to achieve a corresponding goal. The method further includes receiving a chat history from a user, comprising multiple messages, each message being one of a user-authored message or a chat bot-authored message, and further comprising metadata associated with said chat history. The method further includes identifying a particular goal of said user from the multiple goals, selecting a particular instruction set corresponding to said particular goal, and defining a particular prompt to the LLM. The method further includes executing said particular instruction set by providing said particular prompt to said LLM and providing a reply to said user with a result of executing said particular instruction set.
1 . A method for a chat bot, comprising:
receiving a plurality of instruction sets corresponding to a plurality of goals, each instruction set in said plurality of instruction sets defining a prompt to a large language model to achieve a corresponding goal in said plurality of goals;
receiving a chat history from a user, said chat history comprising a plurality of messages, each message in said plurality of messages being one of a user-authored message or a chat bot-authored message, and said chat history further comprising metadata associated with said chat history, wherein the chat history and the metadata are included in each request to a stateless application programming interface (API), such that a state of a chat is maintained by a user client and not persisted by the stateless API, wherein the user stores the chat history and the metadata and transmits the chat history and the metadata to the stateless API in each request;
identifying, based on the chat history and said plurality of goals, a particular goal of said user from said plurality of goals;
selecting a particular instruction set from said plurality of instruction sets based on said particular goal, said particular instruction set defining a particular prompt to said large language model, wherein said particular prompt is a first prompt, and wherein said metadata comprises said particular goal, a first index identifying a previously executed instruction in said particular instruction set, and a second index corresponding to a message in said plurality of messages;
executing said particular instruction set by providing said particular prompt to said large language model, wherein executing said particular instruction set further comprises:
based on said first index, selecting a particular instruction from said particular instruction set;
executing said particular instruction;
updating said first index in said metadata to identify said particular instruction;
defining a second prompt to said large language model, said second prompt comprising said particular instruction and said chat history; and
providing said second prompt to said large language model; and
providing a reply to said user with a result of executing said particular instruction set.
2 . The method of claim 1 , wherein said particular instruction includes one of requesting information relevant to said particular goal from said user and generating a query to an external database for data relevant to said particular goal.
3 . The method of claim 1 , wherein determining the particular goal comprises determining that said metadata comprises an identifier for the particular goal.
4 . The method of claim 1 , wherein said particular prompt is a first prompt, and determining the particular goal comprises:
defining a second prompt to said large language model, said second prompt comprising said chat history and said plurality of goals;
providing said second prompt to said large language model;
receiving an output from said large language model, said output comprising said particular goal; and
updating said metadata to include said particular goal.
5 . The method of claim 1 , wherein said particular prompt comprises instructions for collecting information relevant to said particular goal from the user, by generating a user prompt, providing said user prompt to said user, and receiving a reply from said user in response to said user prompt, wherein said reply comprises said information.
6 . The method of claim 5 , wherein said particular prompt comprises instructions for performing a call to an application programming interface, wherein said call comprises said information relevant to said particular goal received from said user.
7 . The method of claim 5 , wherein said particular prompt comprises instructions for performing a function call, wherein said function call comprises said information relevant to said particular goal received from said user.
8 . The method of claim 5 , further comprising updating said metadata to include said information.
9 . The method of claim 1 , wherein said particular prompt comprises instructions for generating a query to an external database for data relevant to said particular goal, providing said query to said external database, and receiving a response from said external database, wherein said response comprises said data.
10 . The method of claim 9 , wherein said particular prompt comprises instructions for performing a call to an application programming interface, wherein said call comprises said data relevant to said particular goal received from said external database.
11 . The method of claim 9 , wherein said particular prompt comprises instructions for performing a function call, wherein said function call comprises said data relevant to said particular goal received from said external database.
12 . The method of claim 9 , further comprising updating said metadata to include said data.
13 . The method of claim 1 , wherein said particular prompt comprises conditional logic to execute a subset of instructions in said particular instruction set.
14 . A non-transitory computer-readable medium storing a set of instructions for a chat bot, which when executed by a computer, configure the computer to:
receive a plurality of instruction sets corresponding to a plurality of goals, each instruction set in said plurality of instruction sets defining a prompt to a large language model to achieve a corresponding goal in said plurality of goals;
receive a chat history from a user, said chat history comprising a plurality of messages, each message in said plurality of messages being one of a user-authored message or a chat bot-authored message, and said chat history further comprising metadata associated with said chat history, wherein the chat history and the metadata are included in each request to a stateless application programming interface (API), such that a state of a chat is maintained by a user client and not persisted by the stateless API, wherein the user stores the chat history and the metadata and transmits the chat history and the metadata to the stateless API in each request;
identify, based on the chat history and said plurality of goals, a particular goal of said user from said plurality of goals;
select a particular instruction set from said plurality of instruction sets based on said particular goal, said particular instruction set defining a particular prompt to said large language model, wherein said particular prompt is a first prompt, and wherein said metadata comprises said particular goal, a first index identifying a previously executed instruction in said particular instruction set, and a second index corresponding to a message in said plurality of messages;
execute said particular instruction set by providing said particular prompt to said large language model, wherein executing said particular instruction set further comprises:
based on said first index, selecting a particular instruction from said particular instruction set;
executing said particular instruction;
updating said first index in said metadata to identify said particular instruction;
defining a second prompt to said large language model, said second prompt comprising said particular instruction and said chat history; and
providing said second prompt to said large language model; and
provide a reply to said user with a result of executing said particular instruction set.
15 . The non-transitory computer-readable medium of claim 14 , wherein said particular instruction includes one of requesting information relevant to said particular goal from said user, and generating a query to an external database for data relevant to said particular goal.
16 . The non-transitory computer-readable medium of claim 14 , wherein determining the particular goal comprises determining that said metadata comprises an identifier for the particular goal.
17 . The non-transitory computer-readable medium of claim 14 , wherein said particular prompt is a first prompt, and determining the particular goal comprises:
defining a second prompt to said large language model, said second prompt comprising said chat history and said plurality of goals;
providing said second prompt to said large language model;
receiving an output from said large language model, said output comprising said particular goal; and
updating said metadata to include said particular goal.
18 . The non-transitory computer-readable medium of claim 14 , wherein said particular prompt comprises instructions for collecting information relevant to said particular goal from the user, by generating a user prompt, providing said user prompt to said user, and receiving a reply from said user in response to said user prompt, wherein said reply comprises said information.
19 . The non-transitory computer-readable medium of claim 18 , wherein said particular prompt comprises instructions for performing a call to an application programming interface, wherein said call comprises said information relevant to said particular goal received from said user.
20 . The non-transitory computer-readable medium of claim 18 , wherein said particular prompt comprises instructions for performing a function call, wherein said function call comprises said information relevant to said particular goal received from said user.
21 . The non-transitory computer-readable medium of claim 18 , further comprising updating said metadata to include said information.
22 . The non-transitory computer-readable medium of claim 14 , wherein said particular prompt comprises instructions for generating a query to an external database for data relevant to said particular goal, providing said query to said external database, and receiving a response from said external database, wherein said response comprises said data.
23 . The non-transitory computer-readable medium of claim 22 , wherein said particular prompt comprises instructions for performing a call to an application programming interface, wherein said call comprises said data relevant to said particular goal received from said external database.
24 . The non-transitory computer-readable medium of claim 22 , wherein said particular prompt comprises instructions for performing a function call, wherein said function call comprises said data relevant to said particular goal received from said external database.
25 . The non-transitory computer-readable medium of claim 22 , wherein the instructions, when executed by the computer, further configure the computer to update said metadata to include said data.
26 . The non-transitory computer-readable medium of claim 14 , wherein said particular prompt comprises conditional logic to execute a subset of instructions in said particular instruction set.