Skip to content

Commit

Permalink
Merge pull request #158 from filip-michalsky/documentation
Browse files Browse the repository at this point in the history
Documentation updates - great job @chemik-bit !
  • Loading branch information
filip-michalsky authored Jul 12, 2024
2 parents f8f8875 + d8ecc73 commit 503794d
Show file tree
Hide file tree
Showing 19 changed files with 272 additions and 83 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AWS_ACCESS_KEY_ID=xx
AWS_SECRET_ACCESS_KEY=xx
AWS_REGION_NAME=xx
GPT_MODEL=gpt-3.5-turbo-0613
HUGGGINGFACE_API_KEY=xx

#Agent setup
USE_TOOLS_IN_API=True
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ venv/
ENV/
env.bak/
venv.bak/
website/docs/.env

# Spyder project settings
.spyderproject
Expand Down
39 changes: 39 additions & 0 deletions examples/mcdonalds_menu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
McDonald's Product 1: Big Mac
Description: The Big Mac is a classic burger featuring two 100% beef patties, special sauce, lettuce, cheese, pickles, and onions on a sesame seed bun.
Price: $3.99

McDonald's Product 2: Quarter Pounder with Cheese
Description: The Quarter Pounder with Cheese includes a quarter-pound 100% beef patty, two slices of cheese, onions, pickles, mustard, and ketchup on a sesame seed bun.
Price: $4.29

McDonald's Product 3: McChicken
Description: The McChicken is a crispy chicken sandwich with shredded lettuce and mayonnaise on a toasted bun.
Price: $1.29

McDonald's Product 4: Filet-O-Fish
Description: The Filet-O-Fish features a fish filet patty, tartar sauce, and a slice of cheese on a steamed bun.
Price: $3.79

McDonald's Product 5: Chicken McNuggets
Description: Chicken McNuggets are bite-sized pieces of tender, juicy chicken, coated in a crispy breading. Available in 6, 10, 20, and 40 pieces.
Price: $2.99 (6 pieces), $4.49 (10 pieces), $8.99 (20 pieces), $15.99 (40 pieces)

McDonald's Product 6: French Fries
Description: McDonald's French Fries are world-famous for their crispy exterior and fluffy interior, made from premium potatoes.
Price: $1.39 (Small), $1.79 (Medium), $2.19 (Large)

McDonald's Product 7: Happy Meal
Description: The Happy Meal includes a choice of a hamburger, cheeseburger, or 4-piece Chicken McNuggets, along with kid-sized fries, apple slices, and a drink. Comes with a toy.
Price: $3.49

McDonald's Product 8: Egg McMuffin
Description: The Egg McMuffin is a breakfast sandwich with a freshly cracked egg, Canadian bacon, and American cheese on a toasted English muffin.
Price: $2.79

McDonald's Product 9: Sausage Burrito
Description: The Sausage Burrito is a warm flour tortilla filled with scrambled eggs, sausage, melted cheese, green chiles, and onions.
Price: $1.29

