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

Enable Tool Calls #3512

Draft
wants to merge 5 commits into
base: autogenstudio
Choose a base branch
from
Draft
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
9 changes: 8 additions & 1 deletion samples/apps/autogen-studio/autogenstudio/chatmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ class AutoGenChatManager:
"""

def __init__(
self, message_queue: Queue, websocket_manager: WebSocketConnectionManager = None, human_input_timeout: int = 180
self,
message_queue: Queue,
websocket_manager: WebSocketConnectionManager = None,
human_input_timeout: int = 180,
use_tool_calls = False,
) -> None:
"""
Initializes the AutoGenChatManager with a message queue.
Expand All @@ -27,6 +31,7 @@ def __init__(
self.message_queue = message_queue
self.websocket_manager = websocket_manager
self.a_human_input_timeout = human_input_timeout
self.use_tool_calls = use_tool_calls

def send(self, message: dict) -> None:
"""
Expand Down Expand Up @@ -116,6 +121,7 @@ def chat(
send_message_function=self.send,
a_send_message_function=self.a_send,
connection_id=connection_id,
use_tool_calls=self.use_tool_calls,
)

message_text = message.content.strip()
Expand Down Expand Up @@ -167,6 +173,7 @@ async def a_chat(
a_human_input_function=self.a_prompt_for_input,
a_human_input_timeout=self.a_human_input_timeout,
connection_id=connection_id,
use_tool_calls=self.use_tool_calls,
)

message_text = message.content.strip()
Expand Down
9 changes: 6 additions & 3 deletions samples/apps/autogen-studio/autogenstudio/web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
from ..version import VERSION
from ..websocket_connection_manager import WebSocketConnectionManager

# These should both probably be handled by some "settings" UI page.
HUMAN_INPUT_TIMEOUT_SECONDS = 300
USE_TOOL_CALLS = True


profiler = Profiler()
managers = {"chat": None} # manage calls to autogen
# Create thread-safe queue for messages between api thread and autogen threads
Expand Down Expand Up @@ -65,16 +70,14 @@ def message_handler():
database_engine_uri = folders["database_engine_uri"]
dbmanager = DBManager(engine_uri=database_engine_uri)

HUMAN_INPUT_TIMEOUT_SECONDS = 180


@asynccontextmanager
async def lifespan(app: FastAPI):
print("***** App started *****")
managers["chat"] = AutoGenChatManager(
message_queue=message_queue,
websocket_manager=websocket_manager,
human_input_timeout=HUMAN_INPUT_TIMEOUT_SECONDS,
use_tool_calls=USE_TOOL_CALLS,
)
dbmanager.create_db_and_tables()

Expand Down
Loading