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 Starbot ⭐ refactored Amm1rr/Free-Chatbot-API #3

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

sourcery-ai-bot
Copy link
Contributor

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

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

git fetch https://github.com/sourcery-ai-bot/Free-Chatbot-API master
git merge --ff-only FETCH_HEAD
git reset HEAD^

url = "http://localhost:8000/" + ai
url = f"http://localhost:8000/{ai}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 19-31 refactored with the following changes:

Comment on lines -54 to +50
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer ",
},
headers={"Content-Type": "application/json", "Authorization": "Bearer "},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 54-131 refactored with the following changes:

This removes the following comments ( why? ):

# print(f"{data}\n\n")
# Hide API key from Rich traceback.

if arg1.upper() == "TRUE":
stream = True
else:
stream = False

stream = arg1.upper() == "TRUE"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 19-23 refactored with the following changes:

if arg1.upper() == "TRUE":
stream = True
else:
stream = False

stream = arg1.upper() == "TRUE"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 18-65 refactored with the following changes:

if arg1.upper() == "TRUE":
stream = True
else:
stream = False
stream = arg1.upper() == "TRUE"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lines 10-13 refactored with the following changes:

Comment on lines -363 to +337
if response.status_code == 200:
return response.json()
else:
return False
return response.json() if response.status_code == 200 else False
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Client.upload_attachment refactored with the following changes:

Comment on lines -395 to +366
if response.status_code == 200:
return True
else:
return False
return response.status_code == 200
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Client.rename_chat refactored with the following changes:

# answer = {f"answer": "You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."}["answer"]
answer = f"You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."
# print(answer)
return answer

return f"You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ask_gpt refactored with the following changes:

This removes the following comments ( why? ):

# print(answer)
# answer = {f"answer": "You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."}["answer"]

Comment on lines -467 to +470
f"Error": f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
"Error": f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
}

print(response_error)
return response_error
# raise ValueError(
# f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
# )
# raise ValueError(
# f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
# )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ask_gptClaude refactored with the following changes:

Comment on lines -542 to +544
f"Error": f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
"Error": f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
}

print(response_error)
return response_error
# raise ValueError(
# f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
# )
# raise ValueError(
# f"You should set 'COOKIE' in '{CONFIG_FILE_NAME}' file for the Bard or send it as an argument."
# )
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ask_claude refactored with the following changes:

This removes the following comments ( why? ):

# print(response)

Comment on lines -691 to +684
# answer = {f"answer": "You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."}["answer"]
answer = f"You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."
# print(answer)
return answer

return f"You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ask_chatgpt refactored with the following changes:

This removes the following comments ( why? ):

# print(answer)
# answer = {f"answer": "You should set ACCESS_TOKEN in {CONFIG_FILE_NAME} file or send it as an argument."}["answer"]

Comment on lines -786 to +775
for i in range(10):
for _ in range(10):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function fake_data_streamer_OLD refactored with the following changes:

Comment on lines -813 to +802
for i in range(10):
for _ in range(10):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function fake_data_streamer refactored with the following changes:

Comment on lines -838 to +827
if not session_id:
return False
if session_id.lower() == "none":
return False

return True
return False if not session_id else session_id.lower() != "none"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function IsSession refactored with the following changes:

Comment on lines -884 to +878
filtered_cookies = [
cookie for cookie in cookies if sessionName.lower() in cookie.name.lower()
]

result = None
if filtered_cookies:
result = filtered_cookies[-1].value

return result
return (
filtered_cookies[-1].value
if (
filtered_cookies := [
cookie
for cookie in cookies
if sessionName.lower() in cookie.name.lower()
]
)
else None
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function get_Cookie refactored with the following changes:

@Amm1rr Amm1rr merged commit aa84a85 into Amm1rr:master Aug 15, 2023
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.

None yet

2 participants