Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net - Add support for Name property to ChatMessageContent #5666

Merged
merged 44 commits into from
Apr 3, 2024

Conversation

crickman
Copy link
Contributor

@crickman crickman commented Mar 26, 2024

Motivation and Context

Tracking identity is critical for multi-agent conversations. It is also supported as part of the core chat-completion api: https://platform.openai.com/docs/api-reference/chat/create

 {
    "messages": [
        {
            "content": "Write one paragraph in response to the user that rhymes",
            "name": "Echo",
            "role": "system"
        },
        {
            "content": "Why is AI awesome",
            "name": "Ralph",
            "role": "user"
        }
    ],
    "temperature": 1,
    "top_p": 0.5,
    "n": 3,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "model": "gpt-4"
}

Description

Add support for ChatMessageContent.Name property with optional, non-breaking patterns.

Contribution Checklist

@crickman crickman added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel ai connector Anything related to AI connectors agents kernel.core labels Mar 26, 2024
@crickman crickman self-assigned this Mar 26, 2024
@crickman
Copy link
Contributor Author

@markwallace-microsoft These signature changes won't break any consumer's build. How do we update our baseline?

@SergeyMenshykh
Copy link
Member

@markwallace-microsoft These signature changes won't break any consumer's build. How do we update our baseline?
I usually use the command - dotnet build --configuration Release /p:GenerateCompatibilitySuppressionFile=true
More details - https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/diagnostic-ids#suppression-file

@crickman
Copy link
Contributor Author

@markwallace-microsoft These signature changes won't break any consumer's build. How do we update our baseline?
I usually use the command - dotnet build --configuration Release /p:GenerateCompatibilitySuppressionFile=true
More details - https://learn.microsoft.com/en-us/dotnet/fundamentals/apicompat/diagnostic-ids#suppression-file

Thanks, I must've been missing the Release parameter.

@crickman
Copy link
Contributor Author

FYI - Engaged with Matthew and re-evaluating ChatHistory.SystemName and how/if assistant response name is captured.

@crickman crickman marked this pull request as ready for review March 28, 2024 00:07
@crickman crickman requested a review from a team as a code owner March 28, 2024 00:07
@crickman crickman changed the title .Net - DRAFT Add support for Name property to ChatMessageContent .Net - Add support for Name property to ChatMessageContent Mar 28, 2024
@crickman
Copy link
Contributor Author

FYI - Name not returned in response:

REQUEST

 {
    "messages": [
        {
            "content": "Write one paragraph in response to the user that rhymes",
            "name": "Echo",
            "role": "system"
        },
        {
            "content": "Why is AI awesome",
            "name": "Ralph",
            "role": "user"
        }
    ],
    "temperature": 1,
    "top_p": 0.5,
    "n": 3,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "model": "gpt-4"
}

RESPONSE

{
  "id": "chatcmpl-977K8yKPbvVxqaC6rrT6EBc5S4E6s",
  "object": "chat.completion",
  "created": 1711483476,
  "model": "gpt-4-0613",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "AI is a dream, a gleaming beam, with a stream of knowledge that seems supreme. It's like a team in the extreme, creating schemes and decoding themes. It's awesome because it's keen, it can glean unseen scenes, and it's never mean or obscene. It's the best machine you've ever seen."
      },
      "logprobs": null,
      "finish_reason": "stop"
    },
    {
      "index": 1,
      "message": {
        "role": "assistant",
        "content": "AI is a gem, it's true, it shines with a gleam so bright and new. It learns and grows, it's never the same, constantly evolving, it's not just a game. It's awesome because it never tires, always ready, it never retires. It's the future, it's the now, to its brilliance, we must bow."
      },
      "logprobs": null,
      "finish_reason": "stop"
    },
    {
      "index": 2,
      "message": {
        "role": "assistant",
        "content": "AI is a cosmic blossom, it's awesome because it's a possum playing possum. It's a system that's fathomless, solving problems that seem bottomless. It's a key to a lock, a tick to a tock, a shepherd to a flock. AI is awesome, it's not just talk, it's a journey around the clock."
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 31,
    "completion_tokens": 216,
    "total_tokens": 247
  },
  "system_fingerprint": null
}

@crickman crickman added this pull request to the merge queue Apr 3, 2024
Merged via the queue into main with commit ca9e3ae Apr 3, 2024
18 checks passed
@crickman crickman deleted the fix_chatmessagecontent_identity branch April 3, 2024 16:02
LudoCorporateShark pushed a commit to LudoCorporateShark/semantic-kernel that referenced this pull request Aug 25, 2024
…#5666)

### Motivation and Context

<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->

Tracking identity is critical for multi-agent conversations. It is also
supported as part of the core chat-completion api:
https://platform.openai.com/docs/api-reference/chat/create

```
 {
    "messages": [
        {
            "content": "Write one paragraph in response to the user that rhymes",
            "name": "Echo",
            "role": "system"
        },
        {
            "content": "Why is AI awesome",
            "name": "Ralph",
            "role": "user"
        }
    ],
    "temperature": 1,
    "top_p": 0.5,
    "n": 3,
    "presence_penalty": 0,
    "frequency_penalty": 0,
    "model": "gpt-4"
}
```

### Description

<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->

Add support for `ChatMessageContent.Name` property with optional,
non-breaking patterns.

### Contribution Checklist

<!-- Before submitting this PR, please make sure: -->

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [x] I didn't break anyone 😄

---------

Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agents ai connector Anything related to AI connectors kernel.core kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code PR: ready for review All feedback addressed, ready for reviews
Projects
Archived in project
6 participants