Upload folder using huggingface_hub
Browse files- README.md +15 -0
- model-card.md +138 -0
- upload_to_hf.py +88 -0
README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ZenoBot Model - Hugging Face Deployment
|
| 2 |
|
| 3 |
This folder contains the necessary files to deploy ZenoBot as a Hugging Face API service.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- travel
|
| 8 |
+
- itinerary
|
| 9 |
+
- assistant
|
| 10 |
+
- llama
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
widget:
|
| 13 |
+
- text: "Plan a 3-day trip to California starting on 15/04/2024"
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
# ZenoBot Model - Hugging Face Deployment
|
| 17 |
|
| 18 |
This folder contains the necessary files to deploy ZenoBot as a Hugging Face API service.
|
model-card.md
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
+
library_name: transformers
|
| 6 |
+
tags:
|
| 7 |
+
- travel
|
| 8 |
+
- itinerary
|
| 9 |
+
- assistant
|
| 10 |
+
- llama
|
| 11 |
+
pipeline_tag: text-generation
|
| 12 |
+
widget:
|
| 13 |
+
- text: "Plan a 3-day trip to California starting on 15/04/2024"
|
| 14 |
+
example_title: "California Trip"
|
| 15 |
+
- text: "Create a 5-day itinerary for New York state starting next Monday"
|
| 16 |
+
example_title: "New York Trip"
|
| 17 |
+
- text: "I want to visit Florida for a weekend"
|
| 18 |
+
example_title: "Florida Weekend"
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
# ZenoBot - AI Travel Itinerary Assistant
|
| 22 |
+
|
| 23 |
+
ZenoBot is an AI-powered travel assistant that specializes in creating detailed travel itineraries strictly within one state in a country. Built on the Llama 3.2 architecture, ZenoBot generates comprehensive, geographically sensible travel plans with morning, afternoon, and evening activities for each day of your trip.
|
| 24 |
+
|
| 25 |
+
## Model Description
|
| 26 |
+
|
| 27 |
+
ZenoBot is designed to create travel itineraries with the following characteristics:
|
| 28 |
+
|
| 29 |
+
- **State-specific**: All travel plans stay within a single state
|
| 30 |
+
- **Geographically sensible**: Activities are grouped to minimize unnecessary travel
|
| 31 |
+
- **Comprehensive**: Each day includes morning, afternoon, evening, and an additional activity
|
| 32 |
+
- **Well-structured**: Results are delivered in a consistent JSON format
|
| 33 |
+
- **Realistic**: Takes into account travel times between locations
|
| 34 |
+
- **Diverse**: Balances various types of experiences (nature, culture, history, etc.)
|
| 35 |
+
|
| 36 |
+
## Intended Use
|
| 37 |
+
|
| 38 |
+
This model is intended to help users plan trips within specific states in various countries. It's especially useful for:
|
| 39 |
+
|
| 40 |
+
- Tourists planning a visit to a specific state
|
| 41 |
+
- Travel agents creating custom itineraries
|
| 42 |
+
- Locals looking to explore more of their own state
|
| 43 |
+
- Anyone overwhelmed by the options when planning a trip
|
| 44 |
+
|
| 45 |
+
## Usage Examples
|
| 46 |
+
|
| 47 |
+
### API Request Format
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
import requests
|
| 51 |
+
import json
|
| 52 |
+
|
| 53 |
+
query = "Plan a 3-day trip to California starting on 15/04/2024"
|
| 54 |
+
|
| 55 |
+
response = requests.post(
|
| 56 |
+
"https://api-endpoint/generate",
|
| 57 |
+
json={"query": query, "temperature": 0.1}
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
result = response.json()
|
| 61 |
+
print(json.dumps(result, indent=2))
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
### Sample Output
|
| 65 |
+
|
| 66 |
+
```json
|
| 67 |
+
{
|
| 68 |
+
"response": {
|
| 69 |
+
"tripDetails": {
|
| 70 |
+
"tripLengthHigh": false
|
| 71 |
+
},
|
| 72 |
+
"itinerary": [
|
| 73 |
+
{
|
| 74 |
+
"dayStart": "[DayStart]",
|
| 75 |
+
"date": "15/04/2024",
|
| 76 |
+
"morningStart": "[MorningStart]",
|
| 77 |
+
"morning": {
|
| 78 |
+
"name": "Golden Gate Bridge Visit",
|
| 79 |
+
"location": "San Francisco",
|
| 80 |
+
"description": "Start your California adventure with a visit to the iconic Golden Gate Bridge.",
|
| 81 |
+
"transportation": "Taxi"
|
| 82 |
+
},
|
| 83 |
+
"afternoonStart": "[AfternoonStart]",
|
| 84 |
+
"afternoon": {
|
| 85 |
+
"name": "Alcatraz Island Tour",
|
| 86 |
+
"location": "San Francisco Bay",
|
| 87 |
+
"description": "Explore the historic Alcatraz Federal Penitentiary.",
|
| 88 |
+
"transportation": "Ferry"
|
| 89 |
+
},
|
| 90 |
+
"eveningStart": "[EveningStart]",
|
| 91 |
+
"evening": {
|
| 92 |
+
"name": "Fisherman's Wharf Exploration",
|
| 93 |
+
"location": "San Francisco",
|
| 94 |
+
"description": "Enjoy the lively atmosphere of Fisherman's Wharf.",
|
| 95 |
+
"transportation": "Walking"
|
| 96 |
+
},
|
| 97 |
+
"additionalActivityStart": "[AdditionalActivityStart]",
|
| 98 |
+
"additionalActivity": {
|
| 99 |
+
"name": "Cable Car Ride",
|
| 100 |
+
"location": "San Francisco",
|
| 101 |
+
"description": "Take a ride on San Francisco's historic cable cars."
|
| 102 |
+
},
|
| 103 |
+
"dayEnd": "[DayEnd]"
|
| 104 |
+
}
|
| 105 |
+
// Additional days follow the same format
|
| 106 |
+
]
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
```
|
| 110 |
+
|
| 111 |
+
## Limitations
|
| 112 |
+
|
| 113 |
+
- ZenoBot only plans for activities within a single state
|
| 114 |
+
- It does not recommend specific hotels or accommodations
|
| 115 |
+
- It does not include food or restaurant recommendations
|
| 116 |
+
- The model may occasionally suggest activities that are seasonal or unavailable
|
| 117 |
+
- Activities are not verified for current operating hours or availability
|
| 118 |
+
|
| 119 |
+
## Training Details
|
| 120 |
+
|
| 121 |
+
ZenoBot is based on the Llama 3.2 architecture and has been fine-tuned to specialize in travel itinerary generation. The model has been trained to understand geography within states and to create logical travel routes that minimize unnecessary travel time.
|
| 122 |
+
|
| 123 |
+
## Ethical Considerations
|
| 124 |
+
|
| 125 |
+
While ZenoBot attempts to provide useful travel suggestions, users should always:
|
| 126 |
+
|
| 127 |
+
- Verify the existence and availability of suggested activities
|
| 128 |
+
- Check current operating hours and admission requirements
|
| 129 |
+
- Consider local travel advisories and weather conditions
|
| 130 |
+
- Respect local customs and regulations
|
| 131 |
+
- Make their own judgments about the suitability of suggested activities
|
| 132 |
+
|
| 133 |
+
## Contact Information
|
| 134 |
+
|
| 135 |
+
For questions, feedback, or issues regarding ZenoBot, please contact:
|
| 136 |
+
|
| 137 |
+
- GitHub: [ZenoBot Repository](https://github.com/Zeno0007/ZenoBot)
|
| 138 |
+
- Hugging Face: [@Zeno0007](https://huggingface.co/Zeno0007)
|
upload_to_hf.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import argparse
|
| 3 |
+
from huggingface_hub import HfApi, create_repo, HfFolder
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
def upload_to_huggingface(repo_name = "Zeno0007/zenobot", local_dir='.', token=None):
|
| 7 |
+
"""
|
| 8 |
+
Upload files to a Hugging Face repository.
|
| 9 |
+
|
| 10 |
+
Args:
|
| 11 |
+
repo_name (str): Name of the repository (e.g., 'username/model-name')
|
| 12 |
+
local_dir (str): Local directory containing the files to upload
|
| 13 |
+
token (str, optional): Hugging Face token. If None, will look for it in env vars.
|
| 14 |
+
"""
|
| 15 |
+
# Get token from different sources with priority
|
| 16 |
+
if token is None:
|
| 17 |
+
# Try to load from .env file first
|
| 18 |
+
load_dotenv()
|
| 19 |
+
|
| 20 |
+
# If no variables found, try alternate .env filenames
|
| 21 |
+
if not (os.environ.get("HUGGINGFACE_TOKEN") or os.environ.get("HF_TOKEN")):
|
| 22 |
+
if os.path.exists(".env.sample"):
|
| 23 |
+
load_dotenv(".env.sample")
|
| 24 |
+
|
| 25 |
+
# Check various environment variables for the token
|
| 26 |
+
token = (os.environ.get("HUGGINGFACE_TOKEN") or
|
| 27 |
+
os.environ.get("HF_TOKEN") or
|
| 28 |
+
os.environ.get("HF_API_TOKEN"))
|
| 29 |
+
|
| 30 |
+
# If still no token, try the Hugging Face CLI cached token
|
| 31 |
+
if token is None:
|
| 32 |
+
token = HfFolder.get_token()
|
| 33 |
+
|
| 34 |
+
if token is None:
|
| 35 |
+
print("Error: No Hugging Face token found.")
|
| 36 |
+
print("Please provide a token using one of these methods:")
|
| 37 |
+
print("1. Pass it as an argument: --token YOUR_TOKEN")
|
| 38 |
+
print("2. Set it as an environment variable: export HUGGINGFACE_TOKEN=YOUR_TOKEN")
|
| 39 |
+
print("3. Create a .env file with HUGGINGFACE_TOKEN=YOUR_TOKEN")
|
| 40 |
+
print("4. Login using the huggingface-cli: huggingface-cli login")
|
| 41 |
+
return
|
| 42 |
+
|
| 43 |
+
# Initialize the Hugging Face API
|
| 44 |
+
api = HfApi(token=token)
|
| 45 |
+
|
| 46 |
+
# Create or get the repository
|
| 47 |
+
try:
|
| 48 |
+
repo_url = create_repo(repo_name, exist_ok=True, token=token)
|
| 49 |
+
print(f"Repository URL: {repo_url}")
|
| 50 |
+
except Exception as e:
|
| 51 |
+
print(f"Error creating repository: {e}")
|
| 52 |
+
print("\nPlease make sure your token is valid and has write access to this repository.")
|
| 53 |
+
print("You can create or find your token at: https://huggingface.co/settings/tokens")
|
| 54 |
+
return
|
| 55 |
+
|
| 56 |
+
# Define files to be included/excluded
|
| 57 |
+
ignore_patterns = [
|
| 58 |
+
".git/",
|
| 59 |
+
"venv/",
|
| 60 |
+
"__pycache__/",
|
| 61 |
+
"*.pyc",
|
| 62 |
+
".env",
|
| 63 |
+
".gitignore",
|
| 64 |
+
"setup_venv.sh"
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
# Upload the files
|
| 68 |
+
print(f"Uploading files to {repo_name}...")
|
| 69 |
+
try:
|
| 70 |
+
api.upload_folder(
|
| 71 |
+
folder_path=local_dir,
|
| 72 |
+
repo_id=repo_name,
|
| 73 |
+
ignore_patterns=ignore_patterns,
|
| 74 |
+
token=token
|
| 75 |
+
)
|
| 76 |
+
print("Upload complete!")
|
| 77 |
+
except Exception as e:
|
| 78 |
+
print(f"Error during upload: {e}")
|
| 79 |
+
|
| 80 |
+
if __name__ == "__main__":
|
| 81 |
+
parser = argparse.ArgumentParser(description="Upload files to Hugging Face Hub")
|
| 82 |
+
parser.add_argument("repo_name", nargs="?", default="Zeno0007/zenobot",
|
| 83 |
+
help="Name of the repository (e.g., 'username/model-name')")
|
| 84 |
+
parser.add_argument("--dir", default=".", help="Local directory containing the files to upload")
|
| 85 |
+
parser.add_argument("--token", help="Hugging Face token (optional if set as environment variable)")
|
| 86 |
+
|
| 87 |
+
args = parser.parse_args()
|
| 88 |
+
upload_to_huggingface(args.repo_name, args.dir, args.token)
|