Skip to content

Commit

Permalink
added directory for autogen 0.2.27 update / html,css,js file save and…
Browse files Browse the repository at this point in the history
… example .net (cs file)
  • Loading branch information
tylerprogramming committed May 4, 2024
1 parent 32f301c commit 1647336
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 0 deletions.
6 changes: 6 additions & 0 deletions autogen_updates_0_2_27/OAI_CONFIG_LIST.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"model": "gpt-4",
"api_key": "sk-proj-1111"
}
]
13 changes: 13 additions & 0 deletions autogen_updates_0_2_27/code/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- filename: home.html -->

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
</head>
<body>
<h1>Welcome to the Home Page</h1>
<button id="helloButton">Click me</button>
</body>
</html>
13 changes: 13 additions & 0 deletions autogen_updates_0_2_27/code/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--# filename: index.html-->
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Welcome to the Homepage!</h1>
<button id="hello-button">Click me</button>

<script src="script.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions autogen_updates_0_2_27/code/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// filename: script.js

window.onload = function() {
document.getElementById("helloButton").onclick = function() {
alert("Hello!");
}
};
23 changes: 23 additions & 0 deletions autogen_updates_0_2_27/code/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* filename: style.css */

body {
background-color: lightblue;
}

h1 {
color: white;
text-align: center;
}

#helloButton {
display: block;
width: 200px;
height: 50px;
margin: 20px auto;
background-color: #4CAF50;
color: white;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
text-align: center;
}
22 changes: 22 additions & 0 deletions autogen_updates_0_2_27/code/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# filename: styles.css
body {
background-color: lightblue;
}

h1 {
color: white;
text-align: center;
}

#my_button {
display: block;
width: 200px;
height: 50px;
margin: 20px auto;
background-color: #4CAF50;
color: white;
text-align: center;
line-height: 50px;
font-size: 20px;
cursor: pointer;
}
29 changes: 29 additions & 0 deletions autogen_updates_0_2_27/dotnet-autogen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using AutoGen;
using AutoGen.Core;
using AutoGen.OpenAI;


var openAIKey = "your-api-key";
var gpt35Config = new OpenAIConfig(openAIKey, "gpt-3.5-turbo");

var assistantAgent = new AssistantAgent(
name: "assistant",
systemMessage: "You are an assistant that help user to do some tasks.",
llmConfig: new ConversableAgentConfig
{
Temperature = 0,
ConfigList = [gpt35Config],
})
.RegisterPrintMessage(); // register a hook to print message nicely to console

// set human input mode to ALWAYS so that user always provide input
var userProxyAgent = new UserProxyAgent(
name: "user",
humanInputMode: HumanInputMode.ALWAYS)
.RegisterPrintMessage();

// start the conversation
await userProxyAgent.InitiateChatAsync(
receiver: assistantAgent,
message: "Hey assistant, please do me a favor.",
maxRound: 10);
47 changes: 47 additions & 0 deletions autogen_updates_0_2_27/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import autogen
from autogen.coding import LocalCommandLineCodeExecutor


def main():
config_list = autogen.config_list_from_json(
env_or_file="OAI_CONFIG_LIST.json"
)

# Create a local command line code executor.
executor = LocalCommandLineCodeExecutor(
timeout=10,
work_dir="code",
)

assistant = autogen.AssistantAgent(
name="Assistant",
llm_config={
"config_list": config_list
},
system_message="If you want the user to save the code in a file before executing it, put # filename: "
"<filename> inside the code block as the first line. You are a helpful assistant. Return "
"'TERMINATE' when the task is done."
)

user_proxy = autogen.UserProxyAgent(
name="user",
human_input_mode="NEVER",
is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
code_execution_config={"executor": executor},
)

# trying this out with saving html file!
user_proxy.initiate_chat(
assistant,
message="""
Create a simple html that opens a simple home page and stylize it
with some css and save that in a separate file. Create a simple
button on the html page that when clicked, just displays 'Hello!'.
You can also create a javascript file to make this happen.
Make sure to comment out the file names at the top of each file.
"""
)


if __name__ == "__main__":
main()

0 comments on commit 1647336

Please sign in to comment.