Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,12 +118,12 @@ class TextImageRequest(BaseModel):
|
|
| 118 |
voice: str = "af_heart" # Default voice that we know exists
|
| 119 |
speed: float = 1.0
|
| 120 |
|
| 121 |
-
#
|
| 122 |
AVAILABLE_VOICES: ClassVar[List[str]] = ["af_heart"]
|
| 123 |
|
| 124 |
def validate_voice(self):
|
| 125 |
if self.voice not in self.AVAILABLE_VOICES:
|
| 126 |
-
return "af_heart"
|
| 127 |
return self.voice
|
| 128 |
|
| 129 |
class AudioResponse(BaseModel):
|
|
@@ -158,7 +158,7 @@ def llm_chat_response(text, image_base64=None):
|
|
| 158 |
|
| 159 |
logger.info("Initializing InferenceClient...")
|
| 160 |
client = InferenceClient(
|
| 161 |
-
provider="hf-inference", # Using the correct provider
|
| 162 |
api_key=HF_TOKEN
|
| 163 |
)
|
| 164 |
|
|
@@ -178,12 +178,8 @@ def llm_chat_response(text, image_base64=None):
|
|
| 178 |
base_url = os.getenv("BASE_URL", "http://localhost:8000")
|
| 179 |
image_url = f"{base_url}/static/{filename}"
|
| 180 |
prompt = text if text else "Describe this image in one sentence."
|
| 181 |
-
#
|
| 182 |
messages = [
|
| 183 |
-
{
|
| 184 |
-
"role": "system",
|
| 185 |
-
"content": "You are a helpful assistant that describes images and answers questions about them."
|
| 186 |
-
},
|
| 187 |
{
|
| 188 |
"role": "user",
|
| 189 |
"content": [
|
|
|
|
| 118 |
voice: str = "af_heart" # Default voice that we know exists
|
| 119 |
speed: float = 1.0
|
| 120 |
|
| 121 |
+
# Annotate as a ClassVar so Pydantic ignores it as a field.
|
| 122 |
AVAILABLE_VOICES: ClassVar[List[str]] = ["af_heart"]
|
| 123 |
|
| 124 |
def validate_voice(self):
|
| 125 |
if self.voice not in self.AVAILABLE_VOICES:
|
| 126 |
+
return "af_heart"
|
| 127 |
return self.voice
|
| 128 |
|
| 129 |
class AudioResponse(BaseModel):
|
|
|
|
| 158 |
|
| 159 |
logger.info("Initializing InferenceClient...")
|
| 160 |
client = InferenceClient(
|
| 161 |
+
provider="hf-inference", # Using the correct provider as per sample
|
| 162 |
api_key=HF_TOKEN
|
| 163 |
)
|
| 164 |
|
|
|
|
| 178 |
base_url = os.getenv("BASE_URL", "http://localhost:8000")
|
| 179 |
image_url = f"{base_url}/static/{filename}"
|
| 180 |
prompt = text if text else "Describe this image in one sentence."
|
| 181 |
+
# Construct message exactly as in the reference
|
| 182 |
messages = [
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
{
|
| 184 |
"role": "user",
|
| 185 |
"content": [
|