Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -57,7 +57,7 @@ def user(text_prompt: str, chatbot: CHAT_HISTORY):
|
|
57 |
def bot(
|
58 |
files: Optional[List[str]],
|
59 |
model_choice: str,
|
60 |
-
system_instruction: str,
|
61 |
chatbot: CHAT_HISTORY
|
62 |
):
|
63 |
if not GOOGLE_API_KEY:
|
@@ -71,13 +71,17 @@ def bot(
|
|
71 |
top_p=0.9
|
72 |
)
|
73 |
|
|
|
|
|
|
|
|
|
74 |
text_prompt = [chatbot[-1][0]] if chatbot and chatbot[-1][0] and isinstance(chatbot[-1][0], str) else []
|
75 |
image_prompt = [preprocess_image(Image.open(file).convert('RGB')) for file in files] if files else []
|
76 |
|
77 |
model = genai.GenerativeModel(
|
78 |
model_name=model_choice,
|
79 |
generation_config=generation_config,
|
80 |
-
system_instruction=system_instruction
|
81 |
)
|
82 |
|
83 |
response = model.generate_content(text_prompt + image_prompt, stream=True, generation_config=generation_config)
|
|
|
57 |
def bot(
|
58 |
files: Optional[List[str]],
|
59 |
model_choice: str,
|
60 |
+
system_instruction: Optional[str], # Sistema de instrucciones opcional
|
61 |
chatbot: CHAT_HISTORY
|
62 |
):
|
63 |
if not GOOGLE_API_KEY:
|
|
|
71 |
top_p=0.9
|
72 |
)
|
73 |
|
74 |
+
# Usar el valor por defecto para system_instruction si está vacío
|
75 |
+
if not system_instruction:
|
76 |
+
system_instruction = "" # O puedes poner un valor predeterminado como "No system instruction provided."
|
77 |
+
|
78 |
text_prompt = [chatbot[-1][0]] if chatbot and chatbot[-1][0] and isinstance(chatbot[-1][0], str) else []
|
79 |
image_prompt = [preprocess_image(Image.open(file).convert('RGB')) for file in files] if files else []
|
80 |
|
81 |
model = genai.GenerativeModel(
|
82 |
model_name=model_choice,
|
83 |
generation_config=generation_config,
|
84 |
+
system_instruction=system_instruction # Usar el valor por defecto si está vacío
|
85 |
)
|
86 |
|
87 |
response = model.generate_content(text_prompt + image_prompt, stream=True, generation_config=generation_config)
|