fix multi-modual bug (#1127)

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
KevinHuSh 2024-06-12 14:21:35 +08:00 committed by GitHub
parent 169281958b
commit e05395d2a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,10 +75,14 @@ class GptV4(Base):
def describe(self, image, max_tokens=300):
b64 = self.image2base64(image)
prompt = self.prompt(b64)
for i in range(len(prompt)):
for c in prompt[i]["content"]:
if "type" in c: del c["type"]
res = self.client.chat.completions.create(
model=self.model_name,
messages=self.prompt(b64),
messages=prompt,
max_tokens=max_tokens,
)
return res.choices[0].message.content.strip(), res.usage.total_tokens