ctn8176 commited on
Commit
dd0962f
·
verified ·
1 Parent(s): 41fa765

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -43,12 +43,12 @@ def get_movie_info(movie_title):
43
  year = details_data.get("release_date", "Unknown Year")[:4]
44
  genre = ", ".join(genre["name"] for genre in details_data.get("genres", []))
45
  tmdb_link = f"https://www.themoviedb.org/movie/{movie_id}"
46
- # poster_path = details_data.get("poster_path")
47
 
48
  # Convert poster_path to a complete image URL
49
- # image_url = f"https://image.tmdb.org/t/p/w500{poster_path}" if poster_path else ""
50
 
51
- return f"Title: {title}, Year: {year}, Genre: {genre}\nFind more info here: {tmdb_link}"
52
 
53
  else:
54
  return "Movie not found", ""
@@ -65,7 +65,7 @@ def generate_response(prompt):
65
  )
66
 
67
  # Call the get_movie_info function to enrich the response
68
- movie_info = get_movie_info(prompt)
69
 
70
  # Concatenate the movie info with the input template
71
  input_text_template += f" Movie Info: {movie_info}"
@@ -83,7 +83,7 @@ def generate_response(prompt):
83
  output = model.generate(**model_inputs, **gen_conf)
84
 
85
  generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
86
- return f"Movie Info:\n{movie_info}\n\nGenerated Response:\n{generated_text}"
87
 
88
  # Define chat function for gr.ChatInterface
89
  def chat_function(message, history):
@@ -93,4 +93,4 @@ def chat_function(message, history):
93
 
94
  # Create Gradio Chat Interface
95
  chat_interface = gr.ChatInterface(chat_function)
96
- chat_interface.launch()
 
43
  year = details_data.get("release_date", "Unknown Year")[:4]
44
  genre = ", ".join(genre["name"] for genre in details_data.get("genres", []))
45
  tmdb_link = f"https://www.themoviedb.org/movie/{movie_id}"
46
+ poster_path = details_data.get("poster_path")
47
 
48
  # Convert poster_path to a complete image URL
49
+ image_url = f"https://image.tmdb.org/t/p/w500{poster_path}" if poster_path else ""
50
 
51
+ return f"Title: {title}, Year: {year}, Genre: {genre}\nFind more info here: {tmdb_link}", image_url
52
 
53
  else:
54
  return "Movie not found", ""
 
65
  )
66
 
67
  # Call the get_movie_info function to enrich the response
68
+ movie_info, image_url = get_movie_info(prompt)
69
 
70
  # Concatenate the movie info with the input template
71
  input_text_template += f" Movie Info: {movie_info}"
 
83
  output = model.generate(**model_inputs, **gen_conf)
84
 
85
  generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
86
+ return f"Movie Info:\n{movie_info}\n\nGenerated Response:\n{generated_text}\nImage URL: {image_url}"
87
 
88
  # Define chat function for gr.ChatInterface
89
  def chat_function(message, history):
 
93
 
94
  # Create Gradio Chat Interface
95
  chat_interface = gr.ChatInterface(chat_function)
96
+ chat_interface.launch()