Spaces:
Build error
Build error
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -1,19 +1,25 @@
|
|
| 1 |
from crewai import Agent
|
| 2 |
-
from langchain.llms import OpenAI
|
| 3 |
from langchain.llms import HuggingFaceEndpoint
|
| 4 |
-
|
| 5 |
import os
|
| 6 |
from dotenv import load_dotenv
|
|
|
|
|
|
|
| 7 |
load_dotenv()
|
| 8 |
secret_token = os.getenv("content")
|
| 9 |
-
|
| 10 |
-
#from tools.search_tools import SearchTools
|
| 11 |
repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 12 |
-
mistral = HuggingFaceEndpoint(repo_id=repo_id, huggingfacehub_api_token
|
| 13 |
|
| 14 |
class ContentAgents:
|
| 15 |
def __init__(self):
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
def planner_agent(self, topic):
|
| 19 |
return Agent(
|
|
|
|
| 1 |
from crewai import Agent
|
|
|
|
| 2 |
from langchain.llms import HuggingFaceEndpoint
|
|
|
|
| 3 |
import os
|
| 4 |
from dotenv import load_dotenv
|
| 5 |
+
from tools.image_generation_tools import ImageGenerationTools
|
| 6 |
+
|
| 7 |
load_dotenv()
|
| 8 |
secret_token = os.getenv("content")
|
| 9 |
+
|
|
|
|
| 10 |
repo_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 11 |
+
mistral = HuggingFaceEndpoint(repo_id=repo_id, huggingfacehub_api_token=secret_token, max_new_tokens=28000, temperature=0.3, repetition_penalty=1.1)
|
| 12 |
|
| 13 |
class ContentAgents:
|
| 14 |
def __init__(self):
|
| 15 |
+
self.llm = mistral
|
| 16 |
+
self.image_generator = ImageGenerationTools()
|
| 17 |
+
|
| 18 |
+
def generate_image_for_section(self, section_title, topic):
|
| 19 |
+
prompt = f"{section_title} illustration for {topic}"
|
| 20 |
+
save_path = f"images/{section_title.replace(' ', '_')}.png"
|
| 21 |
+
self.image_generator.generate_image(prompt, save_path)
|
| 22 |
+
return save_path
|
| 23 |
|
| 24 |
def planner_agent(self, topic):
|
| 25 |
return Agent(
|