meta-prompt / demo /cot_meta_prompt.py
yaleh's picture
Update meta_prompt_graph.py to handle llms as a single BaseLanguageModel or a dictionary of BaseLanguageModels
68c6b73
"""
MIT License
Copyright (c) 2023 Yale Huang
Email: [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
"""
import argparse
import os
import openai
import gradio as gr
from demo.prompt_ui import PromptUI
class ChatbotApp:
def __init__(self, args):
if args.api_key:
os.environ["OPENAI_API_KEY"] = args.api_key
if args.openai_api_base:
os.environ["OPENAI_API_BASE"] = args.openai_api_base
if args.proxy:
os.environ["OPENAI_PROXY"] = args.proxy
self.prompt_ui = PromptUI(advanced_mode=args.advanced_mode)
self.ui = gr.TabbedInterface(
[self.prompt_ui.ui],
['Prompt']
)
def launch(self, *args, **kwargs):
self.ui.launch(*args, **kwargs)
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--api_key", type=str, required=True, help="OpenAI API key")
parser.add_argument("--proxy", type=str, default=None, help="Proxy settings")
parser.add_argument("--share", action='store_true',
help="Launch app with sharing option")
parser.add_argument("--advanced_mode", action='store_true', default=False,
help="Enable advanced mode")
parser.add_argument("--server_name", type=str, default="127.0.0.1", help="Server name or IP address")
parser.add_argument("--openai_api_base", type=str, default=None, help="OpenAI API base URL")
return parser.parse_args()
if __name__ == "__main__":
args = parse_args()
app = ChatbotApp(args)
app.launch(share=args.share, server_name=args.server_name)