Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import torch
|
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
import gradio as gr
|
4 |
import requests
|
|
|
5 |
|
6 |
model_name = "Writer/palmyra-small"
|
7 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
@@ -84,17 +85,18 @@ def generate_response(prompt):
|
|
84 |
|
85 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
86 |
|
87 |
-
#
|
88 |
-
|
89 |
|
90 |
-
return f"Movie Info:\n{movie_info}\n\nGenerated Response:\n{generated_text}"
|
91 |
|
92 |
# Define chat function for gr.ChatInterface
|
93 |
def chat_function(message, history):
|
94 |
-
response
|
95 |
history.append([message, response])
|
96 |
-
return response
|
97 |
|
98 |
# Create Gradio Chat Interface
|
99 |
chat_interface = gr.ChatInterface(chat_function)
|
100 |
-
chat_interface.launch(share=True)
|
|
|
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
import gradio as gr
|
4 |
import requests
|
5 |
+
from IPython.display import display, Image
|
6 |
|
7 |
model_name = "Writer/palmyra-small"
|
8 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
85 |
|
86 |
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
|
87 |
|
88 |
+
# Embed image directly in the response
|
89 |
+
display(Image(url=image_url, alt="Movie Poster"))
|
90 |
|
91 |
+
return f"Movie Info:\n{movie_info}\n\nGenerated Response:\n{generated_text}"
|
92 |
|
93 |
# Define chat function for gr.ChatInterface
|
94 |
def chat_function(message, history):
|
95 |
+
response = generate_response(message)
|
96 |
history.append([message, response])
|
97 |
+
return response
|
98 |
|
99 |
# Create Gradio Chat Interface
|
100 |
chat_interface = gr.ChatInterface(chat_function)
|
101 |
+
chat_interface.launch(share=True) # Added share=True to create a public link
|
102 |
+
|