You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* SimpleTable is a class representing a table in a SimpleDB. It can handle tabular and geospatial data. To create one, it's best to instantiate a SimpleDB first.
* @param options - Configuration options for the AI request.
564
563
* @param options.batchSize - The number of rows to process in each batch. By default, it is 1.
565
564
* @param options.cache - If true, the results will be cached locally. By default, it is false.
566
-
* @param options.cacheVerbose - If true, more information about the cache will be logged. By default, it is false.
567
565
* @param options.rateLimitPerMinute - The rate limit for the AI requests in requests per minute. If necessary, the method will wait between requests. By default, there is no limit.
568
566
* @param options.model - The model to use. Defaults to the `AI_MODEL` environment variable.
569
567
* @param options.apiKey - The API key. Defaults to the `AI_KEY` environment variable.
570
568
* @param options.vertex - Whether to use Vertex AI. Defaults to `false`. If `AI_PROJECT` and `AI_LOCATION` are set in the environment, it will automatically switch to true.
571
569
* @param options.project - The Google Cloud project ID. Defaults to the `AI_PROJECT` environment variable.
572
570
* @param options.location - The Google Cloud location. Defaults to the `AI_LOCATION` environment variable.
573
571
* @param options.verbose - Whether to log additional information. Defaults to `false`.
574
-
* @param options.costEstimate - Whether to estimate the cost of the request. Defaults to `false`.
* // Don't forget to add .journalism to your .gitignore file!
692
608
* await table.aiQuery(
693
609
* "Give me the average salary by department",
694
-
* { cache: true }
610
+
* { cache: true, verbose: true }
695
611
* )
696
612
* ```
697
613
*
698
614
* @param prompt - The input string to guide the AI in generating the SQL query.
699
615
* @param options - Configuration options for the AI request.
700
616
* @param options.cache - If true, the query will be cached locally. By default, it is false.
701
-
* @param options.cacheVerbose - If true, more information about the cache will be logged. By default, it is false.
702
617
* @param options.model - The model to use. Defaults to the `AI_MODEL` environment variable.
703
618
* @param options.apiKey - The API key. Defaults to the `AI_KEY` environment variable.
704
619
* @param options.vertex - Whether to use Vertex AI. Defaults to `false`. If `AI_PROJECT` and `AI_LOCATION` are set in the environment, it will automatically switch to true.
705
620
* @param options.project - The Google Cloud project ID. Defaults to the `AI_PROJECT` environment variable.
706
621
* @param options.location - The Google Cloud location. Defaults to the `AI_LOCATION` environment variable.
707
622
* @param options.verbose - Whether to log additional information. Defaults to `false`.
708
-
* @param options.costEstimate - Whether to estimate the cost of the request. Defaults to `false`.
709
623
*/
710
624
asyncaiQuery(prompt: string,options: {
711
625
cache?: boolean;
712
-
cacheVerbose?: boolean;
713
626
model?: string;
714
627
apiKey?: string;
715
628
vertex?: boolean;
716
629
project?: string;
717
630
location?: string;
718
631
verbose?: boolean;
719
-
costEstimate?: boolean;
720
632
}={}){
721
-
constp=
722
-
`I have a SQL table named "${this.name}". The data is already in it with these columns:\n${
723
-
JSON.stringify(awaitthis.getTypes(),undefined,2)
724
-
}\nI want you to give me a SQL query to do this:\n- ${prompt}\nThe query must replace the existing "${this.name}" table with 'CREATE OR REPLACE TABLE "${this.name}"'. Return just the query, nothing else.`;
}\nI want you to give me a SQL query to do this:\n- ${prompt}\nThe query must replace the existing "${simpleTable.name}" table with 'CREATE OR REPLACE TABLE "${simpleTable.name}"'. Return just the query, nothing else.`;
0 commit comments