meta /llama-2-13b-chat:6b4da803
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:6b4da803a2382c08868c5af10a523892f38e2de1aafb2ee55b020d9efef2fdb8",
{
input: {
debug: false,
top_p: 1,
prompt: "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.",
temperature: 0.75,
system_prompt: "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.",
max_new_tokens: 500,
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:6b4da803a2382c08868c5af10a523892f38e2de1aafb2ee55b020d9efef2fdb8",
input={
"debug": False,
"top_p": 1,
"prompt": "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.",
"temperature": 0.75,
"system_prompt": "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.",
"max_new_tokens": 500,
"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": "6b4da803a2382c08868c5af10a523892f38e2de1aafb2ee55b020d9efef2fdb8",
"input": {
"debug": false,
"top_p": 1,
"prompt": "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.",
"temperature": 0.75,
"system_prompt": "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\\n\\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don\'t know the answer to a question, please don\'t share false information.",
"max_new_tokens": 500,
"repetition_penalty": 1
}
}' \
https://api.replicate.com/v1/predictions
To learn more, take a look at Replicate’s HTTP API reference docs.
Output
Sure, I'd be happy to help! Based on the information you provided, here is a SQL query that will show you the total revenue by state of customer:
```
SELECT state, SUM(units_purchased * 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
```
Let me explain the query:
1. `SELECT state, SUM(units_purchased * unit_price) AS revenue`: We select two columns: `state` and `revenue`. The `state` column is the state of the customer, and the `revenue` column is the total revenue for that state.
2. `FROM customers`: We start by joining the `customers` table.
3. `JOIN orders ON customers.cust_id = orders.cust_id`: We join the `orders` table on the `cust_id` column.
4. `JOIN products ON orders.prod_id = products.prod_id`: We join the `products` table on the `prod_id` column.
5. `GROUP BY state`: We group the results by the `state` column.
The query will return a table with two columns: `state` and `revenue`. The `revenue` column will have the total revenue for each state.
Note that this query assumes that the state is stored in the `home_address_state` column of the `customers` table. If the state is stored in a different column, you'll need to adjust the query accordingly.
I hope this helps! Let me know if you have any questions or need further assistance.
{
"completed_at": "2023-07-22T00:47:47.112130Z",
"created_at": "2023-07-22T00:47:28.317378Z",
"data_removed": false,
"error": null,
"id": "3q5z6dbbp7kcfh2dhdzglwmkqu",
"input": {
"top_p": 1,
"prompt": "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.",
"temperature": 0.75,
"system_prompt": "You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\n\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.",
"max_new_tokens": 500,
"repetition_penalty": 1
},
"logs": "Formatted input prompt:\n[INST] <<SYS>>\nYou are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.\nIf a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.\n<</SYS>>\nMy database has the following tables:\n- customers, orders, and products\nThe customer table has the following columns:\n- cust_id, name, email, home_address_state, phone\nThe orders table has the following columns:\n- order_id, cust_id, prod_id, units_purchased, discount_percent\nThe products table has the following columns:\n- prod_id, product name, product_description, unit_price\nWrite me a sql query based on the above that will show me my total revenue by state of customer. [/INST]",
"metrics": {
"predict_time": 18.863329,
"total_time": 18.794752
},
"output": [
" Sure,",
" I'd",
" be",
" happy",
" to",
" help!",
" Based",
" on",
" the",
" information",
" you",
" provided,",
" here",
" is",
" a",
" SQL",
" query",
" that",
" will",
" show",
" you",
" the",
" total",
" revenue",
" by",
" state",
" of",
" customer:\n```\nSELECT",
" state,",
" SUM(units_purchased",
" *",
" 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```\n\nLet",
" me",
" explain",
" the",
" query:\n\n1.",
" `SELECT",
" state,",
" SUM(units_purchased",
" *",
" unit_price)",
" AS",
" revenue`:",
" We",
" select",
" two",
" columns:",
" `state`",
" and",
" `revenue`.",
" The",
" `state`",
" column",
" is",
" the",
" state",
" of",
" the",
" customer,",
" and",
" the",
" `revenue`",
" column",
" is",
" the",
" total",
" revenue",
" for",
" that",
" state.\n2.",
" `FROM",
" customers`:",
" We",
" start",
" by",
" joining",
" the",
" `customers`",
" table.\n3.",
" `JOIN",
" orders",
" ON",
" customers.cust_id",
" =",
" orders.cust_id`:",
" We",
" join",
" the",
" `orders`",
" table",
" on",
" the",
" `cust_id`",
" column.\n4.",
" `JOIN",
" products",
" ON",
" orders.prod_id",
" =",
" products.prod_id`:",
" We",
" join",
" the",
" `products`",
" table",
" on",
" the",
" `prod_id`",
" column.\n5.",
" `GROUP",
" BY",
" state`:",
" We",
" group",
" the",
" results",
" by",
" the",
" `state`",
" column.\n\nThe",
" query",
" will",
" return",
" a",
" table",
" with",
" two",
" columns:",
" `state`",
" and",
" `revenue`.",
" The",
" `revenue`",
" column",
" will",
" have",
" the",
" total",
" revenue",
" for",
" each",
" state.\n\nNote",
" that",
" this",
" query",
" assumes",
" that",
" the",
" state",
" is",
" stored",
" in",
" the",
" `home_address_state`",
" column",
" of",
" the",
" `customers`",
" table.",
" If",
" the",
" state",
" is",
" stored",
" in",
" a",
" different",
" column,",
" you'll",
" need",
" to",
" adjust",
" the",
" query",
" accordingly.\n\nI",
" hope",
" this",
" helps!",
" Let",
" me",
" know",
" if",
" you",
" have",
" any",
" questions",
" or",
" need",
" further",
" assistance."
],
"started_at": "2023-07-22T00:47:28.248801Z",
"status": "succeeded",
"urls": {
"get": "https://api.replicate.com/v1/predictions/3q5z6dbbp7kcfh2dhdzglwmkqu",
"cancel": "https://api.replicate.com/v1/predictions/3q5z6dbbp7kcfh2dhdzglwmkqu/cancel"
},
"version": "6b4da803a2382c08868c5af10a523892f38e2de1aafb2ee55b020d9efef2fdb8"
}
Generated in
Formatted input prompt:
[INST] <<SYS>>
You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature.
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.
<</SYS>>
My database has the following tables:
- customers, orders, and products
The customer table has the following columns:
- cust_id, name, email, home_address_state, phone
The orders table has the following columns:
- order_id, cust_id, prod_id, units_purchased, discount_percent
The products table has the following columns:
- prod_id, product name, product_description, unit_price
Write me a sql query based on the above that will show me my total revenue by state of customer. [/INST]