meta /llama-2-13b-chat:df7690f1
Input
Run this model in Node.js with one line of code:
npx create-replicate --model=meta/llama-2-13b-chat
or set up a project from scratch
Install Replicate’s Node.js client library:
npm install replicate
Set the
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Import and set up the client:
import Replicate from "replicate";
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN,
});
Run meta/llama-2-13b-chat using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
const output = await replicate.run(
"meta/llama-2-13b-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5",
{
input: {
debug: false,
top_p: 1,
prompt: "User: My database has the following tables:\n- customers, orders, and products\n\nThe customer table has the following columns:\n- cust_id, name, email, home_address_state, phone\n\nThe orders table has the following columns:\n- order_id, cust_id, prod_id, units_purchased, discount_percent\n\nThe products table has the following columns:\n- prod_id, product name, product_description, unit_price\n\nWrite me a sql query based on the above that will show me my total revenue by state of customer.\nAssistant:",
max_length: 500,
temperature: 0.75,
repetition_penalty: 1
}
}
);
console.log(output);
To learn more, take a look at the guide on getting started with Node.js.
Install Replicate’s Python client library:
pip install replicate
Set the
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Import the client:
import replicate
Run meta/llama-2-13b-chat using Replicate’s API. Check out the model's schema for an overview of inputs and outputs.
output = replicate.run(
"meta/llama-2-13b-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5",
input={
"debug": False,
"top_p": 1,
"prompt": "User: My database has the following tables:\n- customers, orders, and products\n\nThe customer table has the following columns:\n- cust_id, name, email, home_address_state, phone\n\nThe orders table has the following columns:\n- order_id, cust_id, prod_id, units_purchased, discount_percent\n\nThe products table has the following columns:\n- prod_id, product name, product_description, unit_price\n\nWrite me a sql query based on the above that will show me my total revenue by state of customer.\nAssistant:",
"max_length": 500,
"temperature": 0.75,
"repetition_penalty": 1
}
)
# The meta/llama-2-13b-chat model can stream output as it's running.
# The predict method returns an iterator, and you can iterate over that output.
for item in output:
# https://replicate.com/meta/llama-2-13b-chat/api#output-schema
print(item, end="")
To learn more, take a look at the guide on getting started with Python.
Set the
REPLICATE_API_TOKEN
environment variable:export REPLICATE_API_TOKEN=<paste-your-token-here>
Find your API token in your account settings.
Run meta/llama-2-13b-chat 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": "df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5",
"input": {
"debug": false,
"top_p": 1,
"prompt": "User: My database has the following tables:\\n- customers, orders, and products\\n\\nThe customer table has the following columns:\\n- cust_id, name, email, home_address_state, phone\\n\\nThe orders table has the following columns:\\n- order_id, cust_id, prod_id, units_purchased, discount_percent\\n\\nThe products table has the following columns:\\n- prod_id, product name, product_description, unit_price\\n\\nWrite me a sql query based on the above that will show me my total revenue by state of customer.\\nAssistant:",
"max_length": 500,
"temperature": 0.75,
"repetition_penalty": 1
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Output
Sure! Here is a sample SQL query that should give you the total revenue by state of customer based on the tables you provided:
SELECT state, SUM(orders.units_purchased * products.unit_price) AS revenue
FROM customers
JOIN orders ON customers.cust_id = orders.cust_id
JOIN products ON orders.prod_id = products.prod_id
GROUP BY state
This query joins the customers, orders, and products tables on the common column of cust_id, and then groups the results by state to give you the total revenue by state.
{
"completed_at": "2023-07-18T15:12:45.347613Z",
"created_at": "2023-07-18T15:12:37.264097Z",
"data_removed": false,
"error": null,
"id": "4p5yfkbbzfqo2gp642chqdxxdi",
"input": {
"top_p": 1,
"prompt": "User: My database has the following tables:\n- customers, orders, and products\n\nThe customer table has the following columns:\n- cust_id, name, email, home_address_state, phone\n\nThe orders table has the following columns:\n- order_id, cust_id, prod_id, units_purchased, discount_percent\n\nThe products table has the following columns:\n- prod_id, product name, product_description, unit_price\n\nWrite me a sql query based on the above that will show me my total revenue by state of customer.\nAssistant:",
"max_length": 500,
"temperature": 0.75,
"repetition_penalty": 1
},
"logs": null,
"metrics": {
"predict_time": 8.114586,
"total_time": 8.083516
},
"output": [
"Sure!",
" Here",
" is",
" a",
" sample",
" SQL",
" query",
" that",
" should",
" give",
" you",
" the",
" total",
" revenue",
" by",
" state",
" of",
" customer",
" based",
" on",
" the",
" tables",
" you",
" provided:\n\nSELECT",
" state,",
" SUM(orders.units_purchased",
" *",
" products.unit_price)",
" AS",
" revenue\nFROM",
" customers\nJOIN",
" orders",
" ON",
" customers.cust_id",
" =",
" orders.cust_id\nJOIN",
" products",
" ON",
" orders.prod_id",
" =",
" products.prod_id\nGROUP",
" BY",
" state\n\nThis",
" query",
" joins",
" the",
" customers,",
" orders,",
" and",
" products",
" tables",
" on",
" the",
" common",
" column",
" of",
" cust_id,",
" and",
" then",
" groups",
" the",
" results",
" by",
" state",
" to",
" give",
" you",
" the",
" total",
" revenue",
" by",
" state."
],
"started_at": "2023-07-18T15:12:37.233027Z",
"status": "succeeded",
"urls": {
"get": "https://api.replicate.com/v1/predictions/4p5yfkbbzfqo2gp642chqdxxdi",
"cancel": "https://api.replicate.com/v1/predictions/4p5yfkbbzfqo2gp642chqdxxdi/cancel"
},
"version": "df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5"
}
Generated in