Skip to content

Custom Role Name support #394

Open
Open
@ozgur-yalcin

Description

@ozgur-yalcin

Service

OpenAI

Describe the bug

curl -v --location "https://api.mistral.ai/v1/chat/completions" \ --header "Authorization: Bearer $MISTRAL_API_KEY" \ --header "Content-Type: application/json" \ --data '{ "model": "mistral-large-latest", "messages": [ { "role": "User", "content": "Merhaba" } ] }' * Host api.mistral.ai:443 was resolved. * IPv6: (none) * IPv4: 104.18.22.152, 104.18.23.152 * Trying 104.18.22.152:443... * Connected to api.mistral.ai (104.18.22.152) port 443 * ALPN: curl offers h2,http/1.1 * TLSv1.3 (OUT), TLS handshake, Client hello (1): * CAfile: /opt/anaconda3/ssl/cacert.pem * CApath: none * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519 / id-ecPublicKey * ALPN: server accepted h2 * Server certificate: * subject: CN=api.mistral.ai * start date: Mar 9 02:33:22 2025 GMT * expire date: Jun 7 03:33:21 2025 GMT * subjectAltName: host "api.mistral.ai" matched cert's "api.mistral.ai" * issuer: C=US; O=Google Trust Services; CN=WE1 * SSL certificate verify ok. * Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA256 * Certificate level 1: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA384 * Certificate level 2: Public key type EC/secp384r1 (384/192 Bits/secBits), signed using ecdsa-with-SHA384 * using HTTP/2 * [HTTP/2] [1] OPENED stream for https://api.mistral.ai/v1/chat/completions * [HTTP/2] [1] [:method: POST] * [HTTP/2] [1] [:scheme: https] * [HTTP/2] [1] [:authority: api.mistral.ai] * [HTTP/2] [1] [:path: /v1/chat/completions] * [HTTP/2] [1] [user-agent: curl/8.9.1] * [HTTP/2] [1] [accept: */*] * [HTTP/2] [1] [authorization: Bearer $MISTRAL_API_KEY] * [HTTP/2] [1] [content-type: application/json] * [HTTP/2] [1] [content-length: 134] > POST /v1/chat/completions HTTP/2 > Host: api.mistral.ai > User-Agent: curl/8.9.1 > Accept: */* > Authorization: Bearer $MISTRAL_API_KEY > Content-Type: application/json > Content-Length: 134 > * upload completely sent off: 134 bytes * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): < HTTP/2 422 < date: Wed, 26 Mar 2025 13:32:55 GMT < content-type: application/json < content-length: 464 < ratelimitbysize-query-cost: 32001 < ratelimitbysize-limit: 500000 < x-ratelimitbysize-limit-month: 1000000000 < x-ratelimitbysize-remaining-month: 999967999 < ratelimitbysize-reset: 5 < x-ratelimitbysize-limit-minute: 500000 < x-ratelimitbysize-remaining-minute: 467999 < ratelimitbysize-remaining: 467999 < x-envoy-upstream-service-time: 4 < access-control-allow-origin: * < x-kong-upstream-latency: 4 < x-kong-proxy-latency: 6 < x-kong-request-id: 3658e2145174f8454533073c7004bc28 < cf-cache-status: DYNAMIC < set-cookie: __cf_bm=0s_i_nZR8tzptGqAN.OSHoKIieFXoKjRPSCVATgxnyo-1742995975-1.0.1.1-4g638dE7G1uV.AnGzci9brVI8aTc8EakbgXQHZhm3YD5.lZVBP2uXK5OgGyYAHMJQvmSpUBi27hLguSeGL95LrGXkWXh3bx8OS1PebPXP38; path=/; expires=Wed, 26-Mar-25 14:02:55 GMT; domain=.mistral.ai; HttpOnly; Secure; SameSite=None < server: cloudflare < cf-ray: 9267044c2c9e0638-CDG < alt-svc: h3=":443"; ma=86400 < * Connection #0 to host api.mistral.ai left intact {"detail":[{"type":"union_tag_invalid","loc":["body","messages",0],"msg":"Input tag 'User' found using 'role' does not match any of the expected tags: <Roles.system: 'system'>, <Roles.user: 'user'>, <Roles.assistant: 'assistant'>, <Roles.tool: 'tool'>","input":{"role":"User","content":"Merhaba"},"ctx":{"discriminator":"'role'","tag":"User","expected_tags":"<Roles.system: 'system'>, <Roles.user: 'user'>, <Roles.assistant: 'assistant'>, <Roles.tool: 'tool'>"}}]}% 

Steps to reproduce

