Skip to content

Commit a9d5086

Browse files
author
Heena Ugale
committed
testing changes in main not to be pushed, just push RR_collab_SK version
1 parent 4bb348a commit a9d5086

File tree

6 files changed

+71
-14
lines changed

6 files changed

+71
-14
lines changed

FETCH_HEAD

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import requests
2+
3+
# Backend URL (adjust if using a different port)
4+
url = "http://localhost:7000/chat"
5+
6+
# Prepare your payload with session_id and user prompt
7+
data = {
8+
"session_id": "test_session_1",
9+
"prompt": "what was my last subscription for customer ID 103?"
10+
}
11+
12+
# Make the POST request to the backend
13+
response = requests.post(url, json=data)
14+
15+
# Print the response
16+
print("Response:", response.json())
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import os
2+
import logging
3+
from typing import Any, Dict, List, Optional
4+
from dotenv import load_dotenv
5+
6+
load_dotenv() # Load environment variables from .env file if needed
7+
8+
class BaseAgent:
9+
"""
10+
Base class for all agents.
11+
Not intended to be used directly.
12+
Handles environment variables, state store, and chat history.
13+
"""
14+
15+
def __init__(self, state_store: Dict[str, Any], session_id: str) -> None:
16+
self.azure_deployment = os.getenv("AZURE_OPENAI_CHAT_DEPLOYMENT")
17+
self.azure_openai_key = os.getenv("AZURE_OPENAI_API_KEY")
18+
self.azure_openai_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
19+
self.api_version = os.getenv("AZURE_OPENAI_API_VERSION")
20+
self.mcp_server_uri = os.getenv("MCP_SERVER_URI")
21+
self.openai_model_name = os.getenv("OPENAI_MODEL_NAME")
22+
23+
self.session_id = session_id
24+
self.state_store = state_store
25+
26+
self.chat_history: List[Dict[str, str]] = self.state_store.get(f"{session_id}_chat_history", [])
27+
self.state: Optional[Any] = self.state_store.get(session_id, None)
28+
logging.debug(f"Chat history for session {session_id}: {self.chat_history}")
29+
30+
def _setstate(self, state: Any) -> None:
31+
self.state_store[self.session_id] = state
32+
33+
def append_to_chat_history(self, messages: List[Dict[str, str]]) -> None:
34+
self.chat_history.extend(messages)
35+
self.state_store[f"{self.session_id}_chat_history"] = self.chat_history
36+
37+
async def chat_async(self, prompt: str) -> str:
38+
"""
39+
Override in child class!
40+
"""
41+
raise NotImplementedError("chat_async should be implemented in subclass.")

agentic_ai/agents/semantic_kernel/multi_agent/collaborative_multi_agent.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,17 @@ async def chat_async(self, prompt: str) -> str:
344344

345345

346346
# --------------------------- Manual test helper --------------------------- #
347-
if __name__ == "__main__":
348-
349-
async def _demo() -> None:
350-
dummy_state: dict = {}
351-
agent = Agent(dummy_state, session_id="demo")
352-
user_question = "My customer id is 101, what is my current balance?"
353-
answer = await agent.chat_async(user_question)
354-
print("\n>>> Assistant reply:\n", answer)
355-
try:
356-
await agent.contoso_plugin.close()
357-
except Exception as exc:
358-
logger.warning(f"SSE plugin close failed: {exc}")
359-
360-
asyncio.run(_demo())
347+
# if __name__ == "__main__":
348+
349+
# async def _demo() -> None:
350+
# dummy_state: dict = {}
351+
# agent = Agent(dummy_state, session_id="demo")
352+
# user_question = "My customer id is 101, why is my internet bill so high?"
353+
# answer = await agent.chat_async(user_question)
354+
# print("\n>>> Assistant reply:\n", answer)
355+
# try:
356+
# await agent.contoso_plugin.close()
357+
# except Exception as exc:
358+
# logger.warning(f"SSE plugin close failed: {exc}")
359+
360+
# asyncio.run(_demo())

agentic_ai/agents/semantic_kernel/multi_agent/test_updatedsdk.py

Whitespace-only changes.

git

Whitespace-only changes.

0 commit comments

Comments
 (0)