mirror of
https://github.com/showlab/Code2Video.git
synced 2026-10-08 12:47:51 +00:00
Merge cbcfe93156 into c3dd611b55
This commit is contained in:
commit
fb5fdd2389
1 changed files with 4 additions and 4 deletions
|
|
@ -118,11 +118,11 @@ class SmartSVGDownloader:
|
||||||
response = self.api_function(prompt, max_tokens=100)[0]
|
response = self.api_function(prompt, max_tokens=100)[0]
|
||||||
try:
|
try:
|
||||||
content = response.candidates[0].content.parts[0].text
|
content = response.candidates[0].content.parts[0].text
|
||||||
except:
|
except Exception:
|
||||||
content = response.choices[0].message.content
|
content = response.choices[0].message.content
|
||||||
elements = [line.strip().lower() for line in content.strip().split("\n") if line.strip()]
|
elements = [line.strip().lower() for line in content.strip().split("\n") if line.strip()]
|
||||||
return list(dict.fromkeys(elements))[:4]
|
return list(dict.fromkeys(elements))[:4]
|
||||||
except:
|
except Exception:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _check_cache(self, element: str) -> Optional[str]:
|
def _check_cache(self, element: str) -> Optional[str]:
|
||||||
|
|
@ -162,7 +162,7 @@ class SmartSVGDownloader:
|
||||||
filepath = self.assets_dir / f"{element}.png"
|
filepath = self.assets_dir / f"{element}.png"
|
||||||
filepath.write_bytes(img_resp.content)
|
filepath.write_bytes(img_resp.content)
|
||||||
return str(filepath.absolute())
|
return str(filepath.absolute())
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _download_iconify(self, element: str) -> Optional[str]:
|
def _download_iconify(self, element: str) -> Optional[str]:
|
||||||
|
|
@ -178,7 +178,7 @@ class SmartSVGDownloader:
|
||||||
filepath = self.assets_dir / f"{element}.svg"
|
filepath = self.assets_dir / f"{element}.svg"
|
||||||
filepath.write_text(svg_resp.text, encoding="utf-8")
|
filepath.write_text(svg_resp.text, encoding="utf-8")
|
||||||
return str(filepath.absolute())
|
return str(filepath.absolute())
|
||||||
except:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _enhance_animations(self, animations: List[str], assets: Dict[str, str]) -> List[str]:
|
def _enhance_animations(self, animations: List[str], assets: Dict[str, str]) -> List[str]:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue