Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: How to create an agent for Ollama
description: Learn how to create an agent for the Ollama language model in AI Shell.
ms.date: 12/12/2024
ms.date: 05/16/2025
ms.topic: how-to
---

Expand All @@ -15,21 +15,24 @@ get the desired output or assistance. Agents are implemented as C# classes that
For details about the `AIShell.Abstraction` layer and `AIShell.Kernel`, see the
[AI Shell architecture][05] documentation.

This article is a step-by-step guide to creating an agent for the [Ollama][01] language model. The
purpose of this article is to provide a simple example of how to create an agent. There's a more
robust implementation of the Ollama agent in the [`AIShell.Ollama.Agent`][04] folder of the
repository.

## Prerequisites

- .NET 8 SDK or newer
- PowerShell 7.4.6 or newer

## Steps to create an agent

For this example we create an agent to communicate with the language model `phi3` by utilizing
[Ollama][01], a CLI tool for managing and using locally built LLM/SLMs. The complete source code of
the agent can be found in the [`shell/agents/AIShell.Ollama.Agent`][04] folder of the repository.
the repository.
For this example, we create an agent to communicate with the language model `phi3` using
[Ollama][01]. Ollama is a CLI tool for managing and using locally built LLM/SLMs.

### Step 1: Create a new project

First step is to create a new classlib project.
First step is to create a new **classlib** project.

1. Create a new folder named `OllamaAgent`
1. Run the following command to create a new project:
Expand Down Expand Up @@ -94,8 +97,7 @@ public sealed class OllamaAgent : ILLMAgent

Next, implement the necessary variables and methods of the agent class. The comments provide
descriptions of the members of the **OllamaAgent** class. The `_chatService` member is an instance
of the **OllamaChatService** class. You will implement the **OllamaChatService** class in a later
step.
of the **OllamaChatService** class, which you implement in a later step.

```csharp
public sealed class OllamaAgent : ILLMAgent
Expand Down Expand Up @@ -204,8 +206,8 @@ public sealed class OllamaAgent : ILLMAgent
}
```

For the initial implementation, the agent to returns "Hello World!" to prove that you created the
correct interfaces. You will also add a `try-catch` block to catch and handle any exceptions when
For the initial implementation, the agent to returns "Hello World!", proving that you created the
correct interfaces. You also need to add a `try-catch` block to catch and handle any exceptions when
the user tries to cancel the operation.

Add the following code to your `Chat` method.
Expand Down Expand Up @@ -267,7 +269,7 @@ Before you can use the Ollama API, you need to create classes that send input to
responses from the Ollama API. The following [Ollama example][02] shows the format of the input and
the response from the agent.

For this example we call the Ollama API with streaming disabled. Ollama generates a single, fixed
This example calls the Ollama API with streaming disabled. Ollama generates a single, fixed
response. In the future, you could add streaming capabilities so that responses could be rendered in
real time, as the agent receives them.

Expand Down Expand Up @@ -465,7 +467,7 @@ This command builds all necessary packages in the `\bin\Debug\net8.0` folder of
To have `aish` load the agent, you need to copy the `.dll` files to a folder in the `Agents` folder.
The folder name should be the same as the agent name.

There are two location where you can install agents:
You can install agents in one of two locations:

- In the `Agents` folder under the location where you installed `aish.exe`. The
[install script][08] for AI Shell installs in `%LOCALAPPDATA%\Programs\AIShell`. Create the
Expand All @@ -488,10 +490,11 @@ Please select an agent to use:

## How can I share my own agent?

Currently there is no way to share your agents in a centralized repository. We suggest forking this
repository for development of your own agent. You can share a link your fork in the `Agent Sharing`
section of the [Discussions][03] tab of this repository. To use an agent, if you put its `dll` files
in the `agents` folder of the base directory of `aish.exe`, the agent will be loaded by `aish`.
There's no way to share your agents in a centralized repository. We suggest forking this repository
for development of your own agent. You can share a link your fork in the `Agent Sharing` section of
the [Discussions][03] tab of this repository. To use an agent, put agent `dll` files in the `agents`
folder of the base directory of `aish.exe`. AI Shell automatically loads the agents from that
folder.

<!-- link references -->
[01]: https://github.com/ollama/ollama
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ You can also use this example code as a template to create your own agent.

- Install [Ollama][01]
- Install a [Ollama model][02], we
suggest using the `phi3` model as it is set as the default model in the code
suggest using the `phi3` model as it's set as the default model in the code
- [Start the Ollama API server][03]

