githubEdit

Action Table - Document

1. Introduction

This tutorial will guide you through using the JamAI Base TypeScript SDK to create a simple news summarization system.

What We'll Build

Get a news document and let AI tell you the main message!

In this tutorial, we'll create a news summarization system that:

  • Takes a news document as input. The supported formats include: .csv, .tsv, .txt, .md, .doc, .docx, .pdf, .ppt, .pptx, .xls, .xlsx, .xml, .html, .json, .jsonl.

  • Upload the document to JamAI Base action table.

  • Obtain the key information like:

    • Summary

    • Tag

Prerequisites

Before starting, you'll need:

  • Node.js 16.x or higher installed

  • Project ID and Personal Access Token (PAT)

2. Installation and Setup

Installing the TypeScript SDK

Basic Configuration

Get your Personal Access Token (PAT) here:

Get your Project ID here:

circle-info

You can use a .env file to manage your PROJECT_ID and PAT.

3. Creating Your Action Table

For simplicity, you can set up your action table in the JamAI Base platform:

1

Create the action table

  • Navigate to your JamAI Base action table tab.

  • Create a new action table named "news_summarization".

2

Add columns

Create the following columns:

Name
Column Type
Data Type

document

Input

Document

summary

LLM Output

Text

tag

LLM Output

Text

3

Update prompts for LLM Output columns

Update the Prompt for the LLM Output columns as follows:

Column name
Prompt

summary

Table name: "news_summarization"\n\ndocument: ${document}\n\nSummarize the article in not more than three sentences and not more than 50 words.\n\nProvide the summary in the number form.\n\nBe factual and do not hallucinate. Remember to act as a cell in a spreadsheet and provide concise, relevant information without explanations unless specifically requested.

tag

Table name: "news_summarization"\n\ndocument: ${document}\n\nProvide at most three tags that well represent the document. Each tag should not have more than three words.\n\nProvide the tag in the number form.\n\nBe factual and do not hallucinate. Remember to act as a cell in a spreadsheet and provide concise, relevant information without explanations unless specifically requested.

4. Basic Implementation

4.1 Simple Document Processor

4.2 Complete Implementation with Error Handling

5. Usage Examples

5.1 Basic Usage

5.2 Batch Processing

6. Best Practices

  • Error Handling

    • Always validate input files

    • Handle network errors gracefully

  • Performance

    • Reuse the client instance

    • Consider batch processing for multiple files

    • Implement rate limiting for large batches

  • Security

    • Use environment variables for credentials

Complete Standalone Example

Running the Example

  1. Save the code as document_processor.ts

  2. Create a .env file:

  3. Run with:

Or compile and run:

Was this helpful?