Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery refactored main branch #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Oct 17, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from rachittshah October 17, 2023 12:26

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function upload_file refactored with the following changes:

Comment on lines -92 to +101

if os.path.exists(file_path):
data = parse_yaml(file_path)

if raw:
return {'prompt': data.get('prompt')}
else:
return FileResponse(file_path, media_type='application/x-yaml')

else:

if not os.path.exists(file_path):
raise HTTPException(status_code=404, detail=f'File not found: {file_path}')
data = parse_yaml(file_path)

return (
{'prompt': data.get('prompt')}
if raw
else FileResponse(file_path, media_type='application/x-yaml')
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function read_file_by_name refactored with the following changes:

Comment on lines -113 to +133
map_info = {}
map_info = {'title': ask_for_input('title', 'str', True)}

map_info['title'] = ask_for_input('title', 'str', True)
map_info['uuid'] = str(uuid.uuid4())
map_info['description'] = ask_for_input('description', 'str', True)
map_info['category'] = ask_for_input('category', 'str', True)
map_info['provider'] = ask_for_input('provider', 'str', False)
map_info['model'] = ask_for_input('model', 'str', False)

# model settings with default values
model_settings_fields = ['temperature', 'top_k', 'top_p', 'max_tokens', 'stream', 'presence_penalty', 'frequency_penalty']
model_settings_types = ['float', 'int', 'float', 'int', 'bool', 'float', 'float']
model_settings_defaults = [0.8, None, 1, None, False, 0.0, 0.0]

model_settings = {field: ask_for_input(field, ftype, False, default) for field, ftype, default in zip(model_settings_fields, model_settings_types, model_settings_defaults)}

# only add model_settings to map if it's not empty
if any(model_settings.values()):
map_info['model_settings'] = model_settings

map_info['prompt'] = ask_for_input('prompt', 'str', True)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_prompt refactored with the following changes:

Comment on lines -219 to +218

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 219-269 refactored with the following changes:

Comment on lines -28 to +43

url = f'{self.base_url}/{repo_user}/{repo_name}/main/prompts/{full_prompt_name}.yml'
full_prompt_name = full_prompt_name + '.yml' if not full_prompt_name.endswith('.yml') else full_prompt_name
full_prompt_name = (
f'{full_prompt_name}.yml'
if not full_prompt_name.endswith('.yml')
else full_prompt_name
)

print(f'(status) retrieving template: {url}')

try:
response = requests.get(url)
if response.status_code != 200:
print(f'(error) error retrieving template - non 200 status code: {response.status_code}')
return prompt_data

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PromptLoader.get_template refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants