fixed errors when .config.json is corrupt
This commit is contained in:
parent
ad9364400c
commit
0061ca9dfc
9
askai
Normal file → Executable file
9
askai
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!#!/usr/bin/env askai
|
||||
#!/usr/bin/env python
|
||||
|
||||
from langchain.llms import Ollama
|
||||
import json
|
||||
@ -49,11 +49,10 @@ else:
|
||||
try:
|
||||
with open(os.path.expanduser('~/.config.json'), 'r') as f:
|
||||
data = json.load(f)
|
||||
except FileNotFoundError:
|
||||
print("Error: Please run this tool with the --config flag set before you continue.")
|
||||
except:
|
||||
print("Error: The config file is corrupt. Please run with the --config flag set.")
|
||||
exit()
|
||||
|
||||
|
||||
if 'base_url' not in data or 'model' not in data:
|
||||
print('Error: missing base url or model please rerun with --config flag')
|
||||
exit()
|
||||
@ -77,4 +76,4 @@ Information: {textwrap.indent(std_input, ' ')}
|
||||
#print(prompt)
|
||||
|
||||
output = ollama(prompt)
|
||||
print(output)
|
||||
print(output)
|
||||
|
Loading…
Reference in New Issue
Block a user