Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
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
5 changes: 2 additions & 3 deletions common/js/langchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ export default async function LangChainAgent(
// Create a ChatOpenAI model
const model = new ChatOpenAI({
model: 'gpt-5-mini',
temperature: 0,
});

// Create a prompt template
const prompt = ChatPromptTemplate.fromTemplate(`
You are an expert in LangChain, the TypeScript/JavaScript framework for building LLM-powered applications.
You specialize in explaining chains, agents, memory management, prompt templates, output parsers, and
You specialize in explaining chains, agents, memory management, prompt templates, output parsers, and
building production-ready AI applications. Provide detailed, practical information about LangChain development.

Human: {input}
Assistant:`);

Expand Down
3 changes: 1 addition & 2 deletions common/js/langgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ export default async function LangGraphAgent(
// Create a ChatOpenAI model
const model = new ChatOpenAI({
model: 'gpt-5-mini',
temperature: 0,
});

// Create a prompt template
const prompt = ChatPromptTemplate.fromTemplate(`
You are an expert in LangGraph, the TypeScript framework for building stateful AI agents with graph-based workflows.
You specialize in explaining StateGraph architecture, node and edge definitions, tool integration, human-in-the-loop controls,
persistence, and ReAct patterns. Provide detailed, practical information about LangGraph development including code examples.

Human: {input}
Assistant:`);

Expand Down
39 changes: 23 additions & 16 deletions common/py/autogen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,57 @@
from autogen_core import CancellationToken
from autogen_ext.models.openai import OpenAIChatCompletionClient


def welcome():
return {
"welcome": "Welcome to the Microsoft AutoGen Agent! I can help you build multi-agent conversational AI applications with collaborative workflows.",
"prompts": [
{
"data": "Show me how multiple agents can collaborate on a complex task",
"contentType": "text/plain"
"contentType": "text/plain",
},
{
"data": "What are the advantages of using AutoGen for multi-agent systems?",
"contentType": "text/plain"
}
]
"contentType": "text/plain",
},
],
}


async def run(request: AgentRequest, response: AgentResponse, context: AgentContext):
try:
user_message = await request.data.text() or "Hello! Tell me about Microsoft AutoGen and how agents collaborate."

user_message = (
await request.data.text()
or "Hello! Tell me about Microsoft AutoGen and how agents collaborate."
)

# Create model client
model_client = OpenAIChatCompletionClient(model="gpt-4o-mini", temperature=0.7)
model_client = OpenAIChatCompletionClient(model="gpt-4o-mini")

# Create an AssistantAgent with OpenAI model
assistant = AssistantAgent(
name="assistant",
model_client=model_client,
system_message="You are a helpful AI assistant specializing in multi-agent systems and collaborative AI workflows. Provide detailed, informative responses about how agents can work together to solve complex problems."
system_message="You are a helpful AI assistant specializing in multi-agent systems and collaborative AI workflows. Provide detailed, informative responses about how agents can work together to solve complex problems.",
)

# Create a message from the user
message = TextMessage(content=user_message, source="user")
cancellation_token = CancellationToken()

# Send message to assistant and get response
agent_response = await assistant.on_messages([message], cancellation_token)

# Close the model client connection
await model_client.close()

# Extract the response text
response_text = agent_response.chat_message.content

return response.text(response_text)

except Exception as e:
context.logger.error(f"Error running AutoGen agent: {e}")
return response.text("Sorry, there was an error processing your request with the AutoGen agents.")
return response.text(
"Sorry, there was an error processing your request with the AutoGen agents."
)
50 changes: 32 additions & 18 deletions common/py/langgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,73 @@
from langchain_core.messages import AIMessage
from langchain_openai import ChatOpenAI


def welcome():
return {
"welcome": "Welcome to the LangGraph Agent! I can help you build stateful AI agents with graph-based workflows and human-in-the-loop controls.",
"prompts": [
{
"data": "How do I create stateful agents with LangGraph workflows?",
"contentType": "text/plain"
"contentType": "text/plain",
},
{
"data": "What are the advantages of using graph-based agent architectures?",
"contentType": "text/plain"
}
]
"contentType": "text/plain",
},
],
}


# Define example tools for the LangGraph agent
@tool
def get_info(topic: str) -> str:
"""
Get information about a specific topic related to LangGraph and agent development.

Args:
topic (str): The topic to get information about

Returns:
str: Information about the topic
"""
info_database = {
"langgraph": "LangGraph is a framework for building stateful AI agents with graph-based workflows, human-in-the-loop controls, and persistence.",
"stategraph": "StateGraph is the core component in LangGraph that defines the nodes and edges of your agent workflow.",
"tools": "Tools in LangGraph are Python functions that agents can call to perform specific actions or retrieve information.",
"workflows": "Workflows in LangGraph are defined as graphs with nodes (functions) and edges (control flow) that enable complex agent behavior."
"workflows": "Workflows in LangGraph are defined as graphs with nodes (functions) and edges (control flow) that enable complex agent behavior.",
}

topic_lower = topic.lower()
for key, value in info_database.items():
if key in topic_lower:
return value

return f"LangGraph is a powerful framework for building stateful AI agents. It provides graph-based workflows, tool integration, and human-in-the-loop controls for reliable agent development."


# List of available tools
tools = [get_info]

# Initialize the LLM and bind tools
model = ChatOpenAI(model="gpt-5-mini", temperature=0).bind_tools(tools)
model = ChatOpenAI(model="gpt-5-mini").bind_tools(tools)
tool_node = ToolNode(tools)


def call_model(state: MessagesState) -> dict:
"""Node to call the agent model"""
messages = state["messages"]
response = model.invoke(messages)
return {"messages": [response]}


def should_continue(state: MessagesState) -> str:
"""Determine whether to call tools or end the workflow"""
last_message = state["messages"][-1]
if last_message.tool_calls:
return "tools"
return END


# Build the StateGraph
workflow = StateGraph(MessagesState)
workflow.add_node("agent", call_model)
Expand All @@ -85,28 +91,36 @@ def should_continue(state: MessagesState) -> str:
# Compile the graph
agent_graph = workflow.compile()


async def run(request: AgentRequest, response: AgentResponse, context: AgentContext):
try:
user_message = await request.data.text() or "Tell me about LangGraph and how it helps build stateful AI agents."

user_message = (
await request.data.text()
or "Tell me about LangGraph and how it helps build stateful AI agents."
)

# Create initial state with user message
initial_state = {"messages": [("human", user_message)]}

# Run the LangGraph workflow
final_state = None
for chunk in agent_graph.stream(initial_state, stream_mode="values"):
if "messages" in chunk and chunk["messages"]:
final_state = chunk

# Extract the final response
if final_state and "messages" in final_state and final_state["messages"]:
# Get the last AI message
for message in reversed(final_state["messages"]):
if isinstance(message, AIMessage):
return response.text(message.content)

return response.text("I'd be happy to help you learn about LangGraph and building stateful AI agents! Please ask me about graph-based workflows, tools, or agent architecture.")


return response.text(
"I'd be happy to help you learn about LangGraph and building stateful AI agents! Please ask me about graph-based workflows, tools, or agent architecture."
)

except Exception as e:
context.logger.error(f"Error running LangGraph agent: {e}")
return response.text("Sorry, there was an error processing your request with the LangGraph agent.")
return response.text(
"Sorry, there was an error processing your request with the LangGraph agent."
)