forked from tylerprogramming/ai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added directory for autogen 0.2.27 update / html,css,js file save and…
… example .net (cs file)
- Loading branch information
1 parent
32f301c
commit 1647336
Showing
8 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"model": "gpt-4", | ||
"api_key": "sk-proj-1111" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!"); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |