khurrameycon commited on
Commit
ae31f7e
·
verified ·
1 Parent(s): 44d8d66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -8
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
- # Annotated as a ClassVar so Pydantic doesn't treat it as a model 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" # Default to a known available voice
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
- # Include a system message to provide conversation context
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": [