ollama_basic_cha.webm
This is a simple chatbot application that utilizes the Ollama AI platform to provide conversational responses. The chatbot is built using Python and HyperDiv for the user interface.
HyperDiv is a Python library for creating reactive user interfaces in web applications. It allows you to build interactive UI components using a declarative syntax.
Before running the application, ensure you have Python 3.9 or later installed on your system. You also need to install the Ollama package from https://ollama.ai on your chosen platform. And lastly you will need to be running Ollama on either your local machine or another host.
You can install the required Python packages using the following command:
pip install -r requirements.txt
https://github.com/ollama/ollama-python
If you are running ollama on another host or a different port, change this line to reflect the host and port
ollama_url = 'http://localhost:11434'
This environment variable allows setting the host that a Hyperdiv app runs on. The value should be a string representing a valid IP address or hostname, e.g. "0.0.0.0" (default value="localhost").
This environment variable allows setting the port that a Hyperdiv app runs on. The value should be an integer in valid port range, e.g. 8000.
When set to a true value, this environment disables "debug mode" in the internal Tornado server, which normally watches for file changes and auto-reloads the app when a dependent file is modified, and limits logging output.
Setting this environment variable causes all the environment variables in the Development Mode section below to be ignored, regardless of their values.
Works exactly like HD_PRODUCTION but in addition:
It causes run to automatically open a browser tab with the app running in it.
Hyperdiv automatically finds an open port on which to run the app when HD_PORT is left unset. The port search starts and 8988 and goes upward.
This environment variable is meant to be set when shipping apps that users can run locally on their computers. For example, when distributing an app on PyPI.
These environment variables are useful when developing Hyperdiv itself, and may be useful when improving the performance of apps.
When set, this environment variable causes Hyperdiv to log a lot of debugging statements, useful when developing Hyperdiv itself. This output may be inscrutible to developers who aren't working on Hyperdiv itself.
Automatically disabled if HD_PRODUCTION is enabled.
Causes Hyperdiv to log each message sent to the browser. Note that some of these messages can be very large. In particular, when connecting to an app, the entire dom is logged to the console.
Automatically disabled if HD_DEBUG is disabled.
Setting Environment Variables
In bash-like shells, you can set environment variables like this:
export HD_PORT=9000
export HD_PRODUCTION=1
python main.py
Using export will set the environment variable for the rest of the terminal session, or until set again.
You can also set the variable for a single execution of the app, without exporting it to the session.
HD_PORT=9000 HD_PRODUCTION=1 python main.py
In non-bash-like shells, you can use setenv, which works like the export command from bash-like shells:
setenv HD_PORT 9000
setenv HD_PRODUCTION 1
python main.py