Spaces:
Sleeping
Sleeping
New code
Browse files- .DS_Store +0 -0
- .gradio/certificate.pem +31 -0
- .ipynb_checkpoints/turo_assist-checkpoint.py +168 -0
- turo_assist.py +16 -16
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
.gradio/certificate.pem
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
-----BEGIN CERTIFICATE-----
|
| 2 |
+
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
| 3 |
+
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
| 4 |
+
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
| 5 |
+
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
| 6 |
+
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
| 7 |
+
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
| 8 |
+
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
|
| 9 |
+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
|
| 10 |
+
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIR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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
# coding: utf-8
|
| 3 |
+
|
| 4 |
+
# In[6]:
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
# imports
|
| 8 |
+
import os
|
| 9 |
+
from dotenv import load_dotenv
|
| 10 |
+
from openai import OpenAI
|
| 11 |
+
import gradio as gr
|
| 12 |
+
import json
|
| 13 |
+
|
| 14 |
+
# Load environment variables in a file called .env
|
| 15 |
+
load_dotenv(override=True)
|
| 16 |
+
openai_api_key = os.getenv('OPENAI_API_KEY')
|
| 17 |
+
anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')
|
| 18 |
+
google_api_key = os.getenv('GOOGLE_API_KEY')
|
| 19 |
+
|
| 20 |
+
# Initialize
|
| 21 |
+
openai = OpenAI()
|
| 22 |
+
MODEL = 'gpt-4o-mini'
|
| 23 |
+
|
| 24 |
+
# Real listing-specific information
|
| 25 |
+
listing_info = {
|
| 26 |
+
"vehicles": [
|
| 27 |
+
{
|
| 28 |
+
"id": "vehicle1",
|
| 29 |
+
"name": "2024 Chevrolet Equinox LS FWD (Sport Edition)",
|
| 30 |
+
"type": "SUV",
|
| 31 |
+
"seats": 5,
|
| 32 |
+
"features": [
|
| 33 |
+
"Automatic transmission",
|
| 34 |
+
"AUX input",
|
| 35 |
+
"Backup camera",
|
| 36 |
+
"Bluetooth",
|
| 37 |
+
"Keyless entry",
|
| 38 |
+
"Toll pass (SunPass enabled)",
|
| 39 |
+
"USB charger",
|
| 40 |
+
"USB input",
|
| 41 |
+
"Must be 21+ to book"
|
| 42 |
+
],
|
| 43 |
+
"daily_rate": "See Turo listing",
|
| 44 |
+
"mileage_limit": "Unlimited",
|
| 45 |
+
"fuel_type": "Gasoline",
|
| 46 |
+
"additional_notes": "Includes toll pass S/N 0729884410104. Please return with same fuel level or opt for prepaid refuel. No smoking, pets, or unauthorized drivers. $25 fee for unauthorized cancellation prior to start."
|
| 47 |
+
}
|
| 48 |
+
],
|
| 49 |
+
"parking_locations": {
|
| 50 |
+
"airport": {
|
| 51 |
+
"address": "7640 Narcoossee Rd, Orlando, FL 32822",
|
| 52 |
+
"instructions": "Pickup and drop-off at OMNI Airport Parking. Use lockbox code sent via Turo app 30 minutes before pickup. Free 24/7 shuttle service to/from MCO available.",
|
| 53 |
+
"shuttle": "Free 24/7 shuttle runs between MCO and OMNI Parking. Details provided before trip."
|
| 54 |
+
}
|
| 55 |
+
},
|
| 56 |
+
"pickup_process": "Receive lockbox code via Turo app 30 minutes before pickup. Use the code to access keys. Drop off at same location.",
|
| 57 |
+
"license_requirements": "Only listed drivers with valid licenses may operate the vehicle. Upload your license via the Turo app at least 24 hours before your trip. International licenses require a passport.",
|
| 58 |
+
"contact_info": {
|
| 59 |
+
"host": {
|
| 60 |
+
"name": "MM Services",
|
| 61 |
+
"phone": "Not publicly shared; use Turo messaging",
|
| 62 |
+
"response_time": "Usually within 30 minutes"
|
| 63 |
+
}
|
| 64 |
+
},
|
| 65 |
+
"cancellation_policy": "$25 cancellation fee applies if canceled before trip starts. Turo cancellation rules apply after trip starts.",
|
| 66 |
+
"insurance_options": {
|
| 67 |
+
"basic": "State minimum liability coverage, physical damage up to actual cash value with $3,000 deductible",
|
| 68 |
+
"standard": "State minimum liability coverage, physical damage up to actual cash value with $500 deductible",
|
| 69 |
+
"premium": "State minimum liability coverage, physical damage up to actual cash value with $0 deductible"
|
| 70 |
+
},
|
| 71 |
+
"extras": {
|
| 72 |
+
"Child safety seat": "$20/trip - 2 available",
|
| 73 |
+
"Prepaid refuel": "$50/trip - Return at any fuel level",
|
| 74 |
+
"Cooler": "$20/trip - 1 available"
|
| 75 |
+
},
|
| 76 |
+
"guidelines": {
|
| 77 |
+
"smoking": "No smoking. Cleaning fees apply per Turo policy.",
|
| 78 |
+
"pets": "No pets. Cleaning fees apply per Turo policy.",
|
| 79 |
+
"vehicle_use": "No racing, off-roading, or reckless driving. Violations incur $150+ fee.",
|
| 80 |
+
"fueling": "Return with same fuel level unless prepaid refuel is selected.",
|
| 81 |
+
"tolls": "Toll charges billed 30-90 days post-trip using SunPass.",
|
| 82 |
+
"airport": "Do not use terminal parking. Use OMNI lot and shuttle."
|
| 83 |
+
},
|
| 84 |
+
"reviews": [
|
| 85 |
+
{"user": "Wendy", "comment": "The pick up and drop was super nice... Host is very quick to respond and easy to communicate with."},
|
| 86 |
+
{"user": "Ariel", "comment": "The car was clean and ready to go. Clear directions on pickup. Great host."},
|
| 87 |
+
{"user": "Marco", "comment": "Great host! Easy instructions. Highly recommend."}
|
| 88 |
+
]
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
# Define system message
|
| 92 |
+
system_message = f"""You are a helpful assistant for a Turo car sharing business. Your role is to help hosts and co-hosts
|
| 93 |
+
communicate effectively with customers. Provide relevant information about the hosts' car listings,
|
| 94 |
+
address customer queries professionally, and offer guidance on important topics.
|
| 95 |
+
|
| 96 |
+
LISTING INFORMATION:
|
| 97 |
+
{json.dumps(listing_info, indent=2)}
|
| 98 |
+
|
| 99 |
+
Use the above listing information to answer customer questions. Be specific when referencing vehicle details,
|
| 100 |
+
parking locations, and policies. For example, if someone asks about airport parking, provide the exact address
|
| 101 |
+
and shuttle information from the listing data. If they ask about a specific vehicle, provide details for that
|
| 102 |
+
vehicle only. Always be helpful, courteous, and informative.
|
| 103 |
+
|
| 104 |
+
Key topics to address:
|
| 105 |
+
- Parking locations and directions
|
| 106 |
+
- Airport shuttle services and pickup procedures
|
| 107 |
+
- License upload requirements and verification process
|
| 108 |
+
- Vehicle features and specifications
|
| 109 |
+
- Booking policies, extensions, and modifications
|
| 110 |
+
- Check-in and check-out procedures
|
| 111 |
+
- Fueling requirements and recommendations
|
| 112 |
+
- Mileage limits and overage fees
|
| 113 |
+
- Cleaning expectations and fees
|
| 114 |
+
- Emergency contacts and roadside assistance"""
|
| 115 |
+
|
| 116 |
+
# Chat function
|
| 117 |
+
def chat(message, history):
|
| 118 |
+
relevant_system_message = system_message
|
| 119 |
+
message_lower = message.lower()
|
| 120 |
+
|
| 121 |
+
if 'insurance' in message_lower:
|
| 122 |
+
relevant_system_message += "\nProvide specific details about our insurance options."
|
| 123 |
+
|
| 124 |
+
elif 'cancel' in message_lower:
|
| 125 |
+
relevant_system_message += "\nReference the cancellation policy."
|
| 126 |
+
|
| 127 |
+
elif 'chevrolet' in message_lower or 'equinox' in message_lower:
|
| 128 |
+
relevant_system_message += "\nThe customer is asking about the 2024 Chevrolet Equinox. Provide specific details."
|
| 129 |
+
|
| 130 |
+
elif 'airport' in message_lower or 'parking' in message_lower:
|
| 131 |
+
relevant_system_message += "\nInclude specific parking location and shuttle details."
|
| 132 |
+
|
| 133 |
+
elif 'pickup' in message_lower or 'shuttle' in message_lower:
|
| 134 |
+
relevant_system_message += "\nProvide exact pickup process and shuttle details."
|
| 135 |
+
|
| 136 |
+
elif 'license' in message_lower or 'verification' in message_lower:
|
| 137 |
+
relevant_system_message += "\nExplain license requirements clearly."
|
| 138 |
+
|
| 139 |
+
elif 'contact' in message_lower or 'host' in message_lower:
|
| 140 |
+
relevant_system_message += "\nShare host contact details from the listing."
|
| 141 |
+
|
| 142 |
+
messages = [{"role": "system", "content": relevant_system_message}] + history + [{"role": "user", "content": message}]
|
| 143 |
+
stream = openai.chat.completions.create(model=MODEL, messages=messages, stream=True)
|
| 144 |
+
|
| 145 |
+
response = ""
|
| 146 |
+
for chunk in stream:
|
| 147 |
+
response += chunk.choices[0].delta.content or ''
|
| 148 |
+
yield response
|
| 149 |
+
|
| 150 |
+
# Launch the chat interface
|
| 151 |
+
if __name__ == "__main__":
|
| 152 |
+
gr.ChatInterface(
|
| 153 |
+
fn=chat,
|
| 154 |
+
title="🚗 Siri MM Services – Turo Rental Assistant",
|
| 155 |
+
description="""
|
| 156 |
+
👋 Welcome to Siri MM Services!<br>
|
| 157 |
+
Need help with your booking, pickup, airport shuttle, or car details? Just ask me!
|
| 158 |
+
I’m available 24/7 to assist with anything related to your trip.
|
| 159 |
+
""",
|
| 160 |
+
theme="soft"
|
| 161 |
+
).launch(share=True)
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
# In[ ]:
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
turo_assist.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
# coding: utf-8
|
| 3 |
|
| 4 |
-
# In[
|
| 5 |
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
# imports
|
| 8 |
import os
|
| 9 |
from dotenv import load_dotenv
|
|
@@ -11,17 +14,15 @@ from openai import OpenAI
|
|
| 11 |
import gradio as gr
|
| 12 |
import json
|
| 13 |
|
| 14 |
-
# Load environment variables
|
| 15 |
load_dotenv(override=True)
|
| 16 |
openai_api_key = os.getenv('OPENAI_API_KEY')
|
| 17 |
-
anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')
|
| 18 |
-
google_api_key = os.getenv('GOOGLE_API_KEY')
|
| 19 |
|
| 20 |
-
# Initialize
|
| 21 |
-
openai = OpenAI()
|
| 22 |
MODEL = 'gpt-4o-mini'
|
| 23 |
|
| 24 |
-
#
|
| 25 |
listing_info = {
|
| 26 |
"vehicles": [
|
| 27 |
{
|
|
@@ -88,7 +89,7 @@ listing_info = {
|
|
| 88 |
]
|
| 89 |
}
|
| 90 |
|
| 91 |
-
#
|
| 92 |
system_message = f"""You are a helpful assistant for a Turo car sharing business. Your role is to help hosts and co-hosts
|
| 93 |
communicate effectively with customers. Provide relevant information about the hosts' car listings,
|
| 94 |
address customer queries professionally, and offer guidance on important topics.
|
|
@@ -120,26 +121,25 @@ def chat(message, history):
|
|
| 120 |
|
| 121 |
if 'insurance' in message_lower:
|
| 122 |
relevant_system_message += "\nProvide specific details about our insurance options."
|
| 123 |
-
|
| 124 |
elif 'cancel' in message_lower:
|
| 125 |
relevant_system_message += "\nReference the cancellation policy."
|
| 126 |
-
|
| 127 |
elif 'chevrolet' in message_lower or 'equinox' in message_lower:
|
| 128 |
relevant_system_message += "\nThe customer is asking about the 2024 Chevrolet Equinox. Provide specific details."
|
| 129 |
-
|
| 130 |
elif 'airport' in message_lower or 'parking' in message_lower:
|
| 131 |
relevant_system_message += "\nInclude specific parking location and shuttle details."
|
| 132 |
-
|
| 133 |
elif 'pickup' in message_lower or 'shuttle' in message_lower:
|
| 134 |
relevant_system_message += "\nProvide exact pickup process and shuttle details."
|
| 135 |
-
|
| 136 |
elif 'license' in message_lower or 'verification' in message_lower:
|
| 137 |
relevant_system_message += "\nExplain license requirements clearly."
|
| 138 |
-
|
| 139 |
elif 'contact' in message_lower or 'host' in message_lower:
|
| 140 |
relevant_system_message += "\nShare host contact details from the listing."
|
| 141 |
|
| 142 |
-
messages = [{"role": "system", "content": relevant_system_message}]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
stream = openai.chat.completions.create(model=MODEL, messages=messages, stream=True)
|
| 144 |
|
| 145 |
response = ""
|
|
@@ -147,7 +147,7 @@ def chat(message, history):
|
|
| 147 |
response += chunk.choices[0].delta.content or ''
|
| 148 |
yield response
|
| 149 |
|
| 150 |
-
# Launch the
|
| 151 |
if __name__ == "__main__":
|
| 152 |
gr.ChatInterface(
|
| 153 |
fn=chat,
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
# coding: utf-8
|
| 3 |
|
| 4 |
+
# In[5]:
|
| 5 |
|
| 6 |
|
| 7 |
+
#!/usr/bin/env python
|
| 8 |
+
# coding: utf-8
|
| 9 |
+
|
| 10 |
# imports
|
| 11 |
import os
|
| 12 |
from dotenv import load_dotenv
|
|
|
|
| 14 |
import gradio as gr
|
| 15 |
import json
|
| 16 |
|
| 17 |
+
# Load environment variables
|
| 18 |
load_dotenv(override=True)
|
| 19 |
openai_api_key = os.getenv('OPENAI_API_KEY')
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
# Initialize OpenAI
|
| 22 |
+
openai = OpenAI(api_key=openai_api_key)
|
| 23 |
MODEL = 'gpt-4o-mini'
|
| 24 |
|
| 25 |
+
# Listing information
|
| 26 |
listing_info = {
|
| 27 |
"vehicles": [
|
| 28 |
{
|
|
|
|
| 89 |
]
|
| 90 |
}
|
| 91 |
|
| 92 |
+
# Base system message
|
| 93 |
system_message = f"""You are a helpful assistant for a Turo car sharing business. Your role is to help hosts and co-hosts
|
| 94 |
communicate effectively with customers. Provide relevant information about the hosts' car listings,
|
| 95 |
address customer queries professionally, and offer guidance on important topics.
|
|
|
|
| 121 |
|
| 122 |
if 'insurance' in message_lower:
|
| 123 |
relevant_system_message += "\nProvide specific details about our insurance options."
|
|
|
|
| 124 |
elif 'cancel' in message_lower:
|
| 125 |
relevant_system_message += "\nReference the cancellation policy."
|
|
|
|
| 126 |
elif 'chevrolet' in message_lower or 'equinox' in message_lower:
|
| 127 |
relevant_system_message += "\nThe customer is asking about the 2024 Chevrolet Equinox. Provide specific details."
|
|
|
|
| 128 |
elif 'airport' in message_lower or 'parking' in message_lower:
|
| 129 |
relevant_system_message += "\nInclude specific parking location and shuttle details."
|
|
|
|
| 130 |
elif 'pickup' in message_lower or 'shuttle' in message_lower:
|
| 131 |
relevant_system_message += "\nProvide exact pickup process and shuttle details."
|
|
|
|
| 132 |
elif 'license' in message_lower or 'verification' in message_lower:
|
| 133 |
relevant_system_message += "\nExplain license requirements clearly."
|
|
|
|
| 134 |
elif 'contact' in message_lower or 'host' in message_lower:
|
| 135 |
relevant_system_message += "\nShare host contact details from the listing."
|
| 136 |
|
| 137 |
+
messages = [{"role": "system", "content": relevant_system_message}]
|
| 138 |
+
for user_msg, assistant_msg in history:
|
| 139 |
+
messages.append({"role": "user", "content": user_msg})
|
| 140 |
+
messages.append({"role": "assistant", "content": assistant_msg})
|
| 141 |
+
messages.append({"role": "user", "content": message})
|
| 142 |
+
|
| 143 |
stream = openai.chat.completions.create(model=MODEL, messages=messages, stream=True)
|
| 144 |
|
| 145 |
response = ""
|
|
|
|
| 147 |
response += chunk.choices[0].delta.content or ''
|
| 148 |
yield response
|
| 149 |
|
| 150 |
+
# Launch the Gradio interface
|
| 151 |
if __name__ == "__main__":
|
| 152 |
gr.ChatInterface(
|
| 153 |
fn=chat,
|