## Configuration
Expand All @@ -35,8 +35,6 @@ There is an updated version of the Ollama agent available in the AI Shell reposi
queries
- Streaming is currently not supported if you change the stream value to `true` in the data to send
to the API it will not work
- Configuration is currently hard coded in the code and will be moved to a configuration file in the
future

<!-- link references -->
[01]: https://github.com/ollama/ollama
Expand Down
46 changes: 32 additions & 14 deletions reference/docs-conceptual/AIShell/how-to/agent-openai.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: OpenAI agent README
description: Learn how to use the OpenAI agent in AI Shell.
ms.date: 03/03/2025
ms.date: 05/16/2025
ms.topic: how-to
---
# OpenAI agent
Expand All @@ -23,9 +23,14 @@ recommend using an Azure OpenAI deployment for enhanced security and privacy.

## Configuration

Before getting started you need to configure the agent with the details of your OpenAI details. To
configure the agent, run `/agent config openai-gpt` to open up the setting file in your default
editor. Update the file based on the following example:
Before getting started, you need to configure the agent with the details of your OpenAI
implementation. To configure the agent, use the `/agent config openai-gpt` command to open
configuration file in your default editor.

- Azure OpenAI requires the `endpoint`, `deployment` name, and the `model` name.
- Public OpenAI only requires the `model` name. No endpoint, no deployment name.

Update the file based on the following example:

```jsonc
{
Expand Down Expand Up @@ -68,7 +73,7 @@ editor. Update the file based on the following example:
```

> [!NOTE]
> The endpoint for the Azure OpenAI configuration does not need a full endpoint including the
> The endpoint for the Azure OpenAI configuration doesn't need a full endpoint including the
> deployment, for example you can just use the following endpoint format,
> `https://<YourServiceName>.openai.azure.com`.

Expand All @@ -85,8 +90,8 @@ select different OpenAI models for each GPT as required.

The command `/gpt` is provided to make it easy to manage the GPTs.

- Run `/gpt use <gpt-name>` to switch to another GPT instance, or run `/gpt use` to simply choose
from the available ones.
- Run `/gpt use <gpt-name>` to switch to another GPT instance, or run `/gpt use` to choose from the
available ones.
- Run `/gpt list <gpt-name>` to view the details of a GPT definition, or run `/gpt list` to list all
available GPTs.

Expand All @@ -108,10 +113,10 @@ Commands:

## Support for other OpenAI-compatible models

With the release of AI Shell v1.0.0-preview.2, the `openai-gpt` agent extends support to third party
With the release of AI Shell v1.0.0-preview.2, the `openai-gpt` agent extends support to third-party
models that follow the OpenAI API specifications, allowing for a more flexible AI experience. Many
of these models are open source tools for running SLMs and LLMs locally. The `openai-gpt` agent nows
supports the following additional models:
of these models are open source tools for running SLMs and LLMs locally. The `openai-gpt` agent now
supports the following models:

- [**Ollama**][08]
- [**LM Studio**][06]
Expand All @@ -120,10 +125,23 @@ supports the following additional models:
- [**Google Gemini**][02]
- [**Grok**][05]

To use these models, you only need to configure the `endpoint`, `key` and `model name` in the agent
config file. The following `openai.agents.config` file contains example configurations for two of
the new AI providers. For more information about endpoints and model names, see to the documentation
for the specific model.
To use these models, you only need to configure the `endpoint`, `key`, and `model` name in the agent
configuration file. The following `openai.agents.config` file contains example configurations for
two of the new AI providers. For more information about endpoints and model names, see the
documentation for the specific model.

With the release of AI Shell v1.0.0-preview.4, the `openai-gpt` agent supports the following
models names:

- `o1`
- `o3`
- `o4-mini`
- `gpt-4.1`
- `gpt-4o`
- `gpt-4`
- `gpt-4-32k`
- `gpt-4-turbo`
- `gpt-3.5-turbo`

<!-- link references -->
[01]: /azure/ai-services/openai/how-to/create-resource?pivots=web-portal
Expand Down
92 changes: 62 additions & 30 deletions reference/docs-conceptual/AIShell/how-to/aishell-reference.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: AI Shell command reference
description: Learn about the command-line options and commands available in AI Shell.
ms.date: 10/29/2024
ms.date: 05/16/2025
ms.topic: reference
---
# AI Shell command reference
Expand Down Expand Up @@ -33,21 +33,35 @@ By default, `aish` provides a base set of chat commands used to interact with th
list of commands, use the `/help` command in the chat session.

