8000 WIP test adapter · microsoft/Agents-for-python@b65d973 · GitHub
[go: up one dir, main page]

Skip to content

Commit b65d973

Browse files
committed
WIP test adapter
1 parent ad04d27 commit b65d973

File tree

5 files changed

+828
-26
lines changed

5 files changed

+828
-26
lines changed

libraries/Builder/microsoft-agents-builder/microsoft/agents/builder/channel_adapter.py

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ async def create_conversation(
145145
"""
146146
Starts a new conversation with a user. Used to direct message to a member of a group.
147147
148-
:param reference: The conversation reference that contains the tenant
149-
:type reference: :class:`builder.schema.ConversationReference`
150-
:param logic: The logic to use for the creation of the conversation
151-
:type logic: :class:`typing.Callable`
152-
:param conversation_parameters: The information to use to create the conversation
153-
:type conversation_parameters:
148+
:param agent_app_id: The application ID of the agent.
149+
:type agent_app_id: str
154150
:param channel_id: The ID for the channel.
155-
:type channel_id: :class:`typing.str`
151+
:type channel_id: str
156152
:param service_url: The channel's service URL endpoint.
157-
:type service_url: :class:`typing.str`
158-
:param credentials: The application credentials for the agent.
159-
:type credentials: :class:`microsoft.agents.authentication.AppCredentials`
153+
:type service_url: str
154+
:param audience: A value signifying the recipient of the proactive message.
155+
:type audience: str
156+
:param conversation_parameters: The information to use to create the conversation
157+
:type conversation_parameters: :class:`microsoft.agents.core.models.ConversationParameters`
158+
:param callback: The method to call for the resulting agent turn.
159+
:type callback: :class:`typing.Callable[[TurnContext], Awaitable]`
160160
161-
:raises: It raises a generic exception error.
161+
:raises: Exception - Not implemented or when the implementation fails.
162162
163163
:return: A task representing the work queued to execute.
164164
@@ -172,7 +172,46 @@ async def create_conversation(
172172
If the conversation is established with the specified users, the ID of the activity
173173
will contain the ID of the new conversation.
174174
"""
175-
raise Exception("Not Implemented")
175+
from microsoft.agents.core.models import ActivityTypes
176+
177+
# If credentials are not provided, we can't create a conversation
178+
if not conversation_parameters:
179+
raise Exception("conversation_parameters is required")
180+
181+
if (
182+
not conversation_parameters.members
183+
or len(conversation_parameters.members) == 0
184+
):
185+
raise Exception("Conversation parameters must include at least one member")
186+
187+
# Create a new conversation account if none is provided
188+
if (
189+
not conversation_parameters.conversation
190+
or not conversation_parameters.conversation.id
191+
):
192+
from uuid import uuid4
193+
194+
conversation_parameters.conversation = ConversationAccount(id=str(uuid4()))
195+
196+
# Create a conversation update activity
197+
conversation_update = Activity(
198+
type=ActivityTypes.CONVERSATION_UPDATE,
199+
channel_id=channel_id,
200+
service_url=service_url,
201+
conversation=conversation_parameters.conversation,
202+
recipient=conversation_parameters.bot,
203+
from_property=conversation_parameters.members[0],
204+
members_added=conversation_parameters.members,
205+
)
206+
207+
# Create a context for the activity
208+
context = TurnContext(self, conversation_update)
209+
210+
# Set conversation parameters in context data bag
211+
context.turn_state["ConversationParameters"] = conversation_parameters
212+
213+
# Process the activity through the middleware pipeline
214+
return await self.run_pipeline(context, callback)
176215

177216
async def run_pipeline(
178217
self, context: TurnContext, callback: Callable[[TurnContext], Awaitable] = None

0 commit comments

Comments
 (0)
0