yangtb24 commited on
Commit
32dd444
1 Parent(s): 0e49543

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -649,6 +649,7 @@ def handsome_chat_completions():
649
  image_url = images[0]
650
  logging.info(f"Extracted image URL: {image_url}")
651
 
 
652
  if image_url:
653
  chunk_data = {
654
  "id": f"chatcmpl-{uuid.uuid4()}",
@@ -660,14 +661,14 @@ def handsome_chat_completions():
660
  "index": 0,
661
  "delta": {
662
  "role": "assistant",
663
- "content": image_url
664
  },
665
  "finish_reason": None
666
  }
667
  ]
668
  }
669
  yield f"data: {json.dumps(chunk_data)}\n\n".encode('utf-8')
670
- full_response_content = image_url
671
  else:
672
  chunk_data = {
673
  "id": f"chatcmpl-{uuid.uuid4()}",
@@ -764,6 +765,7 @@ def handsome_chat_completions():
764
  image_url = images[0]
765
  logging.info(f"Extracted image URL: {image_url}")
766
 
 
767
  # Construct the expected JSON output - Mimicking OpenAI
768
  response_data = {
769
  "id": f"chatcmpl-{uuid.uuid4()}",
@@ -775,7 +777,7 @@ def handsome_chat_completions():
775
  "index": 0,
776
  "message": {
777
  "role": "assistant",
778
- "content": image_url if image_url else "Failed to generate image", # Directly return the URL in content
779
  },
780
  "finish_reason": "stop",
781
  }
 
649
  image_url = images[0]
650
  logging.info(f"Extracted image URL: {image_url}")
651
 
652
+ markdown_image_link = f"![image]({image_url})"
653
  if image_url:
654
  chunk_data = {
655
  "id": f"chatcmpl-{uuid.uuid4()}",
 
661
  "index": 0,
662
  "delta": {
663
  "role": "assistant",
664
+ "content": markdown_image_link
665
  },
666
  "finish_reason": None
667
  }
668
  ]
669
  }
670
  yield f"data: {json.dumps(chunk_data)}\n\n".encode('utf-8')
671
+ full_response_content = markdown_image_link
672
  else:
673
  chunk_data = {
674
  "id": f"chatcmpl-{uuid.uuid4()}",
 
765
  image_url = images[0]
766
  logging.info(f"Extracted image URL: {image_url}")
767
 
768
+ markdown_image_link = f"![image]({image_url})"
769
  # Construct the expected JSON output - Mimicking OpenAI
770
  response_data = {
771
  "id": f"chatcmpl-{uuid.uuid4()}",
 
777
  "index": 0,
778
  "message": {
779
  "role": "assistant",
780
+ "content": markdown_image_link if image_url else "Failed to generate image", # Directly return the URL in content
781
  },
782
  "finish_reason": "stop",
783
  }