diff --git a/agent_humanloop/schedule_agent.py b/agent_humanloop/schedule_agent.py index 6619d859..737106c7 100644 --- a/agent_humanloop/schedule_agent.py +++ b/agent_humanloop/schedule_agent.py @@ -1,7 +1,9 @@ import asyncio import time + from restack_ai import Restack + async def main(): client = Restack() @@ -36,4 +38,4 @@ def run_schedule_workflow(): asyncio.run(main()) if __name__ == "__main__": - run_schedule_workflow() \ No newline at end of file + run_schedule_workflow() diff --git a/agent_humanloop/src/agents/agent.py b/agent_humanloop/src/agents/agent.py index 46948284..97f2a487 100644 --- a/agent_humanloop/src/agents/agent.py +++ b/agent_humanloop/src/agents/agent.py @@ -1,9 +1,13 @@ +from dataclasses import dataclass from datetime import timedelta + from restack_ai.agent import agent, import_functions, log -from dataclasses import dataclass with import_functions(): - from src.functions.function import feedback as feedback_function, goodbye, InputFeedback + from src.functions.function import InputFeedback, goodbye + from src.functions.function import ( + feedback as feedback_function, + ) @dataclass class Feedback: @@ -23,7 +27,7 @@ async def event_feedback(self, feedback: Feedback) -> Feedback: result = await agent.step(function=feedback_function, function_input=InputFeedback(feedback.feedback), start_to_close_timeout=timedelta(seconds=120)) log.info("Received feedback", result=result) return result - + @agent.event async def event_end(self, end: End) -> End: log.info("Received end", end=end) diff --git a/agent_humanloop/src/client.py b/agent_humanloop/src/client.py index b71efb06..ffc8a9ac 100644 --- a/agent_humanloop/src/client.py +++ b/agent_humanloop/src/client.py @@ -1,7 +1,9 @@ import os + +from dotenv import load_dotenv from restack_ai import Restack from restack_ai.restack import CloudConnectionOptions -from dotenv import load_dotenv + # Load environment variables from a .env file load_dotenv() @@ -17,4 +19,4 @@ api_key=api_key, api_address=api_address ) -client = Restack(connection_options) \ No newline at end of file +client = Restack(connection_options) diff --git a/agent_humanloop/src/functions/function.py b/agent_humanloop/src/functions/function.py index a04396ed..b926e79b 100644 --- a/agent_humanloop/src/functions/function.py +++ b/agent_humanloop/src/functions/function.py @@ -1,5 +1,8 @@ -from restack_ai.function import function, log from dataclasses import dataclass + +from restack_ai.function import function, log + + @dataclass class InputFeedback: feedback: str @@ -7,7 +10,7 @@ class InputFeedback: @function.defn() async def goodbye() -> str: log.info("goodbye function started") - return f"Goodbye!" + return "Goodbye!" @function.defn() async def feedback(input: InputFeedback) -> str: diff --git a/agent_humanloop/src/services.py b/agent_humanloop/src/services.py index 3fc05a90..32e529f3 100644 --- a/agent_humanloop/src/services.py +++ b/agent_humanloop/src/services.py @@ -1,15 +1,18 @@ import asyncio import os +import webbrowser + from watchfiles import run_process -from src.functions.function import feedback, goodbye + +from src.agents.agent import AgentHumanLoop from src.client import client -from human_loop.src.agents.agent import AgentHumanLoop -import webbrowser +from src.functions.function import feedback, goodbye + async def main(): await client.start_service( - workflows= [AgentHumanLoop], + agents= [AgentHumanLoop], functions= [feedback, goodbye] ) @@ -26,4 +29,4 @@ def watch_services(): run_process(watch_path, recursive=True, target=run_services) if __name__ == "__main__": - run_services() \ No newline at end of file + run_services()