Skip to content

onsaurav/TestOllamaAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestOllamaAPI Workspace

Project Description

TestOllamaAPI is an exploratory, full-stack workspace designed to build and test local LLM chat applications using Ollama. It provides a unified React frontend that can interface with a choice of two fully featured backend APIs: one written in Python (FastAPI) and the other in C# (ASP.NET Core).

The primary goals of this project are to demonstrate how to:

  • Seamlessly connect to a local Ollama service to generate text and handle chat streams.
  • Manage conversational state and chat history.
  • Expose a robust REST API for LLM interactions.
  • Build a responsive web UI to chat with local AI models.

The workspace is divided into three main components: a frontend application built with React, and two different backend implementations for the API layer. This allows developers to experiment with or learn from different tech stacks side-by-side.

Project Structure

  • chat-app/: The frontend React web application.
  • TestOllamaAPI/: The C# ASP.NET Core API implementation.
  • ollama-api-python/: The Python FastAPI implementation.

1. React Web Application (chat-app/)

A modern web client to interface with the Ollama chat APIs.

  • Stack: React 18, Vite, TypeScript
  • Setup & Run:
    cd chat-app
    npm install
    npm run dev
  • Default URL: Usually http://localhost:5173 (Vite's default)

2. Python FastAPI (ollama-api-python/)

A lightweight, fast, and highly concurrent Python backend for managing chat conversations and interfacing with the Ollama service.

  • Stack: Python 3.x, FastAPI, Uvicorn, SQLite
  • Features:
    • Conversation history tracking using SQLite
    • Cross-Origin Resource Sharing (CORS) configured for the web frontend
  • Setup & Run:
    cd ollama-api-python
    python -m venv venv
    # Activate venv:
    # Windows: venv\Scripts\activate
    # Mac/Linux: source venv/bin/activate
    pip install -r requirements.txt
    python main.py
  • Default URL: http://localhost:3003
  • API Documentation: http://localhost:3003/docs (Swagger UI)

3. ASP.NET Core API (TestOllamaAPI/)

An alternative backend implementation built with the robust Microsoft .NET ecosystem.

  • Stack: C#, .NET, ASP.NET Core, Scalar (for API documentation)
  • Features:
    • Strongly-typed services (IOllamaService, IConversationService)
    • Configured CORS for frontend access
  • Setup & Run:
    cd TestOllamaAPI
    dotnet build
    dotnet run
  • Default URLs:
    • HTTPS: https://localhost:7201
    • HTTP: http://localhost:5220
  • API Documentation: https://localhost:7201/scalar/v1 (Scalar API Reference)

Getting Started

  1. Start a Backend: Choose either the Python backend or the ASP.NET backend and follow its setup instructions to start the API server. Ensure Ollama is running on your machine.
  2. Start the Frontend: Navigate to the chat-app directory, install the dependencies, and start the development server.
  3. Chat: Open your browser to the Vite dev server URL and start interacting with your local Ollama models!

About

TestOllamaAPI is a full-stack workspace for building local AI chat apps with Ollama. It includes a React frontend and FastAPI or ASP.NET Core backend, supporting chat streaming, conversation history, REST APIs, and responsive LLM-powered interactions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors