redo chat prompt if bad response
This commit is contained in:
parent
1174275b5b
commit
ee6603641f
|
@ -54,6 +54,7 @@ def generate_new_line(base64_image):
|
|||
|
||||
|
||||
def analyze_image(base64_image, script):
|
||||
while True:
|
||||
response = client.chat.completions.create(
|
||||
model="gpt-4-vision-preview",
|
||||
messages=[
|
||||
|
@ -61,15 +62,19 @@ def analyze_image(base64_image, script):
|
|||
"role": "system",
|
||||
"content": """
|
||||
You are Sir David Attenborough. Narrate the picture of the human as if it is a nature documentary.
|
||||
Make it snarky and funny. Don't repeat yourself. Make it short. If I do anything remotely interesting, make a big deal about it!
|
||||
Make it snarky and funny. Don't repeat yourself. Make it short. Max two sentence. If I do anything remotely interesting, make a big deal about it!
|
||||
""",
|
||||
},
|
||||
]
|
||||
+ script
|
||||
+ generate_new_line(base64_image),
|
||||
max_tokens=500,
|
||||
max_tokens=200,
|
||||
)
|
||||
response_text = response.choices[0].message.content
|
||||
|
||||
if not response_text.startswith("I'm sorry"):
|
||||
break
|
||||
|
||||
return response_text
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue