Skip to content
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
4 changes: 3 additions & 1 deletion agent_humanloop/schedule_agent.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import asyncio
import time

from restack_ai import Restack


async def main():

client = Restack()
Expand Down Expand Up @@ -36,4 +38,4 @@ def run_schedule_workflow():
asyncio.run(main())

if __name__ == "__main__":
run_schedule_workflow()
run_schedule_workflow()
10 changes: 7 additions & 3 deletions agent_humanloop/src/agents/agent.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions agent_humanloop/src/client.py
Original file line number Diff line number Diff line change
@@ -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()

Expand All @@ -17,4 +19,4 @@
api_key=api_key,
api_address=api_address
)
client = Restack(connection_options)
client = Restack(connection_options)
7 changes: 5 additions & 2 deletions agent_humanloop/src/functions/function.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from restack_ai.function import function, log
from dataclasses import dataclass

from restack_ai.function import function, log


@dataclass
class InputFeedback:
feedback: str

@function.defn()
async def goodbye() -> str:
log.info("goodbye function started")
return f"Goodbye!"
return "Goodbye!"

@function.defn()
async def feedback(input: InputFeedback) -> str:
Expand Down
13 changes: 8 additions & 5 deletions agent_humanloop/src/services.py
Original file line number Diff line number Diff line change
@@ -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]
)

Expand All @@ -26,4 +29,4 @@ def watch_services():
run_process(watch_path, recursive=True, target=run_services)

if __name__ == "__main__":
run_services()
run_services()