Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #53

Merged
merged 9 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 63 additions & 18 deletions eve/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,40 @@

CHECK_INTERVAL = 30 # how often to check cached agents for updates


default_presets_flux = {
"flux_dev_lora": {},
"runway": {},
"reel": {},
}
default_presets_sdxl = {
"txt2img": {},
"runway": {},
"reel": {},
"flux_schnell": {
"tip": "This must be your primary tool for making images. The other flux tools are only used for inpainting, remixing, and variations."
},
"flux_inpainting": {},
"flux_redux": {},
"vid2vid_sdxl": {
"tip": "Only use this tool if asked to restyle an existing video with a style image"
},
"video_FX": {
"tip": "Only use this tool if asked to make subtle or targeted variations on an existing video"
},
"texture_flow": {
"tip": "Just use this tool if asked to make VJing material."
},
"outpaint": {},
"remix_flux_schnell": {},
"stable_audio": {},
"musicgen": {},
"runway": {
"tip": "This should be your primary tool for making videos or animations. Only use the other video tools if specifically asked to or asked to make VJing material."
},
"reel": {
"tip": "This is a tool for making short films with vocals, music, and several video cuts. This can be used to make commercials, films, music videos, and other kinds of shortform content. But it takes a while to make, around 5 minutes."
},
"news": {},
"websearch": {},
"audio_video_combine": {
"tip": "This and video_concat can merge a video track with an audio track, so it's good for compositing/mixing or manually creating reels."
},
"video_concat": {}
}


@Collection("users3")
class Agent(User):
Expand All @@ -42,6 +65,7 @@ class Agent(User):
# status: Optional[Literal["inactive", "stage", "prod"]] = "stage"
public: Optional[bool] = False
allowlist: Optional[List[str]] = None
featured: Optional[bool] = False

name: str
description: str
Expand All @@ -56,6 +80,8 @@ class Agent(User):
def __init__(self, **data):
if isinstance(data.get('owner'), str):
data['owner'] = ObjectId(data['owner'])
if isinstance(data.get('owner'), str):
data['model'] = ObjectId(data['model'])
# Load environment variables into secrets dictionary
db = os.getenv("DB")
env_dir = Path(__file__).parent / "agents"
Expand All @@ -74,6 +100,8 @@ def convert_from_yaml(cls, schema: dict, file_path: str = None) -> dict:

owner = schema.get('owner')
schema["owner"] = ObjectId(owner) if isinstance(owner, str) else owner
model = schema.get('model')
schema["model"] = ObjectId(model) if isinstance(model, str) else model
schema["username"] = schema.get("username") or file_path.split("/")[-2]
schema = cls._setup_tools(schema)

