Skip to content

A programming framework for agentic AI

Simple chat app (#921)

danyrouh3a768c3189a9
diff --git a/README.md b/README.md
index bfaacc2cc..85b5f806d 100644
--- a/README.md
+++ b/README.md
@@ -119,6 +119,7 @@ After the repo is cloned.
The figure below shows an example conversation flow with AutoGen.
![Agent Chat Example](https://github.com/microsoft/autogen/blob/main/website/static/img/chat_example.png)
+Alternatively, the [sample code](https://github.com/microsoft/autogen/blob/main/samples/simple_chat.py) here allows a user to chat with an AutoGen agent in ChatGPT style.
Please find more [code examples](https://microsoft.github.io/autogen/docs/Examples#automated-multi-agent-chat) for this feature.
## Enhanced LLM Inferences
diff --git a/samples/simple_chat.py b/samples/simple_chat.py
new file mode 100644
index 000000000..1a251c5e2
--- /dev/null
+++ b/samples/simple_chat.py
@@ -0,0 +1,22 @@
+from autogen import UserProxyAgent, ConversableAgent, config_list_from_json
+
+
+def main():
+ # Load LLM inference endpoints from an env variable or a file
+ # See https://microsoft.github.io/autogen/docs/FAQ#set-your-api-endpoints
+ # and OAI_CONFIG_LIST_sample.
+ # For example, if you have created a OAI_CONFIG_LIST file in the current working directory, that file will be used.
+ config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")
+
+ # Create the agent that uses the LLM.
+ assistant = ConversableAgent("agent", llm_config={"config_list": config_list})
+
+ # Create the agent that represents the user in the conversation.
+ user_proxy = UserProxyAgent("user", code_execution_config=False)
+
+ # Let the assistant start the conversation. It will end when the user types exit.
+ assistant.initiate_chat(user_proxy, message="How can I help you today?")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/website/docs/Examples.md b/website/docs/Examples.md
index ac194205b..fb9c2000e 100644
--- a/website/docs/Examples.md
+++ b/website/docs/Examples.md
@@ -38,8 +38,9 @@ Links to notebook examples:
- Function Inception: Enable AutoGen agents to update/remove functions during conversations. - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_inception_function.ipynb)
- Agent Chat with Whisper - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_video_transcript_translate_with_whisper.ipynb)
1. **Human Involvement**
+ - Simple example in ChatGPT style [View example](https://github.com/microsoft/autogen/blob/main/samples/simple_chat.py)
- Auto Code Generation, Execution, Debugging and **Human Feedback** - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_human_feedback.ipynb)
- - Automated Task Solving with GPT-4 + **Multiple Human Users** - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_two_users.ipynb)
+ - Automated Task Solving with GPT-4 + **Multiple Human Users** - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_two_users.ipynb)
- Agent Chat with **Async Human Inputs** - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/Async_human_input.ipynb)
1. **Agent Teaching and Learning**
- Teach Agents New Skills & Reuse via Automated Chat - [View Notebook](https://github.com/microsoft/autogen/blob/main/notebook/agentchat_teaching.ipynb)