ameursg commited on
Commit
e5d4be3
Β·
verified Β·
1 Parent(s): 280802e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -1,8 +1,19 @@
 
1
  import gradio as gr
2
  from transformers import pipeline
 
3
 
4
- # Load Mistral-7B-Instruct AI model
5
- chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1")
 
 
 
 
 
 
 
 
 
6
 
7
  def generate_itinerary(destination, start_date, end_date, traveler_type, companion):
8
  """Generates an AI-powered travel itinerary based on user preferences"""
 
1
+ import os
2
  import gradio as gr
3
  from transformers import pipeline
4
+ from huggingface_hub import login
5
 
6
+ # Get Hugging Face token securely from environment variables
7
+ HF_TOKEN = os.getenv("HF_TOKEN")
8
+
9
+ # Authenticate with Hugging Face
10
+ if HF_TOKEN:
11
+ login(HF_TOKEN)
12
+ else:
13
+ raise ValueError("🚨 Hugging Face token not found! Please add it to Secrets in your Hugging Face Space.")
14
+
15
+ # Load the Mistral-7B-Instruct AI model
16
+ chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1", token=HF_TOKEN)
17
 
18
  def generate_itinerary(destination, start_date, end_date, traveler_type, companion):
19
  """Generates an AI-powered travel itinerary based on user preferences"""