From 60554b0c2e06e3941cf93d2218daa0ac50a769d4 Mon Sep 17 00:00:00 2001 From: Sheng Liang Date: Tue, 27 Feb 2024 18:27:15 -0800 Subject: [PATCH 1/4] Added README-USECASES.md --- docs/README-USECASES.md | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 docs/README-USECASES.md diff --git a/docs/README-USECASES.md b/docs/README-USECASES.md new file mode 100644 index 00000000..c281683c --- /dev/null +++ b/docs/README-USECASES.md @@ -0,0 +1,91 @@ +# Use Cases of GPTScript + +## Retrieval + +Retrieval-Augmented Generation (RAG) leverages a knowledge base outside of the training data before consulting the LLM to generate a response. +The following GPTScript implements RAG: + +```yaml +name: rag +description: implements retrieval-augmented generation +args: prompt: a string +tools: query + +First query the ${prompt} in the knowledge base, then construsts an answer to ${prompt} based on the result of the query. + +--- + +name: query +description: queries the prompt in the knowledge base +args: prompt: a string + +... (implementation of knowledge base query follows) ... +``` + +The idea behind RAG is simple. Its core logic can be implemented in one GPTScript statement: `First query the ${prompt} in the knowledge base, then construsts an answer to ${prompt} based on the result of the query.` The real work of building RAG lies in the tool that queries your knowledge base. + +You construct the appropriate query tool based on the type of knowledge base you have. + +| Knowledge Base | Query Tool | +|------|------| +| A vector database storing common document types such as text, HTML, PDF, and Word | Integrate with LlamaIndex for vector database support [Link to example]| +| Use the public or private internet to supply up-to-date knowledge | Implement query tools using a search engine, as shown in [`search.gpt`](../examples/search.gpt)| +| A structured database supporting SQL such as sqlite, MySQL, PostgreSQL, and Oracle DB | Implement query tools using database command line tools such as `sqlite` and `mysql` [Link to example]| +| An ElasticSearch/OpenSearch database storing logs or other text files | Implement query tools using database command line tools [Link to example]| +| Other databases such as graph or time series databases | Implement query tools using database command line tools [Link to example]| + +## Agents and Assistants + +Agents and assistants are synonyms. They are software programs that leverage LLM to carry out tasks. + +In GPTScript, agents and assistants are implemented using tools. Tools can use other tools. Tools can be implemented using natural language prompts or using traditional programming languages such as Python or JavaScript. You can therefore build arbitrarily complex agents and assistants in GPTScript. + +## Data Analysis + +Depending on the context window supported by the LLM, you can either send a large amount of data to the LLM to analyze in one shot or supply data in batches. + +### Summerization + +Here is a GPTScript that sends a large document in batches to the LLM and produces a summary of the entire document. [Link to example here] + +Here is a GPTScript that reads the content of a large SQL database and produces a summary of the entire database. [Link to example here] + +### Tagging + +Here is a GPTScript that performs sentiment analysis on the input text. [Link to example here] + +### CVS Files + +Here is a GPTScript that summarizes the content of a CSV file. [Link to example here] + +### Understanding Code + +Here is a GPTScript that summarizes the the code stored in a given directory. [Link to example here] + +## Task Automation + +### Planning + +Here is a GPTScript that produces a detailed travel itenirary based on inputs from a user. [Link to example here] + +### Web UI Automation + +Here is a GPTScript that automates data gathering and analysis of web sites by driving a web browser. [Link to example here] + +### CLI Automation + +Here is a GPTScript that automates Kubernetes operations by driving the `kubectl` command line. [Link to example here] + +## Audio, Image, and Vision + +[More details to come] + +## Memory Management + +GPTScript provides a means to manage memory that persists across multiple LLM invocations. The relevant information can be extracted and passed into the LLM as part of the context. In addition, LLM can utilize tools to obtain additional data from the memory maintained in GPTScript. + +[More details to follow.] + +## Chatbots + +GPTScript in combination with Rubra UI provide you with a turn-key implementation of chatbots. [More details to follow] From d1d574ac71c81de1c7394c1790817970f45c3f83 Mon Sep 17 00:00:00 2001 From: Sheng Liang Date: Tue, 27 Feb 2024 18:39:18 -0800 Subject: [PATCH 2/4] Fix typo --- docs/README-USECASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README-USECASES.md b/docs/README-USECASES.md index c281683c..b7114164 100644 --- a/docs/README-USECASES.md +++ b/docs/README-USECASES.md @@ -54,7 +54,7 @@ Here is a GPTScript that reads the content of a large SQL database and produces Here is a GPTScript that performs sentiment analysis on the input text. [Link to example here] -### CVS Files +### CSV Files Here is a GPTScript that summarizes the content of a CSV file. [Link to example here] From 6f78d3bd64a2c5139cf63faa40d44639781c8f5a Mon Sep 17 00:00:00 2001 From: Sheng Liang Date: Wed, 28 Feb 2024 17:15:13 -0800 Subject: [PATCH 3/4] Fix typo and wordings --- docs/README-USECASES.md | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/README-USECASES.md b/docs/README-USECASES.md index b7114164..9a3c2b55 100644 --- a/docs/README-USECASES.md +++ b/docs/README-USECASES.md @@ -34,6 +34,20 @@ You construct the appropriate query tool based on the type of knowledge base you | An ElasticSearch/OpenSearch database storing logs or other text files | Implement query tools using database command line tools [Link to example]| | Other databases such as graph or time series databases | Implement query tools using database command line tools [Link to example]| +## Task Automation + +### Planning + +Here is a GPTScript that produces a detailed travel itenirary based on inputs from a user: [`travel-agent.gpt`](../examples/travel-agent.gpt) + +### Web UI Automation + +Here is a GPTScript that automates data gathering and analysis of web sites by interacting with a chrome web browser. [Link to example here] + +### CLI Automation + +Here is a GPTScript that automates Kubernetes operations by driving the `kubectl` command line. [Link to example here] + ## Agents and Assistants Agents and assistants are synonyms. They are software programs that leverage LLM to carry out tasks. @@ -44,7 +58,7 @@ In GPTScript, agents and assistants are implemented using tools. Tools can use o Depending on the context window supported by the LLM, you can either send a large amount of data to the LLM to analyze in one shot or supply data in batches. -### Summerization +### Summarization Here is a GPTScript that sends a large document in batches to the LLM and produces a summary of the entire document. [Link to example here] @@ -62,26 +76,14 @@ Here is a GPTScript that summarizes the content of a CSV file. [Link to example Here is a GPTScript that summarizes the the code stored in a given directory. [Link to example here] -## Task Automation - -### Planning - -Here is a GPTScript that produces a detailed travel itenirary based on inputs from a user. [Link to example here] - -### Web UI Automation - -Here is a GPTScript that automates data gathering and analysis of web sites by driving a web browser. [Link to example here] - -### CLI Automation - -Here is a GPTScript that automates Kubernetes operations by driving the `kubectl` command line. [Link to example here] - ## Audio, Image, and Vision [More details to come] ## Memory Management +LLMs are stateless. That's why GPTScript by default caches LLM invocations. LLM apps need to keep memory outside of the model. + GPTScript provides a means to manage memory that persists across multiple LLM invocations. The relevant information can be extracted and passed into the LLM as part of the context. In addition, LLM can utilize tools to obtain additional data from the memory maintained in GPTScript. [More details to follow.] From fdb33eb1847d036e94c8432a756727b4420a5579 Mon Sep 17 00:00:00 2001 From: Sheng Liang Date: Wed, 28 Feb 2024 17:25:23 -0800 Subject: [PATCH 4/4] Add more examples --- docs/README-USECASES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README-USECASES.md b/docs/README-USECASES.md index 9a3c2b55..3d290eb3 100644 --- a/docs/README-USECASES.md +++ b/docs/README-USECASES.md @@ -52,7 +52,7 @@ Here is a GPTScript that automates Kubernetes operations by driving the `kubectl Agents and assistants are synonyms. They are software programs that leverage LLM to carry out tasks. -In GPTScript, agents and assistants are implemented using tools. Tools can use other tools. Tools can be implemented using natural language prompts or using traditional programming languages such as Python or JavaScript. You can therefore build arbitrarily complex agents and assistants in GPTScript. +In GPTScript, agents and assistants are implemented using tools. Tools can use other tools. Tools can be implemented using natural language prompts or using traditional programming languages such as Python or JavaScript. You can therefore build arbitrarily complex agents and assistants in GPTScript. Here is an example of an assistant that leverages an HTTP client, MongoDB, and Python code generation to display Hacker News headlines: [`hacker-news-headlines.gpt`](../examples/hacker-news-headlines.gpt) ## Data Analysis @@ -74,7 +74,7 @@ Here is a GPTScript that summarizes the content of a CSV file. [Link to example ### Understanding Code -Here is a GPTScript that summarizes the the code stored in a given directory. [Link to example here] +Here is a GPTScript that summarizes the the code stored under the current directory: [`describe-code.gpt`](../examples/describe-code.gpt) ## Audio, Image, and Vision