Skip to content

Commit

Permalink
Merge branch 'main' into lilyydu/py-sso
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyydu authored Feb 24, 2025
2 parents 6905042 + 549de97 commit acd2846
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Test
run: dotnet test Microsoft.TeamsAI.Tests/Microsoft.Teams.AI.Tests.csproj --verbosity normal --logger trx --results-directory ./TestResults --collect:"XPlat Code Coverage" --configuration Release
- name: Coverage
uses: danielpalme/ReportGenerator-GitHub-Action@c38c522d4b391c1b0da979cbb2e902c0a252a7dc # 5.4.3
uses: danielpalme/ReportGenerator-GitHub-Action@f1927db1dbfc029b056583ee488832e939447fe6 # 5.4.4
with:
reports: ${{ env.SOLUTION_DIR }}TestResults/*/coverage.cobertura.xml
targetdir: ${{ env.SOLUTION_DIR }}TestResults/coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-build-test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Test
run: dotnet test Microsoft.TeamsAI.Tests/Microsoft.Teams.AI.Tests.csproj --no-restore --verbosity normal --logger trx --results-directory ./TestResults --collect:"XPlat Code Coverage" --configuration Release
- name: Coverage
uses: danielpalme/ReportGenerator-GitHub-Action@c38c522d4b391c1b0da979cbb2e902c0a252a7dc # 5.4.3
uses: danielpalme/ReportGenerator-GitHub-Action@f1927db1dbfc029b056583ee488832e939447fe6 # 5.4.4
with:
reports: ${{ env.SOLUTION_DIR }}TestResults/*/coverage.cobertura.xml
targetdir: ${{ env.SOLUTION_DIR }}TestResults/coverage
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dotnet-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Initialize CodeQL
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
languages: csharp
- name: Setup .NET
Expand All @@ -50,6 +50,6 @@ jobs:
working-directory: dotnet/packages/Microsoft.TeamsAI/
run: dotnet build Microsoft.Teams.AI.sln --configuration Release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
category: "/language:csharp"
4 changes: 2 additions & 2 deletions .github/workflows/js-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Initialize CodeQL
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
category: "/language:javascript"
4 changes: 2 additions & 2 deletions .github/workflows/python-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Initialize CodeQL
uses: github/codeql-action/init@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/init@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
languages: python
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/analyze@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
category: "/language:python"
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@dd746615b3b9d728a6a37ca2045b68ca76d4841a # v3.28.8
uses: github/codeql-action/upload-sarif@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3.28.9
with:
sarif_file: results.sarif
75 changes: 74 additions & 1 deletion getting-started/CONCEPTS/STREAMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ There are three parts to streaming:
- [Python Streaming+Tools LightBot](https://github.com/microsoft/teams-ai/tree/main/python/samples/04.ai.c.actionMapping.lightBot)

## Streaming Response Class
The `StreamingResponse` class is the helper class for streaming responses to the client. The class is used to send a series of updates to the client in a single response. If you are using your own custom model, you can directly instantiate and manage this class to stream responses.
The `StreamingResponse` class is the helper class for streaming responses to the client. The class is used to send a series of updates to the client in a single response.

The expected sequence of calls is:

Expand All @@ -52,6 +52,8 @@ The expected sequence of calls is:

Once `endStream()` is called, the stream is considered ended and no further updates can be sent.

If you are using your own custom model, you can directly instantiate and manage this class to stream responses. The instructions for this scenario are specified below, though we encourage you to read through this to its entirety to understand the complete flow.


## Configuration with Azure Open AI / Open AI

Expand Down Expand Up @@ -208,6 +210,77 @@ planner=ActionPlanner(

```

## Custom `StreamingResponse` Management

### Definitions

- **Stream ID**: A unique identifier for the stream, assigned after the initial update is sent. It ensures that all subsequent messages are associated with the correct stream.
- **Sequence Numbers**: Each message in the stream is assigned a sequence number (`streamSequence`), starting from 1 and incrementing with each message. This helps maintain the order of messages.


The class also maintains an internal queue for outgoing activities to ensure they are sent in order and without overloading the Teams client.

### Implementation

#### 1. Initialize `StreamingResponse`

To start using the `StreamingResponse` class, you need to create an instance of it within your bot's turn handler.

```javascript
const streamingResponse = new StreamingResponse(context);
```


#### 2. Send Informative Updates

```javascript
streamingResponse.queueInformativeUpdate('Searching for the information you requested...');
```

#### 3. Queuing Text Chunks

As your bot generates or retrieves content, you can send partial messages to the user.

**Note 1**: As we do not handle chunking, this class assumes you already have some form of chunking mechanism (e.g., via another LLM) prior to using this class.
The streaming behaviour is determined through the timeouts and the size of the text chunks.

**Note 2**: It is important to include a delay between the chunks to avoid spamming the Teams Client.

```javascript
const firstChunk = 'Here is the first part of the information.';
const secondChunk = 'Continuing with more details...';

streamingResponse.queueTextChunk(firstChunk);

// Delay between chunks, minimum 1000ms
await new Promise(resolve => setTimeout(resolve, 1500));

streamingResponse.queueTextChunk(secondChunk);
```

#### 4. Ending the Stream

Call the `endStream` method to conclude the stream. Since this method returns a promise, use `await` to ensure all queued activities are sent before proceeding.


```javascript
await streamingResponse.endStream();
```

### Extra Features

You may also be interested in adding in the [Powered by AI](./POWERED-BY-AI.md) features.

To configure the Feedback Loop, use the `setFeedbackLoop` and `setFeedbackLoopType` methods.

To configure the Generated by AI button, use the `setGeneratedByAILabel` method.

To configure the Sensitivity Label, use the `setSensitivityLabel` method.

To configure citations, use the `setCitations` method. Please see the ClientCitation interface in the Teams AI library for the expected shape of the citation object.

To configure attachments, use the `setAttachments` method. Note that this is only currently rendered for the final chunk.

---

## Return to other major section topics:
Expand Down

0 comments on commit acd2846

Please sign in to comment.