Extracting Address with Mistral via Ollama and UiPath - Locally and for Free

Generative AI continues to reshape automation, the ability to run large language models (LLMs) locally opens up new possibilities for cost-efficient, private, and fast automation workflows.

In this post, we’ll walk you through how to:

  • Run Ollama locally with the Mistral model
  • Use API calls to interact with the model
  • Parse addresses and extract structured details 
  • Integrate it with UiPath using HTTP requests and JSON deserialization

Let’s get started!

Step 1: Install Ollama Locally

First, you need to install Ollama, a lightweight tool that allows you to run LLMs on your local machine.

  • Download Ollama from the official site (Ollama supports Windows, macOS, and Linux):
    https://ollama.com/download
Once installed, test your installation in your cmd:
  • Ollama --Version
This will confirm that Ollama is running correctly, you can also check the local host link (http://localhost:11434/):


Add the Mistral Model


Next, we’ll pull the Mistral model, known for its efficiency and strong performance in language tasks.

Run this command in your terminal:

  • ollama pull mistral
Once downloaded, you can run it:
  • ollama run mistral
Ollama runs a local server (usually on http://localhost:11434) to handle API requests.


Define the Address Parsing Task

Our goal is to send natural language address strings to the Mistral model and receive structured JSON responses with fields like:
{
  "street_name": "Champs-Élysées",
  "street_number": "50",
  "postal_code": "75008",
  "city": "Paris",
  "country": "France"
}

Let’s define a sample prompt:

"Extract the street name, street number, postal code, city, and country from the following address and return it as a JSON object:

50 Champs-Élysées, 75008 Paris, France"

 Integrate with UiPath

Now let’s use UiPath to send the request and process the response.


Tools in UiPath:
  • HTTP Request Activity
  • Deserialize JSON Activity
Set up your HTTP Request:
  • Method: POST
  • Endpoint: http://localhost:11434/api/generate
  • Body (JSON):
{
  "model": "mistral",
  "prompt": "Extract the street name, street number, postal code, city, and country from the following address and return it as a JSON object:\n50 Champs-Élysées, 75008 Paris, France"

Deserialize JSON:
Once you receive the response, use Deserialize JSON activity to parse the "response" field.
From there, you can access each value using:
  • jsonObject("street_name").ToString
  • jsonObject("postal_code").ToString



Commentaires