|
| 1 | +# Use Cases |
| 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`](https://github.com/gptscript-ai/gptscript/tree/main/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 itinerary based on inputs from a user: [`travel-agent.gpt`](https://github.com/gptscript-ai/gptscript/tree/main/examples/travel-agent.gpt) |
| 42 | + |
| 43 | +### Web UI Automation |
| 44 | + |
| 45 | +Here is a GPTScript that automates a web browser to browse and navigate website, extract information: [coachella-browse.gpt](https://github.com/gptscript-ai/browser/tree/main/examples/coachella-browse.gpt) |
| 46 | + |
| 47 | +For additional examples, please explore [here](https://github.com/gptscript-ai/browser?tab=readme-ov-file#examples). |
| 48 | + |
| 49 | +### API Automation |
| 50 | + |
| 51 | +Here are a few GPTScripts that interact with issues on GitHub: |
| 52 | + |
| 53 | +- [Create GitHub Issues](https://github.com/gptscript-ai/create-github-issues/tree/main/examples/example.gpt) |
| 54 | +- [Modify GitHub Issues](https://github.com/gptscript-ai/modify-github-issues/tree/main/examples/example.gpt) |
| 55 | +- [Query GitHub Issues](https://github.com/gptscript-ai/gptscriptquery-github-issues/tree/main/examples/example.gpt) |
| 56 | + |
| 57 | +## Agents and Assistants |
| 58 | + |
| 59 | +Agents and assistants are synonyms. They are software programs that leverage LLM to carry out tasks. |
| 60 | + |
| 61 | +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`](https://github.com/gptscript-ai/gptscript/tree/main/examples/hacker-news-headlines.gpt) |
| 62 | + |
| 63 | +## Data Analysis |
| 64 | + |
| 65 | +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. |
| 66 | + |
| 67 | +### Summarization |
| 68 | + |
| 69 | +Here is a GPTScript that sends a large document in batches to the LLM and produces a summary of the entire document. [hamlet-summarizer](https://github.com/gptscript-ai/gptscript/tree/main/examples/hamlet-summarizer) |
| 70 | + |
| 71 | +### Tagging |
| 72 | + |
| 73 | +Here is a GPTScript that performs sentiment analysis on the input text: [Social Media Post Sentiment Analyzer](https://github.com/gptscript-ai/gptscript/tree/main/examples/sentiments) |
| 74 | + |
| 75 | +### CSV Files |
| 76 | + |
| 77 | +Here is a GPTScript that reads the content of a CSV file and make query using natural language: [csv-reader.gpt](https://github.com/gptscript-ai/csv-reader/tree/main/examples/csv-reader.gpt) |
| 78 | + |
| 79 | +### Understanding Code |
| 80 | + |
| 81 | +Here is a GPTScript that summarizes the code stored under the current directory: [`describe-code.gpt`](https://github.com/gptscript-ai/gptscript/tree/main/examples/describe-code.gpt) |
| 82 | + |
| 83 | +## Vision, Image, and Audio |
| 84 | + |
| 85 | +### Vision |
| 86 | + |
| 87 | +Here is an example of a web app that leverages GPTScript to recognize ingredients in a photo and suggest a recipe based on them: [recipe-generator](https://github.com/gptscript-ai/gptscript/tree/main/examples/recipegenerator). |
| 88 | + |
| 89 | +### Image Generation |
| 90 | + |
| 91 | +Here is a GPTScript that takes a story prompt and generates an illustrated children's book: [story-book.gpt](https://github.com/gptscript-ai/gptscript/tree/main/examples/story-book) |
0 commit comments