typetext
{
"ddl_doc": "CREATE TABLE products (\n product_id INT,\n product_name VARCHAR(100),\n category VARCHAR(50),\n price DECIMAL(10, 2),\n stock_quantity INT\n);\n\nINSERT INTO products (product_id, product_name, category, price, stock_quantity)\nVALUES\n (1, 'Smartphone', 'Electronics', 599.99, 100),\n (2, 'Laptop', 'Electronics', 999.99, 50),\n (3, 'Headphones', 'Electronics', 99.99, 200),\n (4, 'T-shirt', 'Apparel', 19.99, 300),\n (5, 'Jeans', 'Apparel', 49.99, 150);",
"question": "find the price of laptop"
}npm install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_Lxj**********************************
This is your API token. Keep it to yourself.
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run muqtadar08/finetuned_gemma_sql_generator using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"muqtadar08/finetuned_gemma_sql_generator:3b5f9fda888ca684c347536ba9fc01a7cfc60a83ae30f39c220dd072289df0ec",
{
input: {
ddl_doc: "CREATE TABLE products (\n product_id INT,\n product_name VARCHAR(100),\n category VARCHAR(50),\n price DECIMAL(10, 2),\n stock_quantity INT\n);\n\nINSERT INTO products (product_id, product_name, category, price, stock_quantity)\nVALUES\n (1, 'Smartphone', 'Electronics', 599.99, 100),\n (2, 'Laptop', 'Electronics', 999.99, 50),\n (3, 'Headphones', 'Electronics', 99.99, 200),\n (4, 'T-shirt', 'Apparel', 19.99, 300),\n (5, 'Jeans', 'Apparel', 49.99, 150);",
question: "find the price of laptop"
}
}
);
console.log(output);
To learn more, take a look at the guide on getting started with Node.js.
pip install replicate
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_Lxj**********************************
This is your API token. Keep it to yourself.
import replicate
Run muqtadar08/finetuned_gemma_sql_generator using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"muqtadar08/finetuned_gemma_sql_generator:3b5f9fda888ca684c347536ba9fc01a7cfc60a83ae30f39c220dd072289df0ec",
input={
"ddl_doc": "CREATE TABLE products (\n product_id INT,\n product_name VARCHAR(100),\n category VARCHAR(50),\n price DECIMAL(10, 2),\n stock_quantity INT\n);\n\nINSERT INTO products (product_id, product_name, category, price, stock_quantity)\nVALUES\n (1, 'Smartphone', 'Electronics', 599.99, 100),\n (2, 'Laptop', 'Electronics', 999.99, 50),\n (3, 'Headphones', 'Electronics', 99.99, 200),\n (4, 'T-shirt', 'Apparel', 19.99, 300),\n (5, 'Jeans', 'Apparel', 49.99, 150);",
"question": "find the price of laptop"
}
)
print(output)
To learn more, take a look at the guide on getting started with Python.
REPLICATE_API_TOKEN environment variable:export REPLICATE_API_TOKEN=r8_Lxj**********************************
This is your API token. Keep it to yourself.
Run muqtadar08/finetuned_gemma_sql_generator using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
curl -s -X POST \
-H "Authorization: Bearer $REPLICATE_API_TOKEN" \
-H "Content-Type: application/json" \
-H "Prefer: wait" \
-d $'{
"version": "muqtadar08/finetuned_gemma_sql_generator:3b5f9fda888ca684c347536ba9fc01a7cfc60a83ae30f39c220dd072289df0ec",
"input": {
"ddl_doc": "CREATE TABLE products (\\n product_id INT,\\n product_name VARCHAR(100),\\n category VARCHAR(50),\\n price DECIMAL(10, 2),\\n stock_quantity INT\\n);\\n\\nINSERT INTO products (product_id, product_name, category, price, stock_quantity)\\nVALUES\\n (1, \'Smartphone\', \'Electronics\', 599.99, 100),\\n (2, \'Laptop\', \'Electronics\', 999.99, 50),\\n (3, \'Headphones\', \'Electronics\', 99.99, 200),\\n (4, \'T-shirt\', \'Apparel\', 19.99, 300),\\n (5, \'Jeans\', \'Apparel\', 49.99, 150);",
"question": "find the price of laptop"
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
SELECT price FROM products WHERE category = 'Electronics' AND product_name = 'Laptop';
{
"id": "4a9jahe17srg80cf08ybwmjggg",
"model": "muqtadar08/finetuned_gemma_sql_generator",
"version": "3b5f9fda888ca684c347536ba9fc01a7cfc60a83ae30f39c220dd072289df0ec",
"input": {
"ddl_doc": "CREATE TABLE products (\n product_id INT,\n product_name VARCHAR(100),\n category VARCHAR(50),\n price DECIMAL(10, 2),\n stock_quantity INT\n);\n\nINSERT INTO products (product_id, product_name, category, price, stock_quantity)\nVALUES\n (1, 'Smartphone', 'Electronics', 599.99, 100),\n (2, 'Laptop', 'Electronics', 999.99, 50),\n (3, 'Headphones', 'Electronics', 99.99, 200),\n (4, 'T-shirt', 'Apparel', 19.99, 300),\n (5, 'Jeans', 'Apparel', 49.99, 150);",
"question": "find the price of laptop"
},
"logs": "A decoder-only architecture is being used, but right-padding was detected! For correct generation results, please set `padding_side='left'` when initializing the tokenizer.",
"output": "SELECT price FROM products WHERE category = 'Electronics' AND product_name = 'Laptop';",
"data_removed": false,
"error": null,
"source": "web",
"status": "succeeded",
"created_at": "2024-04-21T19:58:07.166Z",
"started_at": "2024-04-21T19:58:07.181831Z",
"completed_at": "2024-04-21T19:58:58.193124Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/4a9jahe17srg80cf08ybwmjggg/cancel",
"get": "https://api.replicate.com/v1/predictions/4a9jahe17srg80cf08ybwmjggg",
"web": "https://replicate.com/p/4a9jahe17srg80cf08ybwmjggg"
},
"metrics": {
"predict_time": 51.011293,
"total_time": 51.027124
}
}