Browse Source

Add support for running local models via LM Studio

pull/334/head
Kayvan Sylvan 12 months ago
parent
commit
45780cf221
  1. 4
      README.md
  2. 2
      installer/client/cli/fabric.py
  3. 9
      installer/client/cli/utils.py

4
README.md

@ -241,7 +241,9 @@ options:
Select the model to use. NOTE: Will not work if you have set a default model. please use --clear to clear persistence before using this flag
--listmodels List all available models
--remoteOllamaServer REMOTEOLLAMASERVER
The URL of the remote ollamaserver to use. ONLY USE THIS if you are using a local ollama server in an non-deault location or port
The URL of the remote ollamaserver to use. ONLY USE THIS if you are using a local ollama server in a non-deault location or port.
--openAiBaseUrl Base URL for OpenAI calls. Use this for when you want to use a local model via LM Studio.
Alternatively, you can set OPENAI_API_BASE_URL in the environment.
--context, -c Use Context file (context.md) to add context to your pattern
```

2
installer/client/cli/fabric.py

@ -64,6 +64,8 @@ def main():
)
parser.add_argument('--remoteOllamaServer',
help='The URL of the remote ollamaserver to use. ONLY USE THIS if you are using a local ollama server in an non-deault location or port')
parser.add_argument('--openAiBaseUrl',
help='Base URL for OpenAI calls. Use this for when you want to use a local model via LM Studio. Alternatively, you can set OPENAI_API_BASE_URL in the environment.')
parser.add_argument('--context', '-c',
help="Use Context file (context.md) to add context to your pattern", action="store_true")

9
installer/client/cli/utils.py

@ -40,9 +40,16 @@ class Standalone:
env_file = os.path.expanduser(env_file)
self.client = None
load_dotenv(env_file)
if args.openAiBaseUrl:
self.openai_base_url = args.openApiBaseUrl
else:
self.openai_base_url = os.environ.get("OPENAI_API_BASE_URL", None)
if "OPENAI_API_KEY" in os.environ:
api_key = os.environ['OPENAI_API_KEY']
self.client = OpenAI(api_key=api_key)
if self.openai_base_url:
self.client = OpenAI(api_key=api_key, base_url=self.openai_base_url)
else:
self.client = OpenAI(api_key=api_key)
self.local = False
self.config_pattern_directory = config_directory
self.pattern = pattern

Loading…
Cancel
Save