Skip to content

Conversation

@stephentoub
Copy link
Contributor

@stephentoub stephentoub commented Sep 23, 2025

Summary by CodeRabbit

  • New Features
    • Chat now supports system-level instructions: optional instruction text can be added to guide assistant behavior.
    • Improved response consistency and controllability when instructions are provided.
    • Backward compatible: chats without instructions continue to behave the same.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Sep 23, 2025

Walkthrough

Adds a conditional System-role message containing options.Instructions to the chat prompt assembly in HuggingFaceApi.ChatClient, inserted before the Assistant segment when present. No public API signatures or error-handling paths were changed.

Changes

Cohort / File(s) Summary
Prompt construction update
src/libs/HuggingFace/Extensions/HuggingFaceApi.ChatClient.cs
When options.Instructions is provided, prepend a System-role message with that text into the messages list before the Assistant segment; request payload order updated. No API surface changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check prompt assembly logic and message ordering in HuggingFaceApi.ChatClient.cs.
  • Verify tests or callers that construct options handle Instructions as expected.

Poem

I thump my paws—new System note in tow,
A whisper up front, before replies flow.
Prompts line up neat, like carrots in rows,
Guidance first, then the answer grows.
Nose twitch—payload ships, off we go!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding support for ChatOptions.Instructions in the HuggingFaceClient.GetResponseAsync method by including instruction text as a system message.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d6447f and a3cdf9c.

📒 Files selected for processing (1)
  • src/libs/HuggingFace/Extensions/HuggingFaceApi.ChatClient.cs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/libs/HuggingFace/Extensions/HuggingFaceApi.ChatClient.cs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d13088 and 6d6447f.

📒 Files selected for processing (1)
  • src/libs/HuggingFace/Extensions/HuggingFaceApi.ChatClient.cs (1 hunks)
🔇 Additional comments (1)
src/libs/HuggingFace/Extensions/HuggingFaceApi.ChatClient.cs (1)

38-42: Place System instructions before conversation messages (recommended)

ChatOptions.Instructions is provider-dependent; if you want it treated as a top-level System message, move the current block (src/libs/HuggingFace/Extensions/HuggingFaceApi.ChatClient.cs — lines 38–42) to immediately after StringBuilder prompt = new(); or add an explicit ChatMessage with role System to guarantee ordering.

@HavenDV HavenDV merged commit 5edf18e into tryAGI:main Dec 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants