Skip to content

Commit 114e534

Browse files
authored
Merge branch 'main' into patch-11
2 parents 08e6e81 + 6a324eb commit 114e534

File tree

100 files changed

+14051
-5420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+14051
-5420
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# VSCode settings
2+
.vscode/
3+
14
# Logs
25
logs
36
*.log

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ This documentation is built using [Docusaurus](https://docusaurus.io/).
4444

4545
# How to contribute?
4646

47-
Mistral AI is committed to open source software development and welcomes external contributions. Please head on to our [contribution guideline](https://docs.mistral.ai/guides/contribute/).
47+
Mistral AI is committed to open source software development and welcomes external contributions. Please head on to our [contribution guideline](https://docs.mistral.ai/guides/contribute/overview).

docs/capabilities/agents.md

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
---
2+
id: agents
3+
title: Agents
4+
sidebar_position: 2.91
5+
---
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
9+
10+
## What are AI agents?
11+
12+
AI agents are autonomous systems powered by large language models (LLMs) that, given high-level instructions, can plan, use tools, carry out steps of processing, and take actions to achieve specific goals. These agents leverage advanced natural language processing capabilities to understand and execute complex tasks efficiently and can even collaborate with each other to achieve more sophisticated outcomes.
13+
14+
15+
## Creating Agents
16+
We provide two primary methods for creating agents:
17+
18+
- La Plateforme [Agent builder](https://console.mistral.ai/build/agents/new): Users can use a user-friendly interface provided on La Plateforme to create and configure their agents.
19+
20+
- [Agent API](#the-agent-api): For developers, we offer the Agents API as a programmatic means to use agents. This method is ideal for developers who need to integrate agent creation into their existing workflows or applications.
21+
22+
## La Plateforme agent builder
23+
24+
To start building your own agent, visit https://console.mistral.ai/build/agents/new.
25+
26+
<img src="/img/agent.png" alt="drawing" width="600"/>
27+
28+
Here are the available options for customizing your agent:
29+
- **Model**: The specific model you would like the agent to use. Default is "Mistral Large 2" (`mistral-large-2407`). The other model choices are "Mistral Nemo" (`open-mistral-nemo`), "Codestral" (`codestral-2405`), and your fine-tuned models.
30+
- **Temperature**: What sampling temperature to use, between 0.0 and 1.0. Higher values will make the output more random, while lower values will make it more focused and deterministic.
31+
- **Instructions** (optional): Instructions allows you to enforce a model behavior through all conversations and messages.
32+
- **Demonstrations** (optional): Few-shot learning examples can be added to help guide the agent to understand the specific behavior you want it to exhibit. You can show the model some examples of input and output to improve performance.
33+
- **Deploy**: Once deployed, you will be able to call the Agent via the API with the `agent_id`, but you can also toggle the option to chat with the corresponding Agent on [Le Chat](https://chat.mistral.ai/chat).
34+
35+
36+
## The Agent API
37+
38+
### Create an agent
39+
40+
Coming soon
41+
<!--
42+
<Tabs>
43+
<TabItem value="python" label="python">
44+
45+
```python
46+
TODO
47+
```
48+
</TabItem>
49+
50+
<TabItem value="javascript" label="javascript">
51+
52+
```javascript
53+
TODO
54+
```
55+
</TabItem>
56+
57+
<TabItem value="curl" label="curl" default>
58+
59+
```bash
60+
curl --location "https://api.mistral.ai/v1/agents" \
61+
--header 'Content-Type: application/json' \
62+
--header 'Accept: application/json' \
63+
--header "Authorization: Bearer $MISTRAL_API_KEY" \
64+
--data '{
65+
"name": "French agent",
66+
"model": "mistral-large-latest",
67+
"instructions": "You are a French-speaking virtual agent, designed to answer your questions in French only, no matter the language of the question."
68+
}'
69+
```
70+
</TabItem>
71+
72+
</Tabs> -->
73+
74+
75+
76+
### Use an agent
77+
78+
79+
<Tabs>
80+
<TabItem value="python" label="python" default>
81+
82+
```python
83+
import os
84+
from mistralai import Mistral
85+
86+
api_key = os.environ["MISTRAL_API_KEY"]
87+
88+
client = Mistral(api_key=api_key)
89+
90+
chat_response = client.agents.complete(
91+
agent_id="ag:3996db2b:20240805:french-agent:a8997aab",
92+
messages=[
93+
{
94+
"role": "user",
95+
"content": "What is the best French cheese?",
96+
},
97+
],
98+
)
99+
print(chat_response.choices[0].message.content)
100+
101+
102+
```
103+
</TabItem>
104+
105+
<TabItem value="javascript" label="javascript">
106+
107+
```typescript
108+
import { Mistral } from '@mistralai/mistralai';
109+
110+
const apiKey = process.env.MISTRAL_API_KEY;
111+
112+
const client = new Mistral({apiKey: apiKey});
113+
114+
const chatResponse = await client.agents.complete({
115+
agentId: "ag:3996db2b:20240805:french-agent:a8997aab",
116+
messages: [{role: 'user', content: 'What is the best French cheese?'}],
117+
});
118+
119+
console.log('Chat:', chatResponse.choices[0].message.content);
120+
```
121+
</TabItem>
122+
123+
<TabItem value="curl" label="curl">
124+
125+
```bash
126+
curl --location "https://api.mistral.ai/v1/agents/completions" \
127+
--header 'Content-Type: application/json' \
128+
--header 'Accept: application/json' \
129+
--header "Authorization: Bearer $MISTRAL_API_KEY" \
130+
--data '{
131+
"agent_id": "ag:3996db2b:20240805:french-agent:a8997aab",
132+
"messages": [{"role": "user", "content": "Who is the most renowned French painter?"}]
133+
}'
134+
```
135+
</TabItem>
136+
137+
</Tabs>
138+
139+
:::note[ ]
140+
- Typescript : Please note that storing secrets such as the API key on the client side (`process.env.MISTRAL_API_KEY`) is dangerous and may lead to secret disclosure
141+
:::
142+
143+
<!--
144+
### List/delete agents
145+
146+
<Tabs>
147+
<TabItem value="python" label="python" default>
148+
149+
```python
150+
TODO
151+
```
152+
</TabItem>
153+
154+
<TabItem value="javascript" label="javascript">
155+
156+
```javascript
157+
TODO
158+
```
159+
</TabItem>
160+
161+
<TabItem value="curl" label="curl">
162+
163+
```bash
164+
TODO
165+
```
166+
</TabItem>
167+
168+
</Tabs> -->
169+
170+
## Use Cases
171+
<details>
172+
<summary><b>Use case 1: French agent</b></summary>
173+
174+
You can create an agent that only speaks French. You'll need to set up the agent with specific instructions and use few-shot learning to ensure it understands the requirement to communicate solely in French.
175+
176+
<!-- Here's the sample Python code to create an agent that only speaks French:
177+
178+
```py
179+
TODO
180+
``` -->
181+
182+
Here is an example of how you can create this agent with the La Plateforme [agent builder](https://console.mistral.ai/build/agents/new).
183+
<img src="/img/French_agent.png" alt="drawing" width="600"/>
184+
</details>
185+
186+
<details>
187+
<summary><b>Use case 2: Python agent</b></summary>
188+
189+
You can create an agent that outputs only Python code without any explanations. This is useful when you need to generate code snippets that can be easily copied and pasted, without the additional explanatory text that our model typically provides.
190+
191+
<!-- Here's the sample Python code to create this agent:
192+
193+
```py
194+
TODO
195+
``` -->
196+
197+
Here is an example of how you can create this agent with using the La Plateforme [agent builder](https://console.mistral.ai/build/agents/new).
198+
199+
200+
<img src="/img/Python_agent.png" alt="drawing" width="600"/>
201+
</details>
202+
203+
<details>
204+
<summary><b>Use case 3: Python agent workflow</b></summary>
205+
206+
<img src="/img/agent_demo1.png" alt="drawing" width="600"/>
207+
208+
You can use the Python agent we created in use case 2 in an assistant coding workflow. For example, here is a very simple Python agent workflow with the following steps:
209+
210+
1. User Query:
211+
212+
The process starts when the user submits a query or request to the Python agent.
213+
214+
2. Code and Test Case Generation:
215+
216+
The agent interprets the user's query and generates the corresponding Python code. Alongside the code, the agent creates a test case to verify the functionality of the generated code.
217+
218+
3. Execution and Validation:
219+
220+
The agent attempts to run the generated code to ensure it executes without errors.
221+
The agent then runs the test case to confirm that the code produces the correct output.
222+
223+
4. Retry Mechanism:
224+
225+
If the code fails to run or the test case does not pass, the agent initiates a retry.
226+
It regenerates the code and test case, addressing any issues identified during the previous attempt.
227+
228+
5. Result Output:
229+
230+
Once the code runs successfully and passes the test case, the agent delivers the result to the user.
231+
232+
Check out this [example notebook](https://github.com/mistralai/cookbook/blob/main/mistral/agents/simple_Python_agent_workflow.ipynb) for details.
233+
234+
</details>
235+
236+
<details>
237+
<summary><b>Use case 4: Data analytical multi-agent workflow</b></summary>
238+
239+
<img src="/img/agent_demo2.png" alt="drawing" width="600"/>
240+
241+
You can also leverage multiple agents in a workflow. Here is an example:
242+
243+
1. Data Analysis Planning:
244+
245+
The planning agent writes a comprehensive data analysis plan, outlining the steps required to analyze the data.
246+
247+
2. Code Generation and Execution:
248+
249+
For each step in the analysis plan, the Python agent generates the corresponding code.
250+
The Python agent then executes the generated code to perform the specified analysis.
251+
252+
3. Analysis Report Summarization:
253+
254+
Based on the results of the executed code, the summarization agent writes an analysis report.
255+
The report summarizes the findings and insights derived from the data analysis.
256+
257+
Check out this [example notebook](https://github.com/mistralai/cookbook/blob/main/mistral/agents/analytical_agent_workflow.ipynb) for details.
258+
259+
</details>
260+
261+
262+
<details>
263+
<summary><b>Use case 5: Role-playing Conversation agent</b></summary>
264+
265+
You can also create role-playing conversation agents. For instance, in this [example](https://github.com/mistralai/cookbook/blob/main/mistral/agents/conversation_agent.ipynb), the role-playing conversation workflow generates an entertaining and humorous exchange between two agents mimicking the styles of two stand-up comedians Ali Wong and Jimmy Yang, incorporating jokes and comedic elements to enhance the conversation.
266+
267+
</details>

0 commit comments

Comments
 (0)