Cristobal299 commited on
Commit
4d60fda
Β·
verified Β·
1 Parent(s): f04b500

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -2
app.py CHANGED
@@ -20,7 +20,7 @@ SYSTEM_DEFAULT = (
20
  print("Cargando tokenizer...")
21
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
22
 
23
- print("Configurando motor de cuantizaci\u00f3n (4-bits)...")
24
  quantization_config = BitsAndBytesConfig(
25
  load_in_4bit=True,
26
  bnb_4bit_compute_dtype=torch.bfloat16,
@@ -69,6 +69,7 @@ def _leer_archivo(path: str) -> str:
69
 
70
  @spaces.GPU
71
  def generar(prompt: str, system: str, key: str, max_tokens: int = 1024) -> str:
 
72
  if API_KEY and key != API_KEY:
73
  return "\u274c Unauthorized"
74
  if not prompt.strip():
@@ -164,9 +165,17 @@ with gr.Blocks(title="\U0001f9e0 F\u00e9nix Brain", theme=gr.themes.Base()) as d
164
  msg_box.submit(_chat, [msg_box, archivo_in, chatbot, system_box, voz_sel, activar_voz], [chatbot, msg_box, audio_out])
165
  clear_btn.click(lambda: ([], "", None), outputs=[chatbot, msg_box, audio_out])
166
 
 
167
  with gr.Tab("\U0001f50c API (La Forja)"):
 
 
 
 
 
 
 
 
168
  gr.Markdown("""
169
- ### Llamada desde La Forja
170
  ```python
171
  from gradio_client import Client
172
  client = Client("Cristobal299/Chat")
 
20
  print("Cargando tokenizer...")
21
  tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, trust_remote_code=True)
22
 
23
+ print("Configurando cuantizaci\u00f3n (4-bits)...")
24
  quantization_config = BitsAndBytesConfig(
25
  load_in_4bit=True,
26
  bnb_4bit_compute_dtype=torch.bfloat16,
 
69
 
70
  @spaces.GPU
71
  def generar(prompt: str, system: str, key: str, max_tokens: int = 1024) -> str:
72
+ """Endpoint API para La Forja."""
73
  if API_KEY and key != API_KEY:
74
  return "\u274c Unauthorized"
75
  if not prompt.strip():
 
165
  msg_box.submit(_chat, [msg_box, archivo_in, chatbot, system_box, voz_sel, activar_voz], [chatbot, msg_box, audio_out])
166
  clear_btn.click(lambda: ([], "", None), outputs=[chatbot, msg_box, audio_out])
167
 
168
+ # ── Endpoint API oculto para La Forja ────────────────────────────────────
169
  with gr.Tab("\U0001f50c API (La Forja)"):
170
+ gr.Markdown("### Endpoint `/generar` para La Forja")
171
+ _p = gr.Textbox(label="prompt", visible=False)
172
+ _s = gr.Textbox(label="system", visible=False)
173
+ _k = gr.Textbox(label="key", visible=False)
174
+ _mt = gr.Number( label="max_tokens", visible=False, value=1024)
175
+ _out = gr.Textbox(label="response", visible=False)
176
+ _btn = gr.Button("generar", visible=False)
177
+ _btn.click(generar, inputs=[_p, _s, _k, _mt], outputs=[_out], api_name="generar")
178
  gr.Markdown("""
 
179
  ```python
180
  from gradio_client import Client
181
  client = Client("Cristobal299/Chat")