ianarawjo 158fa74d97
Add prompt variants option to Prompt Node (#334)
* Add prompt variants feature to Prompt Node

* Fix countQueries backwards compatibility

* Add alertmodal for deleting prompt variant

* Add prompt variants to PromptPreview modals

* Autoresize textarea when switching prompt variants. Ensure auto-templating is only used for variants when length exceeds 1.

* Update package version

* Add an option to CLI to set custom flow directory
2025-03-15 17:48:32 -04:00

50 lines
2.2 KiB
Python

import argparse
from chainforge.flask_app import run_server
# Main Chainforge start
def main():
parser = argparse.ArgumentParser(description='Chainforge command line tool')
# Serve command
subparsers = parser.add_subparsers(dest='serve')
serve_parser = subparsers.add_parser('serve', help='Start Chainforge server')
# TODO: Add this back
# Turn on to disable all outbound LLM API calls and replace them with dummy calls
# that return random strings of ASCII characters. Useful for testing interface without wasting $$.
# serve_parser.add_argument('--dummy-responses',
# help="""Disables queries to LLMs, replacing them with spoofed responses composed of random ASCII characters.
# Produces each dummy response at random intervals between 0.1 and 3 seconds.""",
# dest='dummy_responses',
# action='store_true')
# TODO: Reimplement this where the React server is given the backend's port before loading.
serve_parser.add_argument('--port',
help='The port to run the server on. Defaults to 8000.',
type=int, default=8000, nargs='?')
serve_parser.add_argument('--host',
help="The host to run the server on. Defaults to 'localhost'.",
type=str, default="localhost", nargs='?')
serve_parser.add_argument('--dir',
help="Set a custom directory to use for saving flows and autosaving. By default, ChainForge uses the user data location suggested by the `platformdirs` module. Should be the full path.",
type=str,
default=None)
args = parser.parse_args()
# Currently only support the 'serve' command...
if not args.serve:
parser.print_help()
exit(0)
port = args.port if args.port else 8000
host = args.host if args.host else "localhost"
if args.dir:
print(f"Using directory for storing flows: {args.dir}")
print(f"Serving Flask server on {host} on port {port}...")
run_server(host=host, port=port, flows_dir=args.dir)
if __name__ == "__main__":
main()