Skip to content

Commit

Permalink
fix count
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Oct 24, 2024
1 parent ebc7501 commit 0135f6a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/usecases/ai_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,14 @@ async def send_message_to_thread(

# Extract image URLs from the prompt and replace them with {IMAGE}
prompt_parts = prompt.split()
images_seen = 0
for i, part in enumerate(prompt_parts):
if (part.startswith("http://") or part.startswith("https://")) and any(
part.endswith(ext) for ext in gpt.VALID_IMAGE_EXTENSIONS
):
image_urls.append(part)
prompt_parts[i] = f"{{IMAGE #{i + 1}}}"
prompt_parts[i] = f"{{IMAGE #{images_seen + 1}}}"
images_seen += 1
prompt = " ".join(prompt_parts)

# Add the new prompt and attachments to the message history
Expand All @@ -131,6 +133,7 @@ async def send_message_to_thread(
"content": new_message_content,
}
)
print(new_message_content)

functions = openai_functions.get_full_openai_functions_schema()
try:
Expand Down

0 comments on commit 0135f6a

Please sign in to comment.