An open API service indexing awesome lists of open source software.

https://github.com/hakdogan/financial-agent

This is a financial AI agent that utilizes function calling to invoke application-specific methods in response to user prompts.
https://github.com/hakdogan/financial-agent

ai-agents langchain ollama quarkus

Last synced: 2 months ago
JSON representation

This is a financial AI agent that utilizes function calling to invoke application-specific methods in response to user prompts.

Awesome Lists containing this project

README

          

# financial-agent

`financial-agent` is an AI-powered financial assistant built with [Quarkus's](https://quarkus.io/), [Ollama](https://ollama.com/) and [LangChain4j](https://github.com/langchain4j/langchain4j) extensions.
It leverages **function calling** to query real-time stock, currency, and precious metal prices from external APIs.

## ✨ Features

- 💱 **Exchange Rates**: Fetches real-time stock and currency exchange rates using the [Alpha Vantage API](https://www.alphavantage.co/).
- 🪙 **Precious Metals Prices**: Retrieves current metal prices (gold, silver, etc.) using the [GoldAPI](https://www.goldapi.io/).
- 🧠 **LLM-powered reasoning**: Uses [Ollama](https://ollama.com/) and [LangChain](https://www.langchain.com/) for intelligent prompt interpretation and function calling.
- 🐳 **Automatic Ollama Integration**: If Docker or Podman is available, the Ollama instance is automatically launched by Quarkus during dev mode.

## 🚀 Getting Started

### Prerequisites

- JDK 17+
- Maven 3.8+
- Docker or Podman (for automatic Ollama instance startup)
- Alpha Vantage and GoldAPI API keys

### Run in development mode
You can start the application with your API keys as system properties:
```bash
mvn -DEXCHANGE_API_KEY=your_alpha_vantage_key -DMETAL_API_KEY=your_goldapi_key quarkus:dev
```

> ℹ️ During startup, if Docker or Podman is available, Quarkus will automatically launch an Ollama container.

### 🐳 Run with Docker Compose
You can also run the application and Ollama together using Docker Compose.

1. Set your API keys
Create a `.env` file in the project root:

```bash
EXCHANGE_API_KEY=your_alpha_vantage_key
METAL_API_KEY=your_goldapi_key
```

2. Build the JAR
```bash
mvn clean package -DskipTests
```
3. Start with Docker Compose
```bash
docker-compose up --build
```
This will:

- Start an Ollama container and automatically download the llama3:2 model.
- Start your Quarkus-based financial agent service.
- Connect both services in the same Docker network.

## 🛠️ Configuration
| Property | Description | Example |
|----------------|----------------------------|-----------------------------|
| EXCHANGE_API_KEY | API key for Alpha Vantage | ABC123XYZ |
| METAL_API_KEY | API key for GoldAPI | goldapi-xxxxxxxx-xxxx-xxxx |
| OLLAMA_BASE_URL | Base URL for Ollama service (optional) | http://ollama:11434 |

### Example Prompts

```bash
http GET "http://localhost:10001/api/v1/exchange/1 dolar kaç Türk lirası?"

1 dolar 40.24630000 Türk lirasıdır. Güncellenme tarihi: 2025-07-16 13:54:11.

http GET "http://localhost:10001/api/v1/exchange/Altının ons fiyatı ne kadar?"

Altının (XAU) ons fiyatı şu anda 3323.72 USD'dir.

http GET "http://localhost:10001/api/v1/exchange/Apple güncel fiyatı nedir?"

Apple'ın (AAPL) güncel fiyatı 211,18 USD'dir.
```

### A2A Support

[A2A](https://developers.googleblog.com/en/a2a-a-new-era-of-agent-interoperability/) is an open protocol that provides a standard way for agents to collaborate with each other, regardless of the underlying framework or vendor.

In this example, the Financial Assistant exposes its capabilities to the outside, depending on the A2A protocol.

When the application is running, and you visit the [agent-card.json](http://localhost:10001/.well-known/agent-card.json) link, you should get an output similar to the one below.

```json
{
"name": "Financial Assistant Agent",
"description": "Provides financial information",
"url": "http://localhost:10001",
"version": "1.0.0",
"capabilities": {
"streaming": true,
"pushNotifications": false,
"stateTransitionHistory": false
},
"defaultInputModes": [
"text"
],
"defaultOutputModes": [
"text"
],
"skills": [
{
"id": "financial_assistant",
"name": "Financial Assistant",
"description": "Provides real-time stock prices, exchange rates, and precious metals pricing.",
"tags": [
"financial"
],
"examples": [
"What is the current dollar-TL exchange rate?",
"What is the price of gold per ounce?",
"How many dollars is a Tesla?"
]
}
],
"supportsAuthenticatedExtendedCard": false,
"additionalInterfaces": [
{
"transport": "JSONRPC",
"url": "http://localhost:10001"
}
],
"preferredTransport": "JSONRPC",
"protocolVersion": "0.3.0.Alpha1"
}
```