```
Name Description Source
──────────────────────────────────────────────────────────────────────
/agent Command for agent management. Core
/cls Clear the screen. Core
/code Command to interact with the code generated. Core
/dislike Dislike the last response and send feedback. Core
/exit Exit the interactive session. Core
/help Show all available commands. Core
/like Like the last response and send feedback. Core
/refresh Refresh the chat session. Core
/render Render a markdown file, for diagnosis purpose. Core
/retry Regenerate a new response for the last query. Core
Name Description Source
─────────────────────────────────────────────────────────────────────────────────────
/agent Command for agent management. Core
/clear Clear the screen. Core
/code Command to interact with the code generated. Core
/dislike Dislike the last response and send feedback. Core
/exit Exit the interactive session. Core
/help Show all available commands. Core
/like Like the last response and send feedback. Core
/refresh Start a new chat session. Core
/retry Regenerate a new response for the last query. Core
```

## `/agent` sub commands
## `/agent`

Command for agent management.

```
agent [command] [options]
```

Options: -h, --help Show help and usage information

Subcommands

- `config <azure|openai-gpt>` - Open up the setting file for an agent. When no agent is specified,
target the active agent.
- `list` - List all available agents.
- `use <azure|openai-gpt>` - Specify an agent to use, or choose one from the available agents.

### `/agent config`

Expand All @@ -62,7 +76,6 @@ Arguments: `<azure|openai-gpt>` Name of an agent.
Options:

- `--editor <editor>` The editor to open the setting file in.
- `-h`, `--help` Show help and usage information

Example:

Expand All @@ -74,10 +87,6 @@ Example:

List all available agents.

Options:

- `-h`, `--help` Show help and usage information

Example:

```
Expand All @@ -99,14 +108,41 @@ Example:
2. Define the GPT(s). See details at
https://aka.ms/aish/openai
3. Run '/refresh' to apply the new settings.
azure (active) This AI assistant can generate Azure CLI and
Azure PowerShell commands for managing
Azure resources, answer questions, and provides
information tailored to your specific Azure
environment.
azure This AI assistant connects you to the Copilot in
Azure and can generate Azure CLI and Azure
PowerShell commands for managing Azure resources
and answer questions about Azure.
```

### `/agent use`

Specify an agent to use, or choose one from the available agents.

```
agent use [<agent>] [options]
```

Arguments: `<azure|openai-gpt>` - Name of an agent.

## `/clear`

Clears the screen. You can also use the alias `/cls`.

## `/code`

Command to interact with the code generated.

```
code [command] [options]
```

Subcommands:

## `/code` sub commands
- `copy <n>` Copy the n-th (1-based) code snippet to clipboard. Copy all the code when `<n>` isn't
specified. [default: -1]
- `save <file>` - Save all the code to a file.
- `post <n>` - Post the n-th (1-based) code snippet to the connected command-line shell. Post all
the code when `<n>` isn't specified. [default: -1]

### `/code copy`

Expand All @@ -121,11 +157,7 @@ code copy [<n>] [options]
Arguments:

- `<n>` Use the n-th (1-based) code snippet. Use all the code when no value is specified.
[default: -1]

Options:

- `-h`, `--help` Show help and usage information
[default: -1]

Examples

Expand Down
14 changes: 10 additions & 4 deletions reference/docs-conceptual/AIShell/install-aishell.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,23 @@ AI Shell is supported on the following platforms:
- Windows 10 or higher
- PowerShell 7.4.6 or higher
- Windows Terminal
- PSReadLine v2.4.2-beta2 or higher

### [macOS](#tab/macos)

- macOS v13 Ventura or higher
- PowerShell 7.4.6 or higher
- iTerm2 preferred (no split-screen experience)
- Default macOS Terminal app for the standalone experience
- iTerm2 required to use the split-screen experience
- Python 3.11 or higher required to support iTerm2
- Must enable **Python APIs** in the iTerm2 settings
- PSReadLine v2.4.2-beta2 or higher

### [Linux](#tab/linux)

- Ubuntu 20.04 or higher
- PowerShell 7.4 or higher (recommended)
- PowerShell 7.4.6 or higher
- PSReadLine v2.4.2-beta2 or higher
- Any terminal emulator supported by the OS (no split-screen experience)

> [!NOTE]
Expand All @@ -55,8 +61,8 @@ On Windows, this script:

On macOS, this script:

- Installs the `aish` executable to `/usr/local/AIShell`
- Due to some limitations, the **AIShell** module is not installed
- Installs the `aish` executable to `/usr/local/AIShell` and creates a symbolic link to
`/usr/local/bin/aish`.

> [!NOTE]
> This script only works on Windows and Mac systems. Linux users need to follow the manual
Expand Down
Loading