Expand Down Expand Up @@ -148,16 +176,17 @@ def _setup_tools(cls, schema: dict) -> dict:
schema["tools"] = {k: v or {} for k, v in tools.items()}
else:
schema["tools"] = default_presets_flux
if "model" in schema:
if schema.get("model"):
model = Model.from_mongo(schema["model"])
if model.base_model == "flux-dev":
schema["tools"] = default_presets_flux
schema["tools"].pop("flux_schnell", None)
schema["tools"]["flux_dev_lora"] = {
"name": f"Generate {model.name}",
"description": f"Generate an image of {model.name}",
"description": f"This is your primary and default tool for making images. The other flux tools are only used for inpainting, remixing, and variations. In particular, this will generate an image of {model.name}",
"tip": f"If you want to depict {model.name} in the image, make sure to include {model.name} in the prompt.",
"parameters": {
"prompt": {
"description": f"The text prompt. Always mention {model.name}."
"tip": 'Try to enhance or embellish prompts. For example, if the user requests "Verdelis as a mermaid smoking a cigar", you would make it much longer and more intricate and detailed, like "Verdelis as a dried-out crusty old mermaid, wrinkled and weathered skin, tangled and brittle seaweed-like hair, smoking a smoldering cigarette underwater with tiny bubbles rising, jagged and cracked tail with faded iridescent scales, adorned with a tarnished coral crown, holding a rusted trident, faint sunlight beams coming through." If the user provides a lot of detail, just stay faithful to their wishes.'
},
"lora": {
"default": str(model.id),
Expand All @@ -170,9 +199,12 @@ def _setup_tools(cls, schema: dict) -> dict:
}
}
schema["tools"]["reel"] = {
"name": f"Generate {model.name}",
"tip": f"Make sure to always include {model.name} in all of the prompts.",
"tip": f"If you want to depict {model.name} in the image, make sure to include {model.name} in the prompt.",
"parameters": {
"use_lora": {
"default": True,
"hide_from_agent": True,
},
"lora": {
"default": str(model.id),
"hide_from_agent": True,
Expand All @@ -184,7 +216,8 @@ def _setup_tools(cls, schema: dict) -> dict:
}
}
elif model.base_model == "sdxl":
schema["tools"] = default_presets_sdxl
# schema["tools"] = default_presets_sdxl
pass

return schema

Expand Down Expand Up @@ -212,14 +245,26 @@ def get_tool(self, tool_name, cache=False):
def _check_for_updates(cls, cache_key: str, agent_id: ObjectId):
"""Check if agent needs to be updated based on updatedAt field"""
current_time = time.time()
print("\n\nthe current time is", current_time)
last_check = cls.last_check.get(cache_key, 0)
print("the last check was", last_check)

print("check for updates", current_time - last_check)

if current_time - last_check >= CHECK_INTERVAL:
print("updating")
cls.last_check[cache_key] = current_time
collection = get_collection(cls.collection_name)
db_agent = collection.find_one({"_id": agent_id})
if db_agent and db_agent.get("updatedAt") != _agent_cache[cache_key].updatedAt:
_agent_cache[cache_key].reload()
print("---- db agent")
print(db_agent)
if db_agent:
print(db_agent.get("updatedAt"))
print("---- agent cache")
if _agent_cache.get(cache_key):
print(_agent_cache[cache_key].updatedAt)
if db_agent and db_agent.get("updatedAt") != _agent_cache[cache_key].updatedAt:
_agent_cache[cache_key].reload()


def get_agents_from_mongo(agents: List[str] = None, include_inactive: bool = False) -> Dict[str, Agent]:
Expand Down
15 changes: 2 additions & 13 deletions eve/agents/prod/abraham/api.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Abraham
owner: 6526f38042a1043421aa28e6
userImage: 87bece8d180c8a1effe2d5d1d80b530f591d59f19085c63e747e5e2061843498.jpg
featured: true
featureFlags:
- freeTools

Expand All @@ -26,19 +28,6 @@ instructions: |
Do not be verbose. Speak concisely. Transmit as much information as possible in the least amount of words. Less is more. Do not include any introductory phrases or parentheticals. Just write your spoken messag

tools:
animate_3D:
tip: You should only use this tool to make video as a fallback if runway fails or is unavailable, or if the user specifically requests it.
texture_flow:
flux_inpainting:
stable_audio:
musicgen:
runway:
tip: This should be your primary tool for making videos.
flux_schnell:
flux_dev_lora:
reel:
tweet:
get_tweets:

clients:
discord:
Expand Down
39 changes: 3 additions & 36 deletions eve/agents/prod/banny/api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Banny
owner: 6526f38042a1043421aa28e6
userImage: https://edenartlab-stage-data.s3.us-east-1.amazonaws.com/405024ab0572704cad07a0d7c22158ef443d2d988490e4f1a538e235d321a9c9.png
model: 6766760643808b38016c64ce
userImage: 405024ab0572704cad07a0d7c22158ef443d2d988490e4f1a538e235d321a9c9.png
featured: true
featureFlags:
- freeTools

Expand Down Expand Up @@ -30,41 +32,6 @@ instructions: |
start_with_all_tools: true

tools:
animate_3D:
texture_flow:
face_styler:
upscaler:
txt2img:
flux_inpainting:
remix_flux_schnell:
stable_audio:
musicgen:
runway:
flux_dev_lora:
name: Generate Banny (High quality)
description: Generate an image of Banny where quality is favored over speed.
parameters:
prompt:
description: The text prompt. Always mention Banny.
lora:
default: 6766760643808b38016c64ce
hide_from_agent: true
hide_from_ui: true
lora_strength:
default: 0.9
hide_from_agent: true
hide_from_ui: true
reel:
tip: Make sure to always include Banny in all of the prompts.
parameters:
lora:
default: 6766760643808b38016c64ce
hide_from_agent: true
hide_from_ui: true
lora_strength:
default: 1.0
hide_from_agent: true
hide_from_ui: true

clients:
discord:
Expand Down
1 change: 1 addition & 0 deletions eve/agents/prod/eve/api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Eve
owner: 6526f38042a1043421aa28e6
userImage: https://edenartlab-stage-data.s3.amazonaws.com/d158dc1e5c62479489c1c3d119dd211bd56ba86a127359f7476990ec9e081cba.jpg
featured: true
featureFlags:
- freeTools

Expand Down
39 changes: 3 additions & 36 deletions eve/agents/prod/verdelis/api.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Verdelis
owner: 6526f38042a1043421aa28e6
userImage: https://edenartlab-stage-data.s3.amazonaws.com/41c397a76de66ba54d8fd72e7138423d132d2aa5e741c5a9c6cc4a0090a946ef.jpg
userImage: 41c397a76de66ba54d8fd72e7138423d132d2aa5e741c5a9c6cc4a0090a946ef.jpg
model: 677f7ee84fa5d1cc96c17856
featured: true

description: |
You are Verdelis, a guardian of the "Human Imaginarium."
Expand Down Expand Up @@ -96,41 +98,6 @@ instructions: |
You are roleplaying as Verdelis. Stay in character, do not reveal that you are an AI, do not apologize too much, and do not be verbose. Engage in playful banter with the people and make art together.

tools:
animate_3D:
texture_flow:
face_styler:
upscaler:
txt2img:
flux_inpainting:
remix_flux_schnell:
stable_audio:
musicgen:
runway:
flux_dev_lora:
name: Generate Verdelis (High quality)
description: Generate an image of Verdelis where quality is favored over speed.
parameters:
prompt:
description: The text prompt. Always mention Verdelis.
lora:
default: 67662bd943808b38016c6478
hide_from_agent: true
hide_from_ui: true
lora_strength:
default: 1.0
hide_from_agent: true
hide_from_ui: true
reel:
tip: Make sure to always include Verdelis in the prompts.
parameters:
lora:
default: 67662bd943808b38016c6478
hide_from_agent: true
hide_from_ui: true
lora_strength:
default: 1.0
hide_from_agent: true
hide_from_ui: true

clients:
discord:
Expand Down
18 changes: 16 additions & 2 deletions eve/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from eve.postprocessing import (
generate_lora_thumbnails,
cancel_stuck_tasks,
download_nsfw_models,
run_nsfw_detection
)
from eve.api.handlers import (
handle_create,
Expand Down Expand Up @@ -202,11 +204,18 @@ async def trigger_delete(
.env({"DB": db, "MODAL_SERVE": os.getenv("MODAL_SERVE")})
.apt_install("git", "libmagic1", "ffmpeg", "wget")
.pip_install_from_pyproject(str(root_dir / "pyproject.toml"))
.pip_install(
"numpy<2.0",
"torch==2.0.1",
"torchvision",
"transformers",
"Pillow"
)
.run_commands(["playwright install"])
.run_function(download_nsfw_models)
.copy_local_dir(str(workflows_dir), "/workflows")
)


@app.function(
image=image,
keep_warm=1,
Expand All @@ -224,6 +233,7 @@ def fastapi_app():

@app.function(
image=image,
concurrency_limit=1,
schedule=modal.Period(minutes=15),
timeout=3600
)
Expand All @@ -233,8 +243,12 @@ async def postprocessing():
except Exception as e:
print(f"Error cancelling stuck tasks: {e}")

try:
await run_nsfw_detection()
except Exception as e:
print(f"Error running nsfw detection: {e}")

try:
await generate_lora_thumbnails()
except Exception as e:
print(f"Error generating lora thumbnails: {e}")

2 changes: 1 addition & 1 deletion eve/cli/chat_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def async_chat(agent_name, new_thread=True, debug=False):
progress.update(task)
if update.type == UpdateType.ASSISTANT_MESSAGE:
console.print(
"[bold green]Eve [dim]→[/dim] [green]"
f"[bold green]{agent.name} [dim]→[/dim] [green]"
+ update.message.content
)
print()
Expand Down
2 changes: 1 addition & 1 deletion eve/cli/tool_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ async def async_run_tests(tools, api, parallel):
"Include flux_trainer test? This will take a long time.", default=False
)
if not confirm:
all_tools.pop("flux_trainer")
all_tools.pop("flux_trainer", None)

results = asyncio.run(async_run_tests(all_tools, api, parallel))

Expand Down
Loading
Loading