Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Michalsky committed Mar 25, 2024
1 parent 46b5466 commit 0b74c16
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 43 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
OPENAI_API_KEY="xx"
OTHER_API_KEY="yy"
MINDWARE_URL="xx"
MINDWARE_API_KEY="zz"
PAYMENT_GATEWAY_URL=https://agent-payments-gateway.vercel.app/payment
CONFIG_PATH=examples/example_agent_setup.json
PRODUCT_CATALOG=examples/sample_product_catalog.txt
PRODUCT_PRICE_MAPPING=examples/example_product_price_id_mapping.json
GPT_MODEL=gpt-3.5-turbo-0613
USE_TOOLS_IN_API=True
USE_TOOLS_IN_API=True

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ We are building SalesGPT to power your best AI Sales Agents. Hence, we would lov

# Demos and Use Cases

<i>Unload AI Sales Agent Demo - Powered by SalesGPT:</i> *A New Way to Sell?* 🤔
<i>Unload AI Sales Agent Demos - Powered by SalesGPT:</i> *Our new virtual workforce?* 🤔

**Demo #1: Rachel - Mattress Sales Field Representative Outbound Sales**
**Demo #1: Sarah - Patient Coordinator at South Orange Pediatrics**

[![Rachel - Mattress Sales Field Representative](https://cdn.loom.com/sessions/thumbnails/f0fac42954904471b266980e4948b07d-with-play.gif)](https://www.loom.com/share/f0fac42954904471b266980e4948b07d)
- 100X Your Healthcare Admin with our Virtual Workforce

[![Sarah - South Orange Pediatrics Patient Coordinator](https://cdn.loom.com/sessions/thumbnails/314eb0562fda41ea94e25b267acda6f9-with-play.gif)](https://www.loom.com/share/314eb0562fda41ea94e25b267acda6f9)

**Demo #2: Ted - Autonomously create payment links and collect customer payments**

Expand Down
7 changes: 7 additions & 0 deletions examples/example_product_price_id_mapping.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ai-consulting-services": "price_1Ow8ofB795AYY8p1goWGZi6m",
"Luxury Cloud-Comfort Memory Foam Mattress": "price_1Owv99B795AYY8p1mjtbKyxP",
"Classic Harmony Spring Mattress": "price_1Owv9qB795AYY8p1tPcxCM6T",
"EcoGreen Hybrid Latex Mattress": "price_1OwvLDB795AYY8p1YBAMBcbi",
"Plush Serenity Bamboo Mattress": "price_1OwvMQB795AYY8p1hJN2uS3S"
}
104 changes: 67 additions & 37 deletions examples/sales_agent_with_context.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,38 +67,6 @@
"from typing import Union\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Optional - create a free [Mindware](https://www.mindware.co/) account\n",
"\n",
"This enables your AI sales agents to actually sell."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"I want to sell\n"
]
}
],
"source": [
"I_WANT_TO_SELL=True\n",
"if I_WANT_TO_SELL:\n",
" if \"MINDWARE_API_KEY\" not in os.environ:\n",
" raise ValueError(\"You cannot sell as you did not set up a Mindware account\")\n",
" print(\"I want to sell\")\n",
"\n",
"MINDWARE_URL = os.getenv(\"MINDWARE_URL\", \"https://agent-payments-gateway.vercel.app/payment\")"
]
},
{
"attachments": {},
"cell_type": "markdown",
Expand Down Expand Up @@ -471,6 +439,63 @@
"product_catalog='sample_product_catalog.txt'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from litellm import completion\n",
"import json\n",
"\n",
"def get_product_id_from_query(query, product_price_id_mapping_path):\n",
" # Load product_price_id_mapping from a JSON file\n",
" with open(product_price_id_mapping_path, 'r') as f:\n",
" product_price_id_mapping = json.load(f)\n",
" \n",
" # Serialize the product_price_id_mapping to a JSON string for inclusion in the prompt\n",
" product_price_id_mapping_json_str = json.dumps(product_price_id_mapping)\n",
" \n",
" # Dynamically create the enum list from product_price_id_mapping keys\n",
" enum_list = list(product_price_id_mapping.values()) + [\"No relevant product id found\"]\n",
" enum_list_str = json.dumps(enum_list)\n",
" \n",
" prompt = f\"\"\"\n",
" You are an expert data scientist and you are working on a project to recommend products to customers based on their needs.\n",
" Given the following query:\n",
" {query}\n",
" and the following product price id mapping:\n",
" {product_price_id_mapping_json_str}\n",
" return the product id that is most relevant to the query.\n",
" ONLY return the product id, no other text. If no relevant product id is found, return 'No relevant product id found'.\n",
" FORMAT OUTPUT AS the following schema:\n",
" {{\n",
" \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n",
" \"title\": \"Product ID Response\",\n",
" \"type\": \"object\",\n",
" \"properties\": {{\n",
" \"product_id\": {{\n",
" \"type\": \"string\",\n",
" \"enum\": {enum_list_str}\n",
" }}\n",
" }},\n",
" \"required\": [\"product_id\"]\n",
" }}\n",
" \"\"\"\n",
" \n",
" response = completion(\n",
" model=os.getenv(\"GPT_MODEL\", \"gpt-3.5-turbo-1106\"),\n",
" messages=[{\"content\": prompt, \"role\": \"user\"}],\n",
" max_tokens=1000,\n",
" temperature=0\n",
" )\n",
"\n",
" product_id = response.choices[0].message.content.strip()\n",
" return product_id\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
Expand All @@ -483,16 +508,21 @@
"def generate_stripe_payment_link(query: str) -> str:\n",
" \"\"\"Generate a stripe payment link for a customer based on a single query string.\"\"\"\n",
"\n",
" url = os.getenv(\"MINDWARE_URL\", \"\")\n",
" api_key = os.getenv(\"MINDWARE_API_KEY\", \"\")\n",
" # example testing payment gateway url\n",
" PAYMENT_GATEWAY_URL = os.getenv(\"PAYMENT_GATEWAY_URL\", \"https://agent-payments-gateway.vercel.app/payment\")\n",
" PRODUCT_PRICE_MAPPING = os.getenv(\"PRODUCT_PRICE_MAPPING\", \"example_product_price_id_mapping.json\")\n",
" \n",
" # use LLM to get the price_id from query\n",
" price_id = get_product_id_from_query(query, PRODUCT_PRICE_MAPPING)\n",
"\n",
" payload = json.dumps({\"prompt\": query})\n",
" payload = json.dumps({\"prompt\": query,\n",
" \"price_id\": price_id\n",
" })\n",
" headers = {\n",
" 'Content-Type': 'application/json',\n",
" 'Authorization': f'Bearer {api_key}'\n",
" }\n",
"\n",
" response = requests.request(\"POST\", url, headers=headers, data=payload)\n",
" response = requests.request(\"POST\", PAYMENT_GATEWAY_URL, headers=headers, data=payload)\n",
" return response.text"
]
},
Expand Down

0 comments on commit 0b74c16

Please sign in to comment.