Refactor EnhancedContextPlugin to handle command line arguments for LLM provider selection

This commit is contained in:
2024-11-06 10:34:26 -05:00
parent 30d8412bbf
commit 8a5a29f864
2 changed files with 26 additions and 7 deletions
+25 -7
View File
@@ -25,13 +25,21 @@ from rich.status import Status
from concurrent.futures import ThreadPoolExecutor
import random
from docopt import docopt
DB_PATH = "enhanced_context.db"
AVAILABLE_PROVIDERS = ["xai", "openai", "anthropic", "ollama"]
LLM_MODEL = "gpt-4o-mini"
LLM_PROVIDER = "openai"
__doc__ = """Enhanced Context Chat Interface
# LLM_PROVIDER = "xai"
# LLM_MODEL = "grok-beta"
Usage:
enhanced_context.py [--provider=<provider>]
enhanced_context.py (-h | --help)
Options:
-h --help Show this screen.
--provider=<provider> LLM provider to use (openai/anthropic/xai/ollama)
"""
class EnhancedContextPlugin(sm.BasePlugin):
@@ -581,10 +589,20 @@ class EnhancedContextPlugin(sm.BasePlugin):
# Replace the example usage code at the bottom with this chat interface:
def main():
# Parse arguments
args = docopt(__doc__)
console = Console()
# Use command line provider if specified, otherwise use picker
if args["--provider"]:
provider = args["--provider"].lower()
model = None
else:
provider = None
model = None
# Create a conversation and add the plugin
conversation = sm.create_conversation(
llm_model=LLM_MODEL, llm_provider=LLM_PROVIDER
)
conversation = sm.create_conversation(llm_model=model, llm_provider=provider)
plugin = EnhancedContextPlugin(verbose=False) # Set verbose here
conversation.add_plugin(plugin)
+1
View File
@@ -7,3 +7,4 @@ faiss-cpu
rich
nltk
spacy
docopt