Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def load_config(configfilename):
config = json.load(configfile)
configfile.close()
print(f"Loaded Configfile: {configfilename}.")
except IOError as e:
print(f"Error loading configfile: {e}")
exit
except IOError as e:
print(f"Error loading configfile: {e}")
exit()
# read API KEY from ENV Variable if set
print("OpenAI Chat Client, type !help for help.")

Expand All @@ -99,9 +99,9 @@ def save_config(configfilename):
json.dump(config, configfile, indent=2)
configfile.close()
print(f"Saved Configfile: {configfilename}.")
except IOError as e:
print(f"Error saving configfile: {e}")
exit
except IOError as e:
print(f"Error saving configfile: {e}")
exit()


def main():
Expand All @@ -111,11 +111,12 @@ def main():
except:
load_config("chat_config.json")

response=response_msg=''
context=[]
response=response_msg=''
context=[]

###LOGGING
log_filename = f'logs/chat-session-{datetime.now().strftime("%Y%m%d-%H%M")}.log'
os.makedirs('logs', exist_ok=True)
log_filename = f'logs/chat-session-{datetime.now().strftime("%Y%m%d-%H%M")}.log'
logging.basicConfig(
level=logging.INFO, # Set the logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
format=u'%(asctime)s - %(message)s',
Expand Down Expand Up @@ -188,7 +189,7 @@ def main():
print(f"Unknown command: {user_input}\n Type !help for help")
else:
response = send_payload(user_input)
repsonse_msg=process_response(response)
response_msg=process_response(response)
if enable_logging:
logging.info(f'User: {user_input}')
logging.info(f'{config["model"]}:{response}')
Expand Down