Commit ·
f10bf2f
1
Parent(s): b4a0f99
GEMINI API along with Env Updated for functionality
Browse files- environment.yml +9 -3
- src/api/gemini.py +6 -7
environment.yml
CHANGED
|
@@ -1,14 +1,21 @@
|
|
| 1 |
name: manimator
|
| 2 |
channels:
|
| 3 |
-
- defaults
|
| 4 |
- conda-forge
|
|
|
|
| 5 |
- pytorch
|
| 6 |
dependencies:
|
| 7 |
- python=3.10
|
| 8 |
- pip
|
| 9 |
- numpy>=1.24.0
|
| 10 |
- scipy>=1.10.0
|
| 11 |
-
- libstdcxx-ng
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
- pip:
|
| 13 |
- streamlit>=1.27.0
|
| 14 |
- manim>=0.17.3
|
|
@@ -22,4 +29,3 @@ dependencies:
|
|
| 22 |
- pytorch
|
| 23 |
- torchvision
|
| 24 |
- torchaudio
|
| 25 |
-
- google-genai
|
|
|
|
| 1 |
name: manimator
|
| 2 |
channels:
|
|
|
|
| 3 |
- conda-forge
|
| 4 |
+
- defaults
|
| 5 |
- pytorch
|
| 6 |
dependencies:
|
| 7 |
- python=3.10
|
| 8 |
- pip
|
| 9 |
- numpy>=1.24.0
|
| 10 |
- scipy>=1.10.0
|
| 11 |
+
- libstdcxx-ng # espeak problem fix
|
| 12 |
+
- pango
|
| 13 |
+
- cairo
|
| 14 |
+
- glib
|
| 15 |
+
- harfbuzz
|
| 16 |
+
- freetype
|
| 17 |
+
- fontconfig
|
| 18 |
+
- pkg-config # for compilation
|
| 19 |
- pip:
|
| 20 |
- streamlit>=1.27.0
|
| 21 |
- manim>=0.17.3
|
|
|
|
| 29 |
- pytorch
|
| 30 |
- torchvision
|
| 31 |
- torchaudio
|
|
|
src/api/gemini.py
CHANGED
|
@@ -39,7 +39,7 @@ base_prompt_instructions = (
|
|
| 39 |
"\n3. Matrix visualization:"
|
| 40 |
"\n - Use MathTex for display"
|
| 41 |
"\n - Format: r'\\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix}'"
|
| 42 |
-
"\n4. Use only verified Manim methods:"
|
| 43 |
"\n - self.play(), self.wait(), Create(), Write(), Transform(), FadeIn(), FadeOut(), Add(), Remove(), MoveAlongPath(), Rotating(), Circumscribe(), Indicate(), FocusOn(), Shift(), Scale(), MoveTo(), NextTo(), Axes(), Plot(), LineGraph(), BarChart(), Dot(), Line(), Arrow(), Text(), Tex(), MathTex(), VGroup(), Mobject.animate, self.camera.frame.animate"
|
| 44 |
"\n5. DO NOT USE IMAGES IMPORTS."
|
| 45 |
"\n6. Make the video crazy and innovative by:"
|
|
@@ -75,7 +75,7 @@ def load_manim_examples():
|
|
| 75 |
if not guide_path.exists():
|
| 76 |
logging.warning(f"Manim examples guide not found at {guide_path}")
|
| 77 |
return ""
|
| 78 |
-
|
| 79 |
logging.info(f"Loading Manim examples from {guide_path}")
|
| 80 |
return guide_path.read_text(encoding="utf-8")
|
| 81 |
|
|
@@ -94,7 +94,7 @@ def generate_video(idea: str | None = None, pdf_path: str | None = None):
|
|
| 94 |
|
| 95 |
client = genai.Client(api_key=api_key)
|
| 96 |
contents = []
|
| 97 |
-
|
| 98 |
manim_examples = load_manim_examples()
|
| 99 |
if manim_examples:
|
| 100 |
examples_prompt = "Below are examples of Manim code that demonstrate proper usage patterns. Use these as reference when generating your animation:\n\n" + manim_examples
|
|
@@ -102,7 +102,7 @@ def generate_video(idea: str | None = None, pdf_path: str | None = None):
|
|
| 102 |
logging.info("Added Manim examples from guide.md to prime the model")
|
| 103 |
else:
|
| 104 |
logging.warning("No Manim examples were loaded from guide.md")
|
| 105 |
-
|
| 106 |
user_prompt_text = ""
|
| 107 |
|
| 108 |
if pdf_path:
|
|
@@ -129,9 +129,9 @@ def generate_video(idea: str | None = None, pdf_path: str | None = None):
|
|
| 129 |
generation_config = genai_types.GenerateContentConfig(
|
| 130 |
system_instruction=SYSTEM_PROMPT
|
| 131 |
)
|
| 132 |
-
|
| 133 |
response = client.models.generate_content(
|
| 134 |
-
model="gemini-
|
| 135 |
contents=contents,
|
| 136 |
config=generation_config
|
| 137 |
)
|
|
@@ -205,4 +205,3 @@ def generate_video(idea: str | None = None, pdf_path: str | None = None):
|
|
| 205 |
else:
|
| 206 |
logging.error("Error generating video content. No response received from Gemini.")
|
| 207 |
raise Exception("Error generating video content. No response received.")
|
| 208 |
-
|
|
|
|
| 39 |
"\n3. Matrix visualization:"
|
| 40 |
"\n - Use MathTex for display"
|
| 41 |
"\n - Format: r'\\begin{bmatrix} a & b \\\\ c & d \\end{bmatrix}'"
|
| 42 |
+
"\n4. Use only verified Manim methods:"
|
| 43 |
"\n - self.play(), self.wait(), Create(), Write(), Transform(), FadeIn(), FadeOut(), Add(), Remove(), MoveAlongPath(), Rotating(), Circumscribe(), Indicate(), FocusOn(), Shift(), Scale(), MoveTo(), NextTo(), Axes(), Plot(), LineGraph(), BarChart(), Dot(), Line(), Arrow(), Text(), Tex(), MathTex(), VGroup(), Mobject.animate, self.camera.frame.animate"
|
| 44 |
"\n5. DO NOT USE IMAGES IMPORTS."
|
| 45 |
"\n6. Make the video crazy and innovative by:"
|
|
|
|
| 75 |
if not guide_path.exists():
|
| 76 |
logging.warning(f"Manim examples guide not found at {guide_path}")
|
| 77 |
return ""
|
| 78 |
+
|
| 79 |
logging.info(f"Loading Manim examples from {guide_path}")
|
| 80 |
return guide_path.read_text(encoding="utf-8")
|
| 81 |
|
|
|
|
| 94 |
|
| 95 |
client = genai.Client(api_key=api_key)
|
| 96 |
contents = []
|
| 97 |
+
|
| 98 |
manim_examples = load_manim_examples()
|
| 99 |
if manim_examples:
|
| 100 |
examples_prompt = "Below are examples of Manim code that demonstrate proper usage patterns. Use these as reference when generating your animation:\n\n" + manim_examples
|
|
|
|
| 102 |
logging.info("Added Manim examples from guide.md to prime the model")
|
| 103 |
else:
|
| 104 |
logging.warning("No Manim examples were loaded from guide.md")
|
| 105 |
+
|
| 106 |
user_prompt_text = ""
|
| 107 |
|
| 108 |
if pdf_path:
|
|
|
|
| 129 |
generation_config = genai_types.GenerateContentConfig(
|
| 130 |
system_instruction=SYSTEM_PROMPT
|
| 131 |
)
|
| 132 |
+
|
| 133 |
response = client.models.generate_content(
|
| 134 |
+
model="gemini-2.0-flash",
|
| 135 |
contents=contents,
|
| 136 |
config=generation_config
|
| 137 |
)
|
|
|
|
| 205 |
else:
|
| 206 |
logging.error("Error generating video content. No response received from Gemini.")
|
| 207 |
raise Exception("Error generating video content. No response received.")
|
|
|