Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -58,8 +58,7 @@ def user(text_prompt: str, chatbot: CHAT_HISTORY):
|
|
58 |
def bot(
|
59 |
files: Optional[List[str]],
|
60 |
model_choice: str,
|
61 |
-
chatbot: CHAT_HISTORY
|
62 |
-
system_prompt: str # A帽adimos el par谩metro para el system prompt
|
63 |
):
|
64 |
if not GOOGLE_API_KEY:
|
65 |
raise ValueError("GOOGLE_API_KEY is not set.")
|
@@ -75,12 +74,8 @@ def bot(
|
|
75 |
|
76 |
text_prompt = [chatbot[-1][0]] if chatbot and chatbot[-1][0] and isinstance(chatbot[-1][0], str) else []
|
77 |
image_prompt = [preprocess_image(Image.open(file).convert('RGB')) for file in files] if files else []
|
78 |
-
|
79 |
-
# Aqu铆 incluimos el system prompt en el flujo de generaci贸n de contenido
|
80 |
-
prompt = [system_prompt] + text_prompt # El prompt del sistema se agrega al principio
|
81 |
-
|
82 |
model = genai.GenerativeModel(model_choice)
|
83 |
-
response = model.generate_content(
|
84 |
|
85 |
chatbot[-1][1] = ""
|
86 |
for chunk in response:
|
@@ -109,9 +104,6 @@ model_choice_component = gr.Dropdown(
|
|
109 |
label="Select Model",
|
110 |
scale=2
|
111 |
)
|
112 |
-
system_prompt_component = gr.Textbox(
|
113 |
-
placeholder="Enter system prompt...", show_label=True, scale=8
|
114 |
-
)
|
115 |
|
116 |
user_inputs = [
|
117 |
text_prompt_component,
|
@@ -121,7 +113,6 @@ user_inputs = [
|
|
121 |
bot_inputs = [
|
122 |
upload_button_component,
|
123 |
model_choice_component,
|
124 |
-
system_prompt_component, # A帽adimos el prompt del sistema
|
125 |
chatbot_component
|
126 |
]
|
127 |
|
@@ -135,7 +126,6 @@ with gr.Blocks() as demo:
|
|
135 |
upload_button_component.render()
|
136 |
run_button_component.render()
|
137 |
model_choice_component.render()
|
138 |
-
system_prompt_component.render() # Mostrar el campo para el system prompt
|
139 |
|
140 |
run_button_component.click(
|
141 |
fn=user,
|
|
|
58 |
def bot(
|
59 |
files: Optional[List[str]],
|
60 |
model_choice: str,
|
61 |
+
chatbot: CHAT_HISTORY
|
|
|
62 |
):
|
63 |
if not GOOGLE_API_KEY:
|
64 |
raise ValueError("GOOGLE_API_KEY is not set.")
|
|
|
74 |
|
75 |
text_prompt = [chatbot[-1][0]] if chatbot and chatbot[-1][0] and isinstance(chatbot[-1][0], str) else []
|
76 |
image_prompt = [preprocess_image(Image.open(file).convert('RGB')) for file in files] if files else []
|
|
|
|
|
|
|
|
|
77 |
model = genai.GenerativeModel(model_choice)
|
78 |
+
response = model.generate_content(text_prompt + image_prompt, stream=True, generation_config=generation_config)
|
79 |
|
80 |
chatbot[-1][1] = ""
|
81 |
for chunk in response:
|
|
|
104 |
label="Select Model",
|
105 |
scale=2
|
106 |
)
|
|
|
|
|
|
|
107 |
|
108 |
user_inputs = [
|
109 |
text_prompt_component,
|
|
|
113 |
bot_inputs = [
|
114 |
upload_button_component,
|
115 |
model_choice_component,
|
|
|
116 |
chatbot_component
|
117 |
]
|
118 |
|
|
|
126 |
upload_button_component.render()
|
127 |
run_button_component.render()
|
128 |
model_choice_component.render()
|
|
|
129 |
|
130 |
run_button_component.click(
|
131 |
fn=user,
|