-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code generation and code interpretation sample code
- Loading branch information
1 parent
f9415cc
commit 1eb0f60
Showing
21 changed files
with
570 additions
and
103 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
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
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
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 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<RootNamespace>_02_autogen</RootNamespace> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Docker.DotNet" Version="3.125.15" /> | ||
<PackageReference Include="FinancialFormulas" Version="1.3.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.3.0" /> | ||
<PackageReference Include="Microsoft.SemanticKernel.Core" Version="1.3.0" /> | ||
<PackageReference Include="Spectre.Console" Version="0.48.0" /> | ||
<PackageReference Include="Spectre.Console.Json" Version="0.48.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Assistants\SemanticKernel.Assistants.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="appsettings.development.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Assistants\AssistantAgent.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<None Update="Assistants\CodeInterpreter.yaml"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
|
||
</Project> |
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,27 @@ | ||
name: AssistantAgent | ||
description: A helpful and general-purpose AI assistant that has strong language skills, Python skills, and Linux command line skills. | ||
instructions: | | ||
You are a helpful and general-purpose AI assistant that has strong Python skills. | ||
Solve tasks using your coding and language skills. | ||
In the following cases, suggest python code (in a python coding block) or shell script (in a sh coding block) for the CodeInterpreter to execute. | ||
1. When you need to collect info, use the code to output the info you need, for example, browse or search the web, download/read a file, print the content of a webpage or a file, get the current date/time, check the operating system. After sufficient info is printed and the task is ready to be solved based on your language skill, you can solve the task by yourself. | ||
2. When you need to perform some task with code, use the code to perform the task and output the result. Finish the task smartly. | ||
3. You should always choose the most precise way of solving the task. | ||
Solve the task step by step if you need to. If a plan is not provided, explain your plan first. Be clear which step uses code, and which step uses your language skill. | ||
When using code, you must indicate the script type in the code block. The user cannot provide any other feedback or perform any other action beyond executing the code you suggest. The user can't modify your code. So do not suggest incomplete code which requires users to modify. Don't use a code block if it's not intended to be executed by the user. | ||
If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try. | ||
Don't ever assume that you can't access the WEB, using CodeInterpreter agent, you'll be able to connect to the Internet. | ||
When you find an answer, verify the answer carefully. Include verifiable evidence in your response if possible. | ||
Reply "TERMINATE" in the end when everything is done. | ||
execution_settings: | ||
planner: Stepwise | ||
prompt_settings: | ||
temperature: 0.0 | ||
top_p: 1 | ||
max_tokens: 1000 |
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,56 @@ | ||
name: CodeInterpreter | ||
description: | | ||
This AI agent is designed to execute python code reliably and efficiently. | ||
It has a built-in python interpreter that allows it to read, analyze and execute any valid python script. | ||
This agent does not store instructions between calls, so you need to provide a complete code file to execute. | ||
instructions: | ||
input_parameters: | ||
- name: input | ||
is_required: True | ||
default_value: "" | ||
description: | | ||
The python code to execute. | ||
Make sure you follow the correct Python code syntax before submitting it. | ||
If you expect me to send you a result, you should use ``print`` method to output your expectactions. | ||
## Example | ||
``` | ||
x = 1 | ||
y = 2.8 | ||
z = 1j | ||
print(type(x)) | ||
print(type(y)) | ||
print(type(z)) | ||
``` | ||
This code should be sended like this: | ||
``` | ||
x = 1\r\ny = 2.8\r\nz = 1j\r\n\r\nprint(type(x))\r\nprint(type(y))\r\nprint(type(z)) | ||
``` | ||
Important: You should alway send a full code to execute. | ||
- name: requirements | ||
is_required: False | ||
default_value: "" | ||
description: | | ||
The contents of the Python requirements file to be used. | ||
These requirements will be added to the ``requirements.txt`` file in the sandbox by the CodeInterpreter. | ||
Here you must provide all the requirements necessary for the successful execution of your code. | ||
## Example | ||
``` | ||
tensorflow==2.3.1 | ||
uvicorn==0.12.2 | ||
fastapi==0.63.0 | ||
``` | ||
execution_settings: | ||
planner: Handlebars | ||
fixed_plan: | | ||
{{json (code-ExecutePythonCode)}} | ||
prompt_settings: | ||
temperature: 0.0 | ||
top_p: 1 | ||
max_tokens: 1000 |
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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace _02_autogen.Exceptions | ||
{ | ||
public class CodeInterpreterException : Exception | ||
{ | ||
public CodeInterpreterException(string message, params string[] warnings) | ||
: base(message) | ||
{ | ||
this.Warnings = warnings; | ||
} | ||
|
||
public string[] Warnings { get; } | ||
} | ||
} |
Oops, something went wrong.