Try Ansari now at ansari.chat!
Ansari is an experimental open source project that explores the application of large language models in helping Muslims improve their practice of Islam and non-Muslims develop an accurate understanding of the teachings of Islam.
It is not always correct and can get things wrong. The list below includes some of the issues we’ve seen in working with Ansari.
It uses carefully crafted prompts and several sources accessed through retrieval augmented generation.
A complete list of what Ansari can do can be found here.
Ansari will quite comfortably run on your local machine -- almost all heavy lifting is done using other services. The only complexities are it needs a lot of environment variables to be set and you need to run postgres.
You can also run it on Heroku and you can use the Procfile and runtime.txt filed to deploy it directly on Heroku.
Follow the instructions here to install postgres.
Do a % python -V
to checck that you have python 3 installed. If you get an error or the version starts with a 2, follow the instructions here.
% git clone git@github.com:waleedkadous/ansari-backend.git
% cd ansari-backend
% python -m venv .venv
% source .venv/bin/activate
% pip install -r requirements.txt
You can have a look at .env.example, and save it as .env.
You need at a minimum:
OPENAI_API_KEY
(for the language processing) KALEMAT_API_KEY
(for Qur'an and Hadith search). DATABASE_URL=postgresql://user:password@localhost:5432/ansari_db
. Replace 'user', 'password' with whatever you used to set up your own databaseThere are two optional environment variables.
LANGFUSE_SECRET_KEY
and LANGFUSE_PUBLIC_KEY
: Langfuse is a system for logging LLM interactions. It needs two keys: the secret key and the public key. If the secret key is not defined data will not be logged to langfuse. SENDGRID_API_KEY
: Sendgrid is the system we use for sending password reset emails. If it's not set it will print the e-mails that were sentYou can run the follwing commad to create missing tables in your database.
% python setup_database.py
We use uvicorn
to run the service.
% # Make sure to load environment variables:
% source .env
% uvicorn main_api:app --reload # Reload automatically reloads python files as you edit.
This starts a service on port 8000. You can check it's up by checking at http://localhost:8000/docs which gives you a nice interface to the API.
If you just want to run Ansari on the command line such that it takes input from stdin and outputs on stdout (e.g. for debugging or to feed it text) you can just do:
% python main_stdio.py
Side note: If you're contributing to the main project, you should style your code with ruff.
This roadmap is preliminary, but it gives you an idea of where Ansari is heading. Please contact us at feedback@ansari.chat
if you’d like to help with these.