irisChatGPT application leverages the functionality of one of the hottest python framework LangChain built around Large Language Models (LLMs).
LangChain is a framework that enables quick and easy development of applications that make use of Large Language Models.
Application is built by using objectscript with the help of intersystems Embedded Python functionality. It also contains Streamlit web application which is an open-source Python app framework to create beautiful web apps for data science and machine learning.
Streamlit Web Application Layout
Features
- Built-in Intersystems ObjectScript Reference ChatGPT
- Built-in InterSystems Grand Prix Contest 2023 ChatGPT
- INTERSYSTEMS FHIR SQL BUILDER ChatGPT
- ChatGPT with FHIR server
- Answer questions over a Cache database by using SQLDatabaseChain
- Create your own chatGPT model by using PDF, word and text documents
- OpenAI ChatGPT
- Wikipedia Search
- Search on the internet by using DuckDuckGo (DDG) general search engine
- Generate Python code by using Python REPL LangChain functionality
- Streamlit Web application
- Intersystems objectscript reference ChatGPT (Web interface)
- Intersystems grand prix contest ChatGPT (Web interface)
- Select and upload your own document for ChatGPT (Web Interface)
- OpenAI ChatGPT (Web interface)
How to Run
To start coding with this repo, you do the following:
- Clone/git pull the repo into any local directory
git clone https://github.com/mwaseem75/irisChatGPT.git
- Open the terminal in this directory and run:
docker-compose build
- Run the IRIS container with your project:
docker-compose up -d
Installation with ZPM
zpm "install irisChatGPT.ZPM"
Getting Started
Get OpenAI Key
Application requires OpenAI API Key, sign up for OpenAI API on this page. Once you signed up and logged in, click on Personal, and select View API keys in drop-down menu. Create and copy the API Key
Connect to IRIS Terminal by using below command
docker-compose exec iris iris session iris
Create a new instance of dc.irisChatGPT class and use SetApiKey method to set OpenAI API Key
set chat = ##class(dc.irisChatGPT).%New()
do chat.SetAPIKey("Enter your Open API Key here")
write chat.irisDocs("Give me details of %$PIECE function with syntax")
write chat.irisContest("Give me Prizes and nominations")
Repository will load FHIR Resources, All you need is to configure FHIR SQL BUILDER.
For configuration, Navigate to http://localhost:55037/csp/fhirsql/index.html
For more details about configuration, please watch this Tutorial Video and check
iris-fhirsqlbuilder application by @Guillaume Rongier
Please note that I am using FHIR as package name
To view the specification, Navigate to http://localhost:55037/csp/fhirsql/index.html/spec#/1
After the configuration, we can do ChatGPT with FHIR SQL
write chat.irisFHIRSQL("Give me total patients")
write chat.irisFHIRSQL("List down all the Male Patients")
write chat.irisFHIRSQL("Give me patients where birthdate < 2000")
write chat.irisFHIRSQL("Give me observation details of patient 175")
write chat.irisFHIRSQL("Give me total encounter of 175")
write chat.irisFHIRSQL("Give me goal of Patient 175")
write chat.irisFHIRSQL("Give me details of Organization 80")
ChatGPT with FHIR server
We need to first set FHIR Endpoint by using SetFHIRUrl method.
Currently, I am setting the FHIR server End point running in docker
do chat.SetFHIRUrl("http://localhost:52773/csp/healthshare/fhirserver/fhir/r4/")
Once URL is set, Now we can ask questions about Patient and Observation resources
write chat.irisFHIR("Give me total patients")
write chat.irisFHIR("List down all the Male Patients")
write chat.irisFHIR("Give me observation details of patient 175")
write chat.irisFHIR("Give me procedure of patients id 1")
write chat.irisFHIR("Give me Immunizations of patients id 175")
write chat.irisFHIR("Give me all the encounters of year 2012")
write chat.irisFHIR("Give me condition of patient id 175")
write chat.irisFHIR("Give me all female practioners")
Answer questions over a Cache database by using SQLDatabaseChain
write chat.irisDB("Give me total tables")
Create your own chatGPT model by using PDF, word and text documents
Use ingest function to upload the document
Copy your document to ManagerDirectory()+‘pdfdata/’ folder and then use the below command to ingest the data.
(The repository already contains Defining and Using Classes PDF which we will upload by using the below command)
set doc = ##class(dc.irisChatGPT).ingest("GOBJ.pdf")
Now we will use personalGPT function to chat with our document
w chat.personalGPT("Give me details of objects and properties")
OpenAI ChatGPT
w chat.openAI("Give me details of Intersystems")
Wikipedia Search
w chat.wikiPedia("LangChain")
Search on the internet by using DuckDuckGo (DDG) general search engine
w chat.duckDuckGo("What is the Capital of USA")
Generate Python code by using Python REPL LangChain functionality
w chat.pythonREPL("Write a function to check if 11 a prime number and test it")
Streamlit Web application
Navigate to Streamlit Web Application or CSP Web application
Thanks