mirror of
https://github.com/harry0703/MoneyPrinterTurbo.git
synced 2026-02-21 16:37:21 +08:00
fix: response parsing bug for gemini
This commit is contained in:
parent
1f2b36a4f0
commit
ee7306d216
@ -86,7 +86,7 @@ def _generate_response(prompt: str) -> str:
|
||||
|
||||
if llm_provider == "gemini":
|
||||
import google.generativeai as genai
|
||||
genai.configure(api_key=api_key)
|
||||
genai.configure(api_key=api_key, transport='rest')
|
||||
|
||||
generation_config = {
|
||||
"temperature": 0.5,
|
||||
@ -118,11 +118,15 @@ def _generate_response(prompt: str) -> str:
|
||||
generation_config=generation_config,
|
||||
safety_settings=safety_settings)
|
||||
|
||||
convo = model.start_chat(history=[])
|
||||
try:
|
||||
response = model.generate_content(prompt)
|
||||
candidates = response.candidates
|
||||
generated_text = candidates[0].content.parts[0].text
|
||||
except (AttributeError, IndexError) as e:
|
||||
print("Gemini Error:", e)
|
||||
|
||||
return generated_text
|
||||
|
||||
convo.send_message(prompt)
|
||||
return convo.last.text
|
||||
|
||||
if llm_provider == "cloudflare":
|
||||
import requests
|
||||
response = requests.post(
|
||||
@ -180,9 +184,9 @@ Generate a script for a video, depending on the subject of the video.
|
||||
1. the script is to be returned as a string with the specified number of paragraphs.
|
||||
2. do not under any circumstance reference this prompt in your response.
|
||||
3. get straight to the point, don't start with unnecessary things like, "welcome to this video".
|
||||
4. you must not include any type of markdown or formatting in the script, never use a title.
|
||||
5. only return the raw content of the script.
|
||||
6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line.
|
||||
4. you must not include any type of markdown or formatting in the script, never use a title.
|
||||
5. only return the raw content of the script.
|
||||
6. do not include "voiceover", "narrator" or similar indicators of what should be spoken at the beginning of each paragraph or line.
|
||||
7. you must not mention the prompt, or anything about the script itself. also, never talk about the amount of paragraphs or lines. just write the script.
|
||||
8. respond in the same language as the video subject.
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user