""" Initialize the class with the provided arguments and environment file.
@ -41,7 +44,7 @@ class Standalone:
self.client=OpenAI()
self.client.api_key=apikey
except:
print("No API key found. Use the --apikey option to set the key")
eprint("No API key found. Use the --apikey option to set the key")
self.local=False
self.config_pattern_directory=config_directory
self.pattern=pattern
@ -129,7 +132,7 @@ class Standalone:
system_message={"role":"system","content":system}
messages=[system_message,user_message]
exceptFileNotFoundError:
print("pattern not found")
eprint("pattern not found")
return
else:
ifcontext:
@ -169,17 +172,17 @@ class Standalone:
sys.stdout.flush()
exceptExceptionase:
if"All connection attempts failed"instr(e):
print(
eprint(
"Error: cannot connect to llama2. If you have not already, please visit https://ollama.com for installation instructions")
if"CLAUDE_API_KEY"instr(e):
print(
eprint(
"Error: CLAUDE_API_KEY not found in environment variables. Please run --setup and add the key")
if"overloaded_error"instr(e):
print(
eprint(
"Error: Fabric is working fine, but claude is overloaded. Please try again later.")
else:
print(f"Error: {e}")
print(e)
eprint(f"Error: {e}")
eprint(e)
ifself.args.copy:
pyperclip.copy(buffer)
ifself.args.output:
@ -215,7 +218,7 @@ class Standalone:
system_message={"role":"system","content":system}
messages=[system_message,user_message]
exceptFileNotFoundError:
print("pattern not found")
eprint("pattern not found")
return
else:
ifcontext:
@ -243,19 +246,19 @@ class Standalone:
print(response.choices[0].message.content)
exceptExceptionase:
if"All connection attempts failed"instr(e):
print(
eprint(
"Error: cannot connect to llama2. If you have not already, please visit https://ollama.com for installation instructions")
if"CLAUDE_API_KEY"instr(e):
print(
eprint(
"Error: CLAUDE_API_KEY not found in environment variables. Please run --setup and add the key")
if"overloaded_error"instr(e):
print(
eprint(
"Error: Fabric is working fine, but claude is overloaded. Please try again later.")
if"Attempted to call a sync iterator on an async stream"instr(e):
print("Error: There is a problem connecting fabric with your local ollama installation. Please visit https://ollama.com for installation instructions. It is possible that you have chosen the wrong model. Please run fabric --listmodels to see the available models and choose the right one with fabric --model <model> or fabric --changeDefaultModel. If this does not work. Restart your computer (always a good idea) and try again. If you are still having problems, please visit https://ollama.com for installation instructions.")
eprint("Error: There is a problem connecting fabric with your local ollama installation. Please visit https://ollama.com for installation instructions. It is possible that you have chosen the wrong model. Please run fabric --listmodels to see the available models and choose the right one with fabric --model <model> or fabric --changeDefaultModel. If this does not work. Restart your computer (always a good idea) and try again. If you are still having problems, please visit https://ollama.com for installation instructions.")