SlashGPT is a playground for developers to make quick prototypes of LLM agents (or apps with Natural Language UI).
Here are the design goals for SlashGPT as explained in Manifest and the Architecture allows:
[!NOTE] If you want to try it out immediately, please try the Google Google Colaboratory version.
pip install -r requirements/full.txt or poetry installpip install -r requirements.txtOPENAI_API_KEY=...pdoc src/slashgpt
or
Type ./SlashGPT.py
When you see "You({agent_name}):", type a message to the agent OR type a slash command starting with "/".
It activate "dispatcher" agent first, which is able to dispatch queries to appropriate agents.
Type "/help" to see the list of system commands and available agents.
This is different that user execution, here we link the files in the repo directly into the container so you can run and debug and update code into the repo directly.
docker run -it slashgpt -v $(pwd):/SlashGPT/SlashGPT ./SlashGPT.pymake docker
will drop you into an python debug session.Some of agents are built to mimic the behaviors of ChatGPT code interpreter with various LLMs.
code (GPT3.5) works just like OpenAI's Code Interpreter. It is able to execute the output of generated code appropriately.
code_palm2 (PaLM2) and code_llama (LlaMA) are not able to execute the output of generated code (they often enter into an infinite loop). Therefore, we stop the conversation after the output ("skip_function_result": true in the manifest), and the user needs to explicitly ask it to run the generated code.
For the runtime, it uses IPython by default, but it uses CodeBox if you specify CODEBOX_API_KEY key. IPython displays images as popups, but does not write them into the notebook. CodeBox is able to write them into the notebook.
Sample queries.
Create a new manifest file, {agent_name}.json/yml in "manifests" folder with following properties:
Name of that file becomes the slash command. (the slash command of "foo.json" is "/foo").
It defines template-based function implementations (including mockups), alternative to writing Python code using the "module" property.
It supports four different methods.
Use this method to develop the front-end of a system before the backend become ready.
Here is an example (home).
"actions": {
"fill_bath": { "type": "message_template",
"message":"Success. I started filling the bath tab." },
"set_temperature": { "type": "message_template",
"message":"Success. I set temperature to {temperature} for {location}" },
"start_sprinkler": { "type": "message_template",
"message":"Success. I started the sprinkler for {location}" },
"take_picture": { "type": "message_template",
"message":"Success. I took a picture of {location}" },
"play_music": { "type": "message_template",
"message":"Success. I started playing {music} in {location}" },
"control_light": { "type": "message_template",
"message":"Success. The light switch of {location} is now {switch}." }
}
Use this method to call REST APIs (equivalent to ChatGPT's plugin system).
Here is an example (currency).
"actions": {
"convert": {
"type": "rest",
"url": "https://today-currency-converter.oiconma.repl.co/currency-converter?from={from}&to={to}&amount={amount}"
}
}
Use this method to call GraphQL APIs.
Here is an example (spacex).
"actions": {
"convert": {
"type": "graphQL",
"url": "https://spacex-production.up.railway.app/graphql"
}
}
This method allows a developer to generate a text data (typically in JSON, but not limited to), and turn it into a data URL.
Here is an example for "make_event" function (cal).
"actions": {
"make_event": {
"type": "data_url",
"template": "./resources/calendar.ics",
"mime_type": "text/calendar",
"message": "The event was scheduled. Here is the invitation link: '{url}'"
}
}
The contents of calendar.ics file.
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//My Calendar//NONSELF v1.0//EN
BEGIN:VEVENT
DTSTART:{DTSTART}
DTEND:{DTEND}
SUMMARY:{SUMMARY}
DESCRIPTION:{DESCRIPTION}
LOCATION:{LOCATION}
END:VEVENT
END:VCALENDAR
The definition of "make_event" function.
{
"name": "make_event",
"description": "Create a calendar event in iCalendar format",
"parameters": {
"type": "object",
"properties": {
"SUMMARY": {
"type": "string",
"description": "a short, one-line description of the event"
},
"DESCRIPTION": {
"type": "string",
"description": "a more complete description of the calendar",
"maxLength": 400
},
"DTSTART": {
"type": "string",
"format": "date-time",
"description": "the date and time in UTC that the event begins such as 19980119T020000Z"
},
"DTEND": {
"type": "string",
"format": "date-time",
"description": "the date and time in UTC that the event ends such as 19980119T030000Z"
},
"LOCATION": {
"type": "string",
"description": "the intended venue with address for the event."
}
},
"required": ["SUMMARY", "DTSTART", "DTEND", "DESCRIPTION", "LOCATION"]
}
}
It will emit an event to the caller (of ChatSession:call_loop).
The "emit_method" determines the action and the "emit_data" defines parameters.
ChatApplication implements the "switch_session" method, which takes "message", "agent" and "memory" properties.
Here is an example (dispatcher):
"actions": {
"categorize": {
"type": "emit",
"emit_method": "switch_session",
"emit_data": {
"message": "{question}",
"agent": "{category}"
}
}
},
Automated.
./SlashGPT.py
/autodesk
This is the standard manual test sequence.
# Test REST API
Input: /sample currency
Expected Output: 1 USD is equivalent to 146.31 JPY.
Input: /switch main
# Test REST API with appkey header (WEBPILOT_UID in .env is required)
Input: /sample webpilot
Expected Output: Title: France riots ...\nSummary: The fourth night ...
Input: /switch main
# Test GraphQL
Input: /sample spacex
Expected Output: The CEO of SpaceX is Elon Musk.
Input: /switch main
# Test DataURL
Input: /sample cal
Expected Output: I have scheduled a meeting with Tim Cook on July 4th at 8:00
PM UTC for 30 minutes. The meeting will be held at Tim Cook's office. I have
sent the invitation to Tim Cook at tim@apple.com.
Input: /switch main
# Test Code Interpreter
Input: /code
Input: /sample_stock
Expected Output: <Market cap history of Apple and Tesla>
How to run tests and generate coverage report.
make test
Formatting and linting niceties
make lint
make format
Jupyter Notebook
68.3%
Python
28.4%
HTML
2.9%
SlashGPT is a playground for developers to make quick prototypes of LLM agents (or apps with Natural Language UI).
Here are the design goals for SlashGPT as explained in Manifest and the Architecture allows:
[!NOTE] If you want to try it out immediately, please try the Google Google Colaboratory version.
pip install -r requirements/full.txt or poetry installpip install -r requirements.txtOPENAI_API_KEY=...pdoc src/slashgpt
or
Type ./SlashGPT.py
When you see "You({agent_name}):", type a message to the agent OR type a slash command starting with "/".
It activate "dispatcher" agent first, which is able to dispatch queries to appropriate agents.
Type "/help" to see the list of system commands and available agents.
This is different that user execution, here we link the files in the repo directly into the container so you can run and debug and update code into the repo directly.
docker run -it slashgpt -v $(pwd):/SlashGPT/SlashGPT ./SlashGPT.pymake docker
will drop you into an python debug session.Some of agents are built to mimic the behaviors of ChatGPT code interpreter with various LLMs.
code (GPT3.5) works just like OpenAI's Code Interpreter. It is able to execute the output of generated code appropriately.
code_palm2 (PaLM2) and code_llama (LlaMA) are not able to execute the output of generated code (they often enter into an infinite loop). Therefore, we stop the conversation after the output ("skip_function_result": true in the manifest), and the user needs to explicitly ask it to run the generated code.
For the runtime, it uses IPython by default, but it uses CodeBox if you specify CODEBOX_API_KEY key. IPython displays images as popups, but does not write them into the notebook. CodeBox is able to write them into the notebook.
Sample queries.
Create a new manifest file, {agent_name}.json/yml in "manifests" folder with following properties:
Name of that file becomes the slash command. (the slash command of "foo.json" is "/foo").
It defines template-based function implementations (including mockups), alternative to writing Python code using the "module" property.
It supports four different methods.
Use this method to develop the front-end of a system before the backend become ready.
Here is an example (home).
"actions": {
"fill_bath": { "type": "message_template",
"message":"Success. I started filling the bath tab." },
"set_temperature": { "type": "message_template",
"message":"Success. I set temperature to {temperature} for {location}" },
"start_sprinkler": { "type": "message_template",
"message":"Success. I started the sprinkler for {location}" },
"take_picture": { "type": "message_template",
"message":"Success. I took a picture of {location}" },
"play_music": { "type": "message_template",
"message":"Success. I started playing {music} in {location}" },
"control_light": { "type": "message_template",
"message":"Success. The light switch of {location} is now {switch}." }
}
Use this method to call REST APIs (equivalent to ChatGPT's plugin system).
Here is an example (currency).
"actions": {
"convert": {
"type": "rest",
"url": "https://today-currency-converter.oiconma.repl.co/currency-converter?from={from}&to={to}&amount={amount}"
}
}
Use this method to call GraphQL APIs.
Here is an example (spacex).
"actions": {
"convert": {
"type": "graphQL",
"url": "https://spacex-production.up.railway.app/graphql"
}
}
This method allows a developer to generate a text data (typically in JSON, but not limited to), and turn it into a data URL.
Here is an example for "make_event" function (cal).
"actions": {
"make_event": {
"type": "data_url",
"template": "./resources/calendar.ics",
"mime_type": "text/calendar",
"message": "The event was scheduled. Here is the invitation link: '{url}'"
}
}
The contents of calendar.ics file.
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//My Calendar//NONSELF v1.0//EN
BEGIN:VEVENT
DTSTART:{DTSTART}
DTEND:{DTEND}
SUMMARY:{SUMMARY}
DESCRIPTION:{DESCRIPTION}
LOCATION:{LOCATION}
END:VEVENT
END:VCALENDAR
The definition of "make_event" function.
{
"name": "make_event",
"description": "Create a calendar event in iCalendar format",
"parameters": {
"type": "object",
"properties": {
"SUMMARY": {
"type": "string",
"description": "a short, one-line description of the event"
},
"DESCRIPTION": {
"type": "string",
"description": "a more complete description of the calendar",
"maxLength": 400
},
"DTSTART": {
"type": "string",
"format": "date-time",
"description": "the date and time in UTC that the event begins such as 19980119T020000Z"
},
"DTEND": {
"type": "string",
"format": "date-time",
"description": "the date and time in UTC that the event ends such as 19980119T030000Z"
},
"LOCATION": {
"type": "string",
"description": "the intended venue with address for the event."
}
},
"required": ["SUMMARY", "DTSTART", "DTEND", "DESCRIPTION", "LOCATION"]
}
}
It will emit an event to the caller (of ChatSession:call_loop).
The "emit_method" determines the action and the "emit_data" defines parameters.
ChatApplication implements the "switch_session" method, which takes "message", "agent" and "memory" properties.
Here is an example (dispatcher):
"actions": {
"categorize": {
"type": "emit",
"emit_method": "switch_session",
"emit_data": {
"message": "{question}",
"agent": "{category}"
}
}
},
Automated.
./SlashGPT.py
/autodesk
This is the standard manual test sequence.
# Test REST API
Input: /sample currency
Expected Output: 1 USD is equivalent to 146.31 JPY.
Input: /switch main
# Test REST API with appkey header (WEBPILOT_UID in .env is required)
Input: /sample webpilot
Expected Output: Title: France riots ...\nSummary: The fourth night ...
Input: /switch main
# Test GraphQL
Input: /sample spacex
Expected Output: The CEO of SpaceX is Elon Musk.
Input: /switch main
# Test DataURL
Input: /sample cal
Expected Output: I have scheduled a meeting with Tim Cook on July 4th at 8:00
PM UTC for 30 minutes. The meeting will be held at Tim Cook's office. I have
sent the invitation to Tim Cook at tim@apple.com.
Input: /switch main
# Test Code Interpreter
Input: /code
Input: /sample_stock
Expected Output: <Market cap history of Apple and Tesla>
How to run tests and generate coverage report.
make test
Formatting and linting niceties
make lint
make format
Jupyter Notebook
68.3%
Python
28.4%
HTML
2.9%