Skip to content

feat: add system message support for Anthropic provider#25

Merged
akshaydeo merged 1 commit into04-16-feat_readmefrom
04-27-feat_fixes_and_optimisations
Apr 30, 2025
Merged

feat: add system message support for Anthropic provider#25
akshaydeo merged 1 commit into04-16-feat_readmefrom
04-27-feat_fixes_and_optimisations

Conversation

@Pratham-Mishra04
Copy link
Copy Markdown
Collaborator

Add support for system messages in Anthropic provider

This PR adds support for system messages in the Anthropic provider by properly handling system role messages in the chat completion API. System messages are now extracted from the input messages array and combined into a single system message in the Anthropic API request.

Key changes:

  • Extract system messages from the input and add them to the Anthropic request's "system" field
  • Skip system messages when formatting regular messages to avoid duplication
  • Join multiple system messages with spaces when more than one is provided
  • Make the ParallelToolCalls field in ModelParameters properly omitempty
  • Add Enum field to FunctionParameters for better function calling support
  • Update test configuration to use Claude 3.7 Sonnet for tool calls testing

This change enables proper handling of system prompts with Anthropic models, which is important for setting context and controlling model behavior.

Copy link
Copy Markdown
Collaborator Author

Pratham-Mishra04 commented Apr 27, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Pratham-Mishra04 Pratham-Mishra04 mentioned this pull request Apr 27, 2025
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-27-feat_fixes_and_optimisations branch 2 times, most recently from 81b2cc0 to e8a891c Compare April 27, 2025 13:38
Comment thread core/tests/tests.go Outdated
for i, choice := range result.Choices {
if choice.Message.ToolCalls != nil && len(*choice.Message.ToolCalls) > 0 {
toolCall := *choice.Message.ToolCalls
fmt.Printf("\n🐒 %s Tool Call Result %d (Choice %d): %s\n", config.Provider, index+1, i+1, toolCall[0].Function.Arguments)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove all these from the codebase - fmt.Printf is an expensive line

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

its only there in the test files so do we need to remove it? cause anyway it is not interfering with the core working

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

use log.Println

Copy link
Copy Markdown
Contributor

@akshaydeo akshaydeo left a comment

Choose a reason for hiding this comment

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

added one comment

@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-27-feat_fixes_and_optimisations branch from e8a891c to 380f868 Compare April 28, 2025 05:54
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-27-feat_fixes_and_optimisations branch 2 times, most recently from 64bce76 to 1520f38 Compare April 28, 2025 06:15
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-16-feat_readme branch 2 times, most recently from 6727e2e to fa3c0b1 Compare April 28, 2025 06:16
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-27-feat_fixes_and_optimisations branch from 1520f38 to 180a91a Compare April 28, 2025 06:16
@Pratham-Mishra04 Pratham-Mishra04 marked this pull request as ready for review April 30, 2025 04:45
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-27-feat_fixes_and_optimisations branch from 180a91a to 55a5a8e Compare April 30, 2025 05:21
@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 04-27-feat_fixes_and_optimisations branch from 55a5a8e to 54176d6 Compare April 30, 2025 05:27
@akshaydeo akshaydeo merged commit 7cb192b into 04-16-feat_readme Apr 30, 2025
1 check passed
@Pratham-Mishra04 Pratham-Mishra04 deleted the 04-27-feat_fixes_and_optimisations branch May 6, 2025 04:33
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