# How to Pass the Conversation as Input in the Mistral Instruct Inference API

**URL:** <https://discuss.huggingface.co/t/how-to-pass-the-conversation-as-input-in-the-mistral-instruct-inference-api/58177>\
**Category:** Inference Endpoints on the Hub\
**Created:** [October 11, 2023, 1:53pm UTC](https://discuss.huggingface.co/t/how-to-pass-the-conversation-as-input-in-the-mistral-instruct-inference-api/58177 "2023-10-11T13:53:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![namitgupta](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/namitgupta/32/20254_2.png) [@namitgupta](https://discuss.huggingface.co/u/namitgupta)\
**Post date:** [October 11, 2023, 1:53pm UTC](https://discuss.huggingface.co/t/how-to-pass-the-conversation-as-input-in-the-mistral-instruct-inference-api/58177/1 "2023-10-11T13:53:16Z")

</div>

Here is the curl command which only accepts one input but I need to pass a chat conversation as input in a structure like following -

```auto
Human: {past-message}
AI: {past-reply}
Human: {new-message}

```

Curl command for mistral instruct -

```auto
curl https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.1 \
	-X POST \
	-d '{"inputs": "Can you please let us know more details about your "}' \
	-H 'Content-Type: application/json' \
	-H "Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

```

Is it possible?

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](https://discuss.huggingface.co/u/radames)\
**Post date:** [October 12, 2023, 12:45am UTC](https://discuss.huggingface.co/t/how-to-pass-the-conversation-as-input-in-the-mistral-instruct-inference-api/58177/2 "2023-10-12T00:45:13Z")

</div>

hi @namitgupta ,

If you want to run a chat conversation, you need to build your input string following a [chat template](https://huggingface.co/docs/transformers/chat_templating) for the model.

Here is a simple JavaScript snippet for you, I’m sure you can adapt to use with curl

```js
fetch(
  "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.1",
  {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: "Bearer xxxxxx",
    },
    body: JSON.stringify({
      inputs:
        `<s>[INST] What is your favourite condiment? [/INST]
My favorite condiment is ketchup. It's versatile, tasty, and goes well with a variety of foods.</s>
[INST] And what do you think about it? [/INST]`,
      parameters: { max_new_tokens: 500 },
    }),
  }
)
  .then((response) => response.json())
  .then((data) => console.log(data[0].generated_text));

```

You can see a full Python example using our [InferenceClient](https://huggingface.co/docs/huggingface_hub/package_reference/inference_client#huggingface_hub.InferenceClient.text_generation.example)

> **[app.py · osanseviero/mistral-super-fast at main](https://huggingface.co/spaces/osanseviero/mistral-super-fast/blob/main/app.py)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.

---

<div class="post-metadata">

**Author:** ![namitgupta](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/namitgupta/32/20254_2.png) [@namitgupta](https://discuss.huggingface.co/u/namitgupta)\
**Post date:** [October 12, 2023, 4:47am UTC](https://discuss.huggingface.co/t/how-to-pass-the-conversation-as-input-in-the-mistral-instruct-inference-api/58177/3 "2023-10-12T04:47:51Z")

</div>

Thanks @radames. This works but in response I am getting the prompt as well in the generated text. How to fix this?

`[{"generated_text":"<s>[INST] What is your favourite condiment? [/INST]\nMy favorite condiment is ketchup. It's versatile, tasty, and goes well with a variety of foods.</s>\n[INST] And what do you think about it? [/INST] I think ketchup is a great condiment. It adds a nice tangy flavor to many dishes and can be used in a variety of ways, such as on burgers, fries, and eggs. It's also a popular choice for many people, so it's always nice to have it on hand."}]`

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](https://discuss.huggingface.co/u/radames)\
**Post date:** [October 12, 2023, 5:04am UTC](https://discuss.huggingface.co/t/how-to-pass-the-conversation-as-input-in-the-mistral-instruct-inference-api/58177/4 "2023-10-12T05:04:02Z")

</div>

sorry, yes you can add `return_full_text` to params

`parameters: { max_new_tokens: 100 , return_full_text: false},`

You can see all available parameters here

> **[Detailed parameters](https://huggingface.co/docs/api-inference/detailed_parameters#text-generation-task)**
>
> We’re on a journey to advance and democratize artificial intelligence through open source and open science.