McDonald's Product 10: McFlurry
Description: The McFlurry is a creamy, soft-serve ice cream dessert mixed with your choice of Oreo or M&M's candies.
Price: $2.39
11 changes: 11 additions & 0 deletions examples/mcdonalds_worker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"salesperson_name": "Alex Johnson",
"salesperson_role": "Home Order Hotline Representative",
"company_name": "McDonald's",
"company_business": "McDonald's is a global fast-food restaurant chain that provides customers with a variety of delicious and affordable meals, including burgers, fries, and beverages. We are committed to delivering quick service and a great dining experience.",
"company_values": "At McDonald's, our mission is to make delicious feel-good moments easy for everyone. We believe in providing high-quality food, exceptional service, and a welcoming environment for our customers.",
"conversation_purpose": "assist customers with their home orders and ensure they are satisfied with their experience.",
"conversation_type": "call",
"use_custom_prompt": "True",
"custom_prompt": "Never forget your name is {salesperson_name}. You work as a {salesperson_role}.\nYou work at company named {company_name}. {company_name}'s business is the following: {company_business}.\nCompany values are the following. {company_values}\nYou are contacting a customer in order to {conversation_purpose}\nYour means of contacting the customer is {conversation_type}\n\nIf you're asked about where you got the user's contact information, say that you got it from their recent order with us.\nKeep your responses in short length to retain the user's attention. Never produce lists, just answers.\nStart the conversation by just a greeting and how is the customer doing without pitching in your first turn.\nWhen the conversation is over, output <END_OF_CALL>\nAlways think about at which conversation stage you are at before answering:\n\n1: Introduction: Start the conversation by introducing yourself and your company. Be polite and respectful while keeping the tone of the conversation professional. Your greeting should be welcoming. Always clarify in your greeting the reason why you are calling.\n2: Qualification: Qualify the customer by confirming if they are the right person to talk to regarding their recent order. Ensure that they have placed an order with us recently.\n3: Value proposition: Briefly explain how McDonald's values customer feedback and how it helps improve our service. Focus on the unique aspects of our service that set us apart from competitors.\n4: Needs analysis: Ask open-ended questions to uncover the customer's needs and feedback. Listen carefully to their responses and take notes.\n5: Solution presentation: Based on the customer's feedback, present how McDonald's can address their concerns or enhance their ordering experience.\n6: Objection handling: Address any objections that the customer may have regarding their order. Be prepared to provide solutions or compensations to support your claims.\n7: Close: Ask for any additional feedback or suggestions by proposing a next step. This could be a follow-up call or a visit to our restaurant. Ensure to summarize what has been discussed and reiterate the benefits.\n8: End conversation: The customer has to leave the call, the customer is not interested, or next steps were already determined by the home order hotline representative.\n\nExample 1:\nConversation history:\n{salesperson_name}: Hey, good morning! <END_OF_TURN>\nUser: Hello, who is this? <END_OF_TURN>\n{salesperson_name}: This is {salesperson_name} calling from {company_name}. How are you? \nUser: I am well, why are you calling? <END_OF_TURN>\n{salesperson_name}: I am calling to talk about your recent home order with McDonald's. <END_OF_TURN>\nUser: I am not interested, thanks. <END_OF_TURN>\n{salesperson_name}: Alright, no worries, have a good day! <END_OF_TURN> <END_OF_CALL>\nEnd of example 1.\n\nExample 2:\nConversation history:\n{salesperson_name}: Hey, good morning! <END_OF_TURN>\nUser: Hello, who is this? <END_OF_TURN>\n{salesperson_name}: This is {salesperson_name} calling from {company_name}. I am calling you to see if you were satisfied with your recent home order.\nUser: My experience was okay. <END_OF_TURN>\n{salesperson_name}: I am sorry to hear that. Can you tell me more about what could have been better? <END_OF_TURN>\nUser: The delivery was a bit slow. <END_OF_TURN>\n{salesperson_name}: I understand. At {company_name}, we strive to provide quick service. I will make sure to pass on your feedback to improve our delivery times. <END_OF_TURN>\nUser: Thank you, I appreciate that. <END_OF_TURN>\n...\nEnd of example 2.\n\nYou must respond according to the previous conversation history and the stage of the conversation you are at.\nOnly generate one response at a time and act as {salesperson_name} only! When you are done generating your turn, end with '<END_OF_TURN>' to give the user a chance to respond.\nNever forget to output <END_OF_TURN> after your turn.\nNever forget you have a clear goal of why you are contacting the customer and that is {conversation_purpose}.\n\nConversation history: \n{conversation_history}\n{salesperson_name}:"
}
20 changes: 20 additions & 0 deletions examples/sample_product_catalog_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Product 1: Himmel Soft Memory Foam Mattress
Dive into the luxury of the Himmel Soft Memory Foam Mattress, a masterpiece of comfort and design. This mattress features a temperature-sensitive memory foam that contours to your body, providing customized support and exceptional comfort. It is built on a durable high-density foam base that retains its shape and firmness over time. Enhanced with cooling gel particles, it helps maintain an optimal sleeping temperature all night. The soft, hypoallergenic cover, beautifully stitched with elegant patterns, not only decorates your space but also protects against allergens. Choose the Himmel Soft Memory Foam Mattress for a rejuvenating sleep experience.
Price: $950
Sizes available for this product: Twin, Queen, King

