Hjgugugjhuhjggg commited on
Commit
bdfd0ae
·
verified ·
1 Parent(s): 0306915

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -6,7 +6,7 @@ from typing import Union
6
 
7
  from fastapi import FastAPI, HTTPException, Response, Request, UploadFile, File
8
  from fastapi.responses import StreamingResponse
9
- from pydantic import BaseModel, ValidationError, validator
10
  from transformers import (
11
  AutoConfig,
12
  AutoModelForCausalLM,
@@ -45,13 +45,15 @@ class GenerateRequest(BaseModel):
45
  chunk_delay: float = 0.0
46
  stop_sequences: list[str] = []
47
 
48
- @validator("model_name")
 
 
49
  def model_name_cannot_be_empty(cls, v):
50
  if not v:
51
  raise ValueError("model_name cannot be empty.")
52
  return v
53
 
54
- @validator("task_type")
55
  def task_type_must_be_valid(cls, v):
56
  valid_types = ["text-to-text", "text-to-image", "text-to-speech", "text-to-video"]
57
  if v not in valid_types:
 
6
 
7
  from fastapi import FastAPI, HTTPException, Response, Request, UploadFile, File
8
  from fastapi.responses import StreamingResponse
9
+ from pydantic import BaseModel, ValidationError, field_validator
10
  from transformers import (
11
  AutoConfig,
12
  AutoModelForCausalLM,
 
45
  chunk_delay: float = 0.0
46
  stop_sequences: list[str] = []
47
 
48
+ model_config = {"protected_namespaces": ()}
49
+
50
+ @field_validator("model_name")
51
  def model_name_cannot_be_empty(cls, v):
52
  if not v:
53
  raise ValueError("model_name cannot be empty.")
54
  return v
55
 
56
+ @field_validator("task_type")
57
  def task_type_must_be_valid(cls, v):
58
  valid_types = ["text-to-text", "text-to-image", "text-to-speech", "text-to-video"]
59
  if v not in valid_types: