Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Dec 29, 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 AMarete December 29, 2023 14:36
Comment on lines -38 to +42
if lines[0].split("?")[-1].strip() == "Yes":
tool = lines[1].split(":", 1)[-1].strip()
command = lines[2].split(":", 1)[-1].strip()
return tool, command
else:
if lines[0].split("?")[-1].strip() != "Yes":
return Break()
tool = lines[1].split(":", 1)[-1].strip()
command = lines[2].split(":", 1)[-1].strip()
return tool, command
Copy link
Author

Choose a reason for hiding this comment

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

Function tool_parse refactored with the following changes:

Comment on lines -48 to +54
for i, tool in enumerate(tools):
if selector == tool.__class__.__name__:
return model(command, tool_num=i)
return ("",)
return next(
(
model(command, tool_num=i)
for i, tool in enumerate(tools)
if selector == tool.__class__.__name__
),
("",),
)
Copy link
Author

Choose a reason for hiding this comment

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

Function tool_use refactored with the following changes:

  • Use the built-in function next instead of a for-loop (use-next)

return ""

return model(state.next_query)
return "" if state.next_query is None else model(state.next_query)
Copy link
Author

Choose a reason for hiding this comment

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

Function google refactored with the following changes:

Comment on lines -54 to +51
for i in range(3):
for _ in range(3):
Copy link
Author

Choose a reason for hiding this comment

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

Function selfask refactored with the following changes:

def enum(x: Type[Enum]) -> Dict[str, int]:
d = {e.name: e.value for e in x}
return d
return {e.name: e.value for e in x}
Copy link
Author

Choose a reason for hiding this comment

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

Function enum refactored with the following changes:

else:
self.backend = backend

self.backend = [backend] if not isinstance(backend, List) else backend
Copy link
Author

Choose a reason for hiding this comment

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

Function Prompt.__init__ refactored with the following changes:

Comment on lines -132 to +128
for r in self.stream(model_input, tool_num):
yield r
yield from self.stream(model_input, tool_num)
Copy link
Author

Choose a reason for hiding this comment

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

Function Prompt.Model.__call__ refactored with the following changes:

  • Replace yield inside for loop with yield from (yield-from)

if isinstance(s, str):
return {"string": s}
return s
return {"string": s} if isinstance(s, str) else s
Copy link
Author

Choose a reason for hiding this comment

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

Function to_gradio_block refactored with the following changes:

Comment on lines -211 to +209
if all([k in os.environ for k in keys]):
if all(k in os.environ for k in keys):
Copy link
Author

Choose a reason for hiding this comment

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

Function api_keys refactored with the following changes:

Comment on lines -314 to +312
inputs = list([gr.Textbox(label=f) for f in fields])
inputs = [gr.Textbox(label=f) for f in fields]
Copy link
Author

Choose a reason for hiding this comment

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

Function show 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.

1 participant