Skip to content

Commit

Permalink
[repo] fix: C# Citations' encodingFormat to not be hardcoded. Fix J…
Browse files Browse the repository at this point in the history
…S AssistantsPlanner options to set api version (#2235)

## Linked issues

closes: #2234
closes: #2233

## Details

- Fix C# `AIEntity` to make `encodingFormat` optional and not hardcoded.
- Change inline docs to indicate `encodingFormat` is for
`citation.appearance.text`
- Update `AssistantsPlannerOptions` to include `api_version` field
- Update `AssistantsPlanner` to set `api_version`

## Attestation Checklist

- [x] My code follows the style guidelines of this project

- I have checked for/fixed spelling, linting, and other errors
- I have commented my code for clarity
- I have made corresponding changes to the documentation (updating the
doc strings in the code is sufficient)
- My changes generate no new warnings
- I have added tests that validates my changes, and provides sufficient
test coverage. I have tested with:
  - Local testing
  - E2E testing in Teams
- New and existing unit tests pass locally with my changes

---------

Co-authored-by: Corina Gum <>
  • Loading branch information
corinagum authored Dec 12, 2024
1 parent 9292bb8 commit e119b57
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class ClientCitationAppearance
public string Name { get; set; } = string.Empty;

/// <summary>
/// Optional. The citation appreance text. It is ignored in Teams.
/// Optional. The citation appearance text.
/// </summary>
[JsonProperty(PropertyName = "text")]
public string? Text { get; set; }
Expand All @@ -112,10 +112,10 @@ public class ClientCitationAppearance
public string Abstract { get; set; } = string.Empty;

/// <summary>
/// The encoding format used for the icon.
/// Optional. Encoding format of the `citation.appearance.text` field.
/// </summary>
[JsonProperty(PropertyName = "encodingFormat")]
public string EncodingFormat { get; set; } = "text/html";
public string? EncodingFormat { get; set; }

/// <summary>
/// The icon provided in the citation ui.
Expand Down
3 changes: 2 additions & 1 deletion js/packages/teams-ai/src/planners/AssistantsPlanner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ describe('AssistantsPlanner', () => {

const options: AssistantsPlannerOptions = {
apiKey: 'test-key',
assistant_id: 'test-assistant-id'
assistant_id: 'test-assistant-id',
api_version: '2024-02-15'
};

planner = new AssistantsPlanner<TurnState>(options);
Expand Down
6 changes: 6 additions & 0 deletions js/packages/teams-ai/src/planners/AssistantsPlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export interface AssistantsPlannerOptions {
* Defaults to 'conversation.assistants_state'.
*/
assistants_state_variable?: string;

/**
* Optional. Version of the API being called. Default is '2024-02-15-preview'.
*/
api_version?: string;
}

/**
Expand All @@ -92,6 +97,7 @@ export class AssistantsPlanner<TState extends TurnState = TurnState> implements
this._options = {
polling_interval: DEFAULT_POLLING_INTERVAL,
assistants_state_variable: DEFAULT_ASSISTANTS_STATE_VARIABLE,
api_version: '2024-02-15-preview',
...options
};

Expand Down
2 changes: 1 addition & 1 deletion js/packages/teams-ai/src/types/ClientCitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface ClientCitation {
abstract: string;

/**
* Encoding format of the ` citation.appearance.text` field.
* Encoding format of the `citation.appearance.text` field.
*/
encodingFormat?: 'application/vnd.microsoft.card.adaptive';

Expand Down
3 changes: 2 additions & 1 deletion js/samples/04.ai-apps/d.assistants-mathBot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ if (!process.env.ASSISTANT_ID) {
const planner = new AssistantsPlanner({
apiKey: apiKey,
endpoint: endpoint,
assistant_id: process.env.ASSISTANT_ID!
assistant_id: process.env.ASSISTANT_ID!,
api_version: '2024-02-15-preview'
});

// Define storage and application
Expand Down
3 changes: 2 additions & 1 deletion js/samples/04.ai-apps/e.assistants-orderBot/src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ if (!process.env.ASSISTANT_ID) {
const planner = new AssistantsPlanner({
apiKey: apiKey,
endpoint: endpoint,
assistant_id: process.env.ASSISTANT_ID ?? assistantId
assistant_id: process.env.ASSISTANT_ID ?? assistantId,
api_version: '2024-02-15-preview'
});

// Define storage and application
Expand Down
6 changes: 3 additions & 3 deletions python/packages/ai/teams/ai/citations/citations.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ class Appearance(Model):
Attributes:
@type (str): Required; must be 'DigitalDocument'
name (str): The name of the document
text (str): Optional; ignored in Teams
text (str): Optional; the appearance text of the citation.
url (str): The url of the document
abstract (str): Content of the citation. Must be clipped if longer than 480 characters
encodingFormat (str): The encoding format of the citation
image (str): Used for icon; for not it is ignored
encodingFormat (str): Encoding format of the `citation.appearance.text` field.
image (str): Used for icon; for now it is ignored
keywords (list[str]): The optional keywords to the citation
usageInfo (SensitivityUsageInfo): The optional sensitivity content information
"""
Expand Down

0 comments on commit e119b57

Please sign in to comment.