Skip to content

Assistant prefix for kimi k2 #22

Description

@JunityZz
from openai import OpenAI

client = OpenAI(
    api_key="xxx",
    base_url="https://api.moonshot.cn/v1",
)

completion = client.chat.completions.create(
    model="kimi-k2-0711-preview",
    messages=[
        {
            "role": "user",
            "content": "Who are you?",
        },
        {"role": "assistant", "content": "Hi", "partial": True},
    ],
    temperature=0.3,
)

print(completion.choices[0].message.content)
from openai import OpenAI

client = OpenAI(
    api_key="xxx",
    base_url="https://llm.chutes.ai/v1",
)

completion = client.chat.completions.create(
    model="moonshotai/Kimi-K2-Instruct",
    messages=[
        {
            "role": "user",
            "content": "who are you",
        },
        {"role": "assistant", "content": "I am", "partial": True, "prefix": True},
    ],
    temperature=0.3,
)

print(completion.choices[0].message.content)

From the code above, first code I get
Hi! I'm Kimi, your AI assistant and good friend. I'm here to help you with any questions or tasks you have. How can I assist you today?

the second code I get
I’m Kimi, your AI friend from Moonshot AI. How can I assist you today?

Because prefill is not working.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions