|
| 1 | +# Use Cases of GPTScript |
| 2 | + |
| 3 | +## Retrieval |
| 4 | + |
| 5 | +Retrieval-Augmented Generation (RAG) leverages a knowledge base outside of the training data before consulting the LLM to generate a response. |
| 6 | +The following GPTScript implements RAG: |
| 7 | + |
| 8 | +```yaml |
| 9 | +name: rag |
| 10 | +description: implements retrieval-augmented generation |
| 11 | +args: prompt: a string |
| 12 | +tools: query |
| 13 | + |
| 14 | +First query the ${prompt} in the knowledge base, then construsts an answer to ${prompt} based on the result of the query. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +name: query |
| 19 | +description: queries the prompt in the knowledge base |
| 20 | +args: prompt: a string |
| 21 | + |
| 22 | +... (implementation of knowledge base query follows) ... |
| 23 | +``` |
| 24 | + |
| 25 | +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. |
| 26 | + |
| 27 | +You construct the appropriate query tool based on the type of knowledge base you have. |
| 28 | + |
| 29 | +| Knowledge Base | Query Tool | |
| 30 | +|------|------| |
| 31 | +| A vector database storing common document types such as text, HTML, PDF, and Word | Integrate with LlamaIndex for vector database support [Link to example]| |
| 32 | +| 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)| |
| 33 | +| 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]| |
| 34 | +| An ElasticSearch/OpenSearch database storing logs or other text files | Implement query tools using database command line tools [Link to example]| |
| 35 | +| Other databases such as graph or time series databases | Implement query tools using database command line tools [Link to example]| |
| 36 | + |
| 37 | +## Task Automation |
| 38 | + |
| 39 | +### Planning |
| 40 | + |
| 41 | +Here is a GPTScript that produces a detailed travel itenirary based on inputs from a user: [`travel-agent.gpt`](../examples/travel-agent.gpt) |
| 42 | + |
| 43 | +### Web UI Automation |
| 44 | + |
| 45 | +Here is a GPTScript that automates data gathering and analysis of web sites by interacting with a chrome web browser. [Link to example here] |
| 46 | + |
| 47 | +### CLI Automation |
| 48 | + |
| 49 | +Here is a GPTScript that automates Kubernetes operations by driving the `kubectl` command line. [Link to example here] |
| 50 | + |
| 51 | +## Agents and Assistants |
| 52 | + |
| 53 | +Agents and assistants are synonyms. They are software programs that leverage LLM to carry out tasks. |
| 54 | + |
| 55 | +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) |
| 56 | + |
| 57 | +## Data Analysis |
| 58 | + |
| 59 | +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. |
| 60 | + |
| 61 | +### Summarization |
| 62 | + |
| 63 | +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] |
| 64 | + |
| 65 | +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] |
| 66 | + |
| 67 | +### Tagging |
| 68 | + |
| 69 | +Here is a GPTScript that performs sentiment analysis on the input text. [Link to example here] |
| 70 | + |
| 71 | +### CSV Files |
| 72 | + |
| 73 | +Here is a GPTScript that summarizes the content of a CSV file. [Link to example here] |
| 74 | + |
| 75 | +### Understanding Code |
| 76 | + |
| 77 | +Here is a GPTScript that summarizes the the code stored under the current directory: [`describe-code.gpt`](../examples/describe-code.gpt) |
| 78 | + |
| 79 | +## Audio, Image, and Vision |
| 80 | + |
| 81 | +[More details to come] |
| 82 | + |
| 83 | +## Memory Management |
| 84 | + |
| 85 | +LLMs are stateless. That's why GPTScript by default caches LLM invocations. LLM apps need to keep memory outside of the model. |
| 86 | + |
| 87 | +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. |
| 88 | + |
| 89 | +[More details to follow.] |
| 90 | + |
| 91 | +## Chatbots |
| 92 | + |
| 93 | +GPTScript in combination with Rubra UI provide you with a turn-key implementation of chatbots. [More details to follow] |
0 commit comments