Product 2: Tradfri Pocket Spring Mattress
Experience the perfect combination of tradition and modernity with our Tradfri Pocket Spring Mattress. It boasts a sturdy pocket spring core surrounded by luxurious padding layers that provide a balanced support and plush comfort. The top layer is quilted and soft, enhancing the comfort with a touch of luxury. The reinforced edges offer increased durability and a uniform sleep surface. Its natural cotton cover efficiently absorbs moisture, ensuring a dry and pleasant sleep environment. The Tradfri Pocket Spring Mattress is ideal for those who value a harmonious blend of support and softness.
Price: $1,250
Sizes available for this product: Queen, King

Product 3: Grönblad Natural Latex Mattress
The Grönblad Natural Latex Mattress is our commitment to sustainable comfort. Crafted from 100% natural latex sourced from environmentally responsible plantations, this mattress delivers a dynamic, supportive sleep while offering excellent pressure relief. It features a base of individually encased coils that reduce motion transfer, making it ideal for couples. Covered in certified organic cotton, it provides a soft, breathable sleeping surface. With its natural antimicrobial and hypoallergenic qualities, the Grönblad is an excellent choice for those with allergies, combining eco-friendliness with luxurious comfort.
Price: $1,550
Sizes available for this product: Twin, Full

Product 4: Skogsliden Bamboo Mattress
Elevate your sleep with the Skogsliden Bamboo Mattress, where comfort meets sustainability. This mattress includes a layer of adaptive foam that conforms to your body, supported by a durable base foam that prevents sagging. The highlight is its bamboo-infused top layer, offering a soft, cool touch and excellent moisture management, thanks to bamboo's natural properties. The removable bamboo cover is silky and easy to care for, ensuring a clean and refreshing sleep environment. The Skogsliden Bamboo Mattress is a luxurious choice for those seeking eco-friendly sleep solutions.
Price: $2,500
Sizes available for this product: King
2 changes: 1 addition & 1 deletion salesgpt/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setup_knowledge_base(
with open(product_catalog, "r") as f:
product_catalog = f.read()

text_splitter = CharacterTextSplitter(chunk_size=10, chunk_overlap=0)
text_splitter = CharacterTextSplitter(chunk_size=5000, chunk_overlap=200)
texts = text_splitter.split_text(product_catalog)

llm = ChatOpenAI(model_name="gpt-4-0125-preview", temperature=0)
Expand Down
11 changes: 11 additions & 0 deletions website/docs/Tools/Different_business.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
sidebar_position: 5

---

# Different Business Use Cases

SalesGPT is a versatile AI agent that can be adapted to various industries by changing the setup file and updating the product catalog. By default, SalesGPT is configured using the `example_agent_setup.json` file located in the `examples` directory.

To illustrate, SalesGPT can be configured to act as a McDonald's hotline worker. This is achieved by updating the `.env` file with the appropriate configuration and product catalog:
![Correct Functioning](/img/mcdonalds.png)
33 changes: 33 additions & 0 deletions website/docs/Tools/Open_source_models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
sidebar_position: 5

---

# Using Open Source Models

SalesGPT allows you to use open-source models instead of paid models like OpenAI's GPT. To do this, follow these steps:

1. **Change the GPT_MODEL Environment Variable:**
Update the `GPT_MODEL` environment variable in your `.env` file to the desired open-source model. For example:
```
GPT_MODEL=your_open_source_model
```

2. **Update the `_streaming_generator` Function:**
If you are using an open-source model, you may need to add an `api_base` argument to the `_streaming_generator` function in the `agents.py` script. This argument should be set to the inference URL of the model. If the model is deployed locally, use a localhost URL; otherwise, use any other working URL depending on the deployment.

Here is an example of how to modify the `_streaming_generator` function:
```python
return self.sales_conversation_utterance_chain.llm.completion_with_retry(
messages=messages,
stop="<END_OF_TURN>",
stream=True,
model=self.model_name,
api_base="your_inference_url" # Add this line for open-source models
)
```

By following these steps, you can configure SalesGPT to use an open-source model for generating responses.

For more information on possible model deployments, you can visit: [LiteLLM Providers Documentation](https://litellm.vercel.app/docs/providers)

21 changes: 20 additions & 1 deletion website/docs/Tools/Product_catalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@ sidebar_position: 2

---

# Product search catalog
# Product catalog
To ensure that SalesGPT can effectively understand and utilize your product catalog, it is important to set up the correct chunk size in the text splitter within the `tools.py` file. Proper chunking helps in maintaining the context and coherence of the product information.

Here are two examples of incorrect setups and one example of a correct setup:

### Incorrect Setup 1
![Incorrect Setup 1](/img/bad_1.png)

### Incorrect Setup 2
![Incorrect Setup 2](/img/bad_2.png)

### Correct Setup
![Correct Setup](/img/correct.png)

You can implement your product catalog into SalesGPT by loading it.
To add a different product catalog, such as the `sample_product_catalog_2.txt` file, follow these steps:

1. **Update the product catalog file**: Replace the existing product catalog file with your new product catalog file. For example, you can use the `sample_product_catalog_2.txt` file.

2. **Update the `run_api` file**: Make sure to update the `product_catalog` variable in the `run_api` file to point to the new product catalog file. Alternatively, if you have set up the `PRODUCT_CATALOG` environment variable, update it to the path of your new product catalog file.

Here is an example of how to update the `setup_knowledge_base` function (product catalog function) in the `tools.py` file:
![Correct Product Catalog](/img/new_products.png)
9 changes: 0 additions & 9 deletions website/docs/Use_Cases/Basic_uses.md

This file was deleted.

23 changes: 23 additions & 0 deletions website/docs/Use_Cases/Mattress_salesman.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
sidebar_position: 1

---

# SalesGPT as a Mattress Salesman

SalesGPT can be configured to work as a mattress salesman by setting up a custom prompt and conversation flow. For example, you can set up SalesGPT to represent a salesperson from a premium mattress company like Sleep Haven. The custom prompt can include details about the salesperson's name, role, company, and the purpose of the conversation.

Here is an example setup:

- **Salesperson Name**: Ted Lasso
- **Salesperson Role**: Business Development Representative
- **Company Name**: Sleep Haven
- **Company Business**: Sleep Haven is a premium mattress company that provides customers with the most comfortable and supportive sleeping experience possible. We offer a range of high-quality mattresses, pillows, and bedding accessories that are designed to meet the unique needs of our customers.
- **Company Values**: Our mission at Sleep Haven is to help people achieve a better night's sleep by providing them with the best possible sleep solutions. We believe that quality sleep is essential to overall health and well-being, and we are committed to helping our customers achieve optimal sleep by offering exceptional products and customer service.
- **Conversation Purpose**: Find out whether they are looking to achieve better sleep via buying a premier mattress.
- **Conversation Type**: Call

The conversation flow can be structured into stages such as Introduction, Qualification, Value Proposition, Needs Analysis, Solution Presentation, Objection Handling, Close, and End Conversation. SalesGPT will follow this flow to engage with potential customers, understand their needs, and present the best mattress solutions.

![Correct Functioning](/img/correct.png)

6 changes: 3 additions & 3 deletions website/docs/Use_Cases/Use_case_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ sidebar_position: 2

---

# Tutorial for various use cases for SalesGPT
# McDonalds hotline worker

This use case will be particularly cool guys!!
SalesGPT is a versatile AI agent that can be used in a variety of scenarios. For example, it can function as a McDonald's hotline worker, handling customer inquiries and orders efficiently. Additionally, it can also work as a mattress salesman, understanding customer needs and providing tailored recommendations.

We are currently working on adding more use case examples. Stay tuned!
![Correct Functioning](/img/mcdonalds.png)

2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const config = {

items: [
{
to: '/Use_Cases/Basic_uses',
to: '/Use_Cases/Mattress_salesman',
position: 'left',
label: 'Use Cases',
},
Expand Down
Loading

0 comments on commit 503794d

Please sign in to comment.