Skip to content

Commit

Permalink
Improve code readability in _cli.py
Browse files Browse the repository at this point in the history
- Split long lines of code into multiple lines for better readability.
- Renamed file handler variable 'f' to 'f_file' for clarity.
  • Loading branch information
yangbobo2021 authored and basicthinker committed Jul 1, 2023
1 parent a421d16 commit a5e74e3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions devchat/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ def init_dir() -> Tuple[dict, str]:
help='Add one or more files to the prompt as a context.')
@click.option('-m', '--model', help='Specify the model to temporarily use for the prompt '
'(prefer to modify .chat/config.json).')
@click.option('--functions', type=click.Path(exists=True), help='Path to a JSON file with functions for the prompt.')
@click.option('--functions', type=click.Path(exists=True),
help='Path to a JSON file with functions for the prompt.')
def prompt(content: Optional[str], parent: Optional[str], reference: Optional[List[str]],
instruct: Optional[List[str]], context: Optional[List[str]], model: Optional[str], functions: Optional[str] = None):
instruct: Optional[List[str]], context: Optional[List[str]],
model: Optional[str], functions: Optional[str] = None):
"""
Main function to run the chat application.
Expand Down Expand Up @@ -152,9 +154,11 @@ def prompt(content: Optional[str], parent: Optional[str], reference: Optional[Li
model = config['model']
functions_data = None
if functions is not None:
with open(functions, 'r', encoding="utf-8") as f:
functions_data = json.load(f)
openai_config = OpenAIChatConfig(model=model, functions=functions_data, **config['OpenAI'])
with open(functions, 'r', encoding="utf-8") as f_file:
functions_data = json.load(f_file)
openai_config = OpenAIChatConfig(model=model,
functions=functions_data,
**config['OpenAI'])

chat = OpenAIChat(openai_config)
store = Store(chat_dir, chat)
Expand Down

0 comments on commit a5e74e3

Please sign in to comment.