curl -v --location "https://api.mistral.ai/v1/chat/completions" \ --header "Authorization: Bearer $MISTRAL_API_KEY" \ --header "Content-Type: application/json" \ --data '{ "model": "mistral-large-latest", "messages": [ { "role": "user", "content": "Merhaba" } ] }' * Host api.mistral.ai:443 was resolved. * IPv6: (none) * IPv4: 104.18.23.152, 104.18.22.152 * Trying 104.18.23.152:443... * Connected to api.mistral.ai (104.18.23.152) port 443 * ALPN: curl offers h2,http/1.1 * TLSv1.3 (OUT), TLS handshake, Client hello (1): * CAfile: /opt/anaconda3/ssl/cacert.pem * CApath: none * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / X25519 / id-ecPublicKey * ALPN: server accepted h2 * Server certificate: * subject: CN=api.mistral.ai * start date: Mar 9 02:33:22 2025 GMT * expire date: Jun 7 03:33:21 2025 GMT * subjectAltName: host "api.mistral.ai" matched cert's "api.mistral.ai" * issuer: C=US; O=Google Trust Services; CN=WE1 * SSL certificate verify ok. * Certificate level 0: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA256 * Certificate level 1: Public key type EC/prime256v1 (256/128 Bits/secBits), signed using ecdsa-with-SHA384 * Certificate level 2: Public key type EC/secp384r1 (384/192 Bits/secBits), signed using ecdsa-with-SHA384 * using HTTP/2 * [HTTP/2] [1] OPENED stream for https://api.mistral.ai/v1/chat/completions * [HTTP/2] [1] [:method: POST] * [HTTP/2] [1] [:scheme: https] * [HTTP/2] [1] [:authority: api.mistral.ai] * [HTTP/2] [1] [:path: /v1/chat/completions] * [HTTP/2] [1] [user-agent: curl/8.9.1] * [HTTP/2] [1] [accept: */*] * [HTTP/2] [1] [authorization: Bearer $MISTRAL_API_KEY] * [HTTP/2] [1] [content-type: application/json] * [HTTP/2] [1] [content-length: 134] > POST /v1/chat/completions HTTP/2 > Host: api.mistral.ai > User-Agent: curl/8.9.1 > Accept: */* > Authorization: Bearer $MISTRAL_API_KEY > Content-Type: application/json > Content-Length: 134 > * upload completely sent off: 134 bytes * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): < HTTP/2 200 < date: Wed, 26 Mar 2025 13:32:50 GMT < content-type: application/json < content-length: 336 < ratelimitbysize-query-cost: 32001 < ratelimitbysize-reset: 11 < x-ratelimitbysize-limit-minute: 500000 < x-ratelimitbysize-remaining-minute: 467999 < ratelimitbysize-limit: 500000 < x-ratelimitbysize-limit-month: 1000000000 < x-ratelimitbysize-remaining-month: 999967999 < ratelimitbysize-remaining: 467999 < x-envoy-upstream-service-time: 521 < access-control-allow-origin: * < x-kong-upstream-latency: 522 < x-kong-proxy-latency: 8 < x-kong-request-id: 3b35707db531013f718ff538102e1223 < cf-cache-status: DYNAMIC < set-cookie: __cf_bm=OgS8M7UcZU.EuNdG1dsj9kkjGXsSRBbI40BIPOMY6F0-1742995970-1.0.1.1-IS__tVVxAKRbaYWFKh1MPvHk5LPw0HT9P.apt.nIEJTZbs8LdggFjY0mn84jSfP04bfK2qMvBBvLU47R6wKBqhJjFEi3j1jZCG6A01dov5Y; path=/; expires=Wed, 26-Mar-25 14:02:50 GMT; domain=.mistral.ai; HttpOnly; Secure; SameSite=None < server: cloudflare < cf-ray: 92670428d986d151-CDG < alt-svc: h3=":443"; ma=86400 < * Connection #0 to host api.mistral.ai left intact {"id":"f96633569843443baf81fce524ab3699","object":"chat.completion","created":1742995969,"model":"mistral-large-latest","choices":[{"index":0,"message":{"role":"assistant","tool_calls":null,"content":"Merhaba! Nasıl yardımcı olabilirim?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":6,"total_tokens":22,"completion_tokens":16}} 

Code snippets

There are SystemChatMessage, AssistantChatMessage, UserChatMessage etc. but non-standard role names can be used as in the mistral ai example. I need a class named like CustomChatMessage and we can define custom role name as string

OS

macOS

.NET version

8

Library version

2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-author-feedbackWorkflow: More information is needed from author to address the issue.questionCategory: The issue is seeking information about the library or its usage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions