Skip to content

Commit

Permalink
Merge branch 'main' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhu authored Oct 13, 2024
2 parents 5a10e28 + 43ccc81 commit 83b0bb5
Show file tree
Hide file tree
Showing 56 changed files with 1,164 additions and 687 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL Advanced"

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '25 17 * * 3'

jobs:
analyze:
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
include:
- language: csharp
build-mode: manual
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- if: matrix.build-mode == 'manual'
shell: bash
working-directory: dotnet
run: |
dotnet workload install aspire
dotnet restore -bl
dotnet build --no-restore --configuration Release -bl /p:SignAssembly=true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
uv sync --locked --all-extras
source .venv/bin/activate
poe --directory ./packages/autogen-core docs-build
mkdir -p docs-staging/autogen/dev/
mv ./packages/autogen-core/docs/build/* docs-staging/autogen/dev/
mkdir -p docs-staging/dev/
mv ./packages/autogen-core/docs/build/* docs-staging/dev/
working-directory: ./python
- name: generate redirects
run: |
Expand Down Expand Up @@ -99,8 +99,8 @@ jobs:
fi
- run: |
mkdir -p artifact/autogen/0.2/
cp -r build/* artifact/autogen/0.2/
mkdir -p artifact/0.2/
cp -r build/* artifact/0.2/
- uses: actions/upload-artifact@v4
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/single-python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy single package

on:
workflow_dispatch:
inputs:
package:
description: 'Select the package to deploy'
required: true
type: choice
options:
- autogen-agentchat
- autogen-core
- autogen-ext
- agbench
- autogen-magentic-one
- autogen-studio
ref:
description: 'Tag to deploy'
required: true

jobs:
deploy-package:
environment:
name: package
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
# Require ref to be a tag
- run: git show-ref --verify refs/tags/${{ github.event.inputs.ref }}
- run: curl -LsSf https://astral.sh/uv/install.sh | sh
- run: uv build --package ${{ github.event.inputs.package }} --out-dir dist/
working-directory: python
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: python/dist/
43 changes: 0 additions & 43 deletions CONTRIBUTORS.md

This file was deleted.

45 changes: 28 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<a name="readme-top"></a>

<div align="center">
<img src="https://microsoft.github.io/autogen/img/ag.svg" alt="AutoGen Logo" width="100">
<img src="https://microsoft.github.io/autogen/0.2/img/ag.svg" alt="AutoGen Logo" width="100">

[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/cloudposse.svg?style=social&label=Follow%20%40pyautogen)](https://twitter.com/pyautogen)

Expand All @@ -10,7 +10,7 @@
# AutoGen

> [!IMPORTANT]
> AutoGen 0.4 is a from-the-ground-up rewrite of AutoGen. Learn more about the history, goals and future at [this blog post](https://microsoft.github.io/autogen/blog). We’re excited to work with the community to gather feedback, refine, and improve the project before we officially release 0.4. This is a big change, so AutoGen 0.2 is still available, maintained, and developed in the [0.2 branch](https://github.com/microsoft/autogen/tree/0.2).
> [AutoGen 0.4](https://microsoft.github.io/autogen/dev) is a from-the-ground-up rewrite of AutoGen. Learn more about the history, goals and future at [this blog post](https://microsoft.github.io/autogen/blog). We’re excited to work with the community to gather feedback, refine, and improve the project before we officially release 0.4. This is a big change, so AutoGen 0.2 is still available, maintained, and developed in the [0.2 branch](https://github.com/microsoft/autogen/tree/0.2).
AutoGen is an open-source framework for building AI agent systems.
It simplifies the creation of event-driven, distributed, scalable, and resilient agentic applications.
Expand Down Expand Up @@ -47,14 +47,14 @@ AutoGen offers the following key features:
AutoGen has several packages and is built upon a layered architecture.
Currently, there are three main APIs your application can target:

- [Core](https://microsoft.github.io/autogen/dev/core-user-guide/index.html)
- [AgentChat](https://microsoft.github.io/autogen/dev/agentchat-user-guide/index.html)
- [Core](https://microsoft.github.io/autogen/dev/user-guide/core-user-guide/index.html)
- [AgentChat](https://microsoft.github.io/autogen/dev/user-guide/agentchat-user-guide/index.html)
- [Extensions](https://microsoft.github.io/autogen/dev/reference/python/autogen_ext/autogen_ext.html)

## Core

- [Installation](https://microsoft.github.io/autogen/dev/packages/index.html#pkg-info-autogen-core)
- [Quickstart](https://microsoft.github.io/autogen/dev/core-user-guide/guides/quickstart.html)
- [Quickstart](https://microsoft.github.io/autogen/dev/user-guide/core-user-guide/quickstart.html)

The core API of AutoGen, `autogen-core`, is built following the
[actor model](https://en.wikipedia.org/wiki/Actor_model).
Expand All @@ -68,7 +68,7 @@ while still communicating with one another.
## AgentChat

- [Installation](https://microsoft.github.io/autogen/dev/packages/index.html#pkg-info-autogen-agentchat)
- [Quickstart](https://microsoft.github.io/autogen/dev/agentchat-user-guide/guides/quickstart.html)
- [Quickstart](https://microsoft.github.io/autogen/dev/user-guide/agentchat-user-guide/quickstart.html)

The AgentChat API, `autogen-agentchat`, is task driven and at a high level like AutoGen 0.2.
It allows you to define conversational agents, compose them into teams and then
Expand Down Expand Up @@ -106,21 +106,32 @@ The following code uses code execution, you need to have [Docker installed](http
and running on your machine.

```python
import asyncio
import logging
from autogen_agentchat import EVENT_LOGGER_NAME
from autogen_agentchat.agents import CodeExecutorAgent, CodingAssistantAgent
from autogen_agentchat.logging import ConsoleLogHandler
from autogen_agentchat.teams import RoundRobinGroupChat, StopMessageTermination
from autogen_core.components.code_executor import DockerCommandLineCodeExecutor
from autogen_ext.code_executor.docker_executor import DockerCommandLineCodeExecutor
from autogen_core.components.models import OpenAIChatCompletionClient

async with DockerCommandLineCodeExecutor(work_dir="coding") as code_executor:
code_executor_agent = CodeExecutorAgent("code_executor", code_executor=code_executor)
coding_assistant_agent = CodingAssistantAgent(
"coding_assistant", model_client=OpenAIChatCompletionClient(model="gpt-4o")
)
group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent])
result = await group_chat.run(
task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'.",
termination_condition=StopMessageTermination(),
)
logger = logging.getLogger(EVENT_LOGGER_NAME)
logger.addHandler(ConsoleLogHandler())
logger.setLevel(logging.INFO)

async def main() -> None:
async with DockerCommandLineCodeExecutor(work_dir="coding") as code_executor:
code_executor_agent = CodeExecutorAgent("code_executor", code_executor=code_executor)
coding_assistant_agent = CodingAssistantAgent(
"coding_assistant", model_client=OpenAIChatCompletionClient(model="gpt-4o", api_key="YOUR_API_KEY")
)
group_chat = RoundRobinGroupChat([coding_assistant_agent, code_executor_agent])
result = await group_chat.run(
task="Create a plot of NVDIA and TSLA stock returns YTD from 2024-01-01 and save it to 'nvidia_tesla_2024_ytd.png'.",
termination_condition=StopMessageTermination(),
)

asyncio.run(main())
```

### C#
Expand Down
1 change: 0 additions & 1 deletion dotnet/samples/Hello/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public async Task Handle(ConversationClosed item)
Message = goodbye
}.ToCloudEvent(this.AgentId.Key);
await PublishEvent(evt).ConfigureAwait(false);
await Task.Delay(60000);
await App.ShutdownAsync();
}
public async Task<string> SayHello(string ask)
Expand Down
42 changes: 25 additions & 17 deletions dotnet/src/AutoGen.SourceGenerator/FunctionCallGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// FunctionCallGenerator.cs

using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Linq;
Expand Down Expand Up @@ -100,7 +101,10 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
};

var functionSource = functionTT.TransformText();
var fileName = $"{className}.generated.cs";
// Avoid conflict with filename for parallel builds targeting several .NET versions
// at once. Without unique filenames, the build will fail with the 'IOException'
// with message 'The process cannot access the file '%TEMP%\{className}.generated.cs'
var fileName = $"{className}_{System.Guid.NewGuid()}.generated.cs";

ctx.AddSource(fileName, SourceText.From(functionSource, System.Text.Encoding.UTF8));
File.WriteAllText(Path.Combine(Path.GetTempPath(), fileName), functionSource);
Expand All @@ -110,25 +114,29 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
{
var overallFunctionDefinition = source.Right.SelectMany(x => x!.FunctionContracts.Select(y => new { fullClassName = x.FullClassName, y = y }));
var overallFunctionDefinitionObject = overallFunctionDefinition.Select(
x => new
x =>
{
fullClassName = x.fullClassName,
functionDefinition = new
Debug.Assert(x.y.Parameters != null, "x.y.Parameters != null");
return new
{
x.y.Name,
x.y.Description,
x.y.ReturnType,
Parameters = x.y.Parameters.Select(y => new
fullClassName = x.fullClassName,
functionDefinition = new
{
y.Name,
y.Description,
y.JsonType,
y.JsonItemType,
y.Type,
y.IsOptional,
y.DefaultValue,
}),
},
x.y.Name,
x.y.Description,
x.y.ReturnType,
Parameters = x.y.Parameters.Select(y => new
{
y.Name,
y.Description,
y.JsonType,
y.JsonItemType,
y.Type,
y.IsOptional,
y.DefaultValue,
}),
},
};
});

var json = JsonConvert.SerializeObject(overallFunctionDefinitionObject, formatting: Formatting.Indented);
Expand Down
Loading

0 comments on commit 83b0bb5

Please sign in to comment.