Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 8fe28b6

Browse files
committed
fix merging problem
2 parents 2860a98 + 12ec693 commit 8fe28b6

32 files changed

+2429
-359
lines changed

README.md

Lines changed: 156 additions & 149 deletions
Large diffs are not rendered by default.

projects/Calculate Age/calculate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ def month_days(month, leap_year):
4646

4747
day = day + localtime.tm_mday
4848
print("%s's age is %d years or " % (name, year), end="")
49-
print("%d months or %d days" % (month, day))
49+
print("%d months or %d days" % (month, day))

projects/Calculate Age/src/calculate_age.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
def age_calculator(name, age):
66
"""
7-
Calculate user's age in years, month, and days
8-
based on current date and print.
7+
Calculate user's age in years, month, and days
8+
based on current date and print.
99
10-
Args:
11-
name (str): user's name.
12-
age (int): user's age in years.
10+
Args:
11+
name (str): user's name.
12+
age (int): user's age in years.
1313
14-
Returns:
15-
None.
16-
"""
14+
Returns:
15+
None.
16+
"""
1717
localtime = time.localtime(time.time())
1818

1919
year = int(age)
@@ -36,7 +36,3 @@ def age_calculator(name, age):
3636
day += localtime.tm_mday
3737

3838
return f"{name}'s age is {year} years or {month} months or {day} days"
39-
40-
41-
42-

projects/Calculate Age/src/main.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
def main():
55
"""
6-
the user to input name and age, validate input,
7-
and calculates and displays the user age in years, months and days.
6+
the user to input name and age, validate input,
7+
and calculates and displays the user age in years, months and days.
88
9-
Args:
10-
None.
9+
Args:
10+
None.
1111
12-
Return:
13-
None.
14-
"""
12+
Return:
13+
None.
14+
"""
1515
input_name = input("input your name: ")
1616

1717
while True:
@@ -29,7 +29,6 @@ def main():
2929

3030
print(result)
3131

32+
3233
if __name__ == "__main__":
3334
main()
34-
35-

projects/Calculate Age/src/utilize_date.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
def judge_leap_year(year):
55
"""
6-
judge the leap year.
6+
judge the leap year.
77
8-
Args:
9-
year (int): To check the year.
10-
return:
11-
bool: Ture if the year is a leap year, False otherwise.
12-
"""
8+
Args:
9+
year (int): To check the year.
10+
return:
11+
bool: Ture if the year is a leap year, False otherwise.
12+
"""
1313
if isleap(year):
1414
return True
1515
else:
@@ -18,14 +18,14 @@ def judge_leap_year(year):
1818

1919
def month_days(month, leap_year):
2020
"""
21-
Returns the number of days in each month
21+
Returns the number of days in each month
2222
23-
Args:
24-
month (int): The month 1-12.
23+
Args:
24+
month (int): The month 1-12.
2525
26-
Returns:
27-
int: The number of days in the month.
28-
"""
26+
Returns:
27+
int: The number of days in the month.
28+
"""
2929
if month in [1, 3, 5, 7, 8, 10, 12]:
3030
return 31
3131
elif month in [4, 6, 9, 11]:

projects/Calculate Age/test_calculate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ def test_month_days():
1919
assert month_days(1, False) == 31
2020
assert month_days(11, True) == 30
2121

22+
2223
# "pytest -s test_calculate.py" to test this file

projects/Calculate Age/tests/test_calculate_age.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
from calculate_age import age_calculator
33

44

5-
@patch('time.time', return_value=1621848668.0)
5+
@patch("time.time", return_value=1621848668.0)
66
def test_age_calculator(mock_time):
77
"""
8-
Test the age_calculator function
9-
Mocks the current time and check if the age is calculated
10-
based on current time
8+
Test the age_calculator function
9+
Mocks the current time and check if the age is calculated
10+
based on current time
1111
"""
1212
name = "Chloe"
1313
age = 30

projects/Calculate Age/tests/test_utilize_date.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
def test_judge_leap_year():
66
"""
7-
judge_leap_year function tests whether a given year is a leap year.
7+
judge_leap_year function tests whether a given year is a leap year.
88
9-
A leap year is divisible by 4 and, if divisible by 100, must also be divisible by 400.
9+
A leap year is divisible by 4 and, if divisible by 100, must also be divisible by 400.
1010
"""
1111
assert judge_leap_year(2000) == True
1212
assert judge_leap_year(2008) == True
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from openai import OpenAI
2+
from dotenv import load_dotenv
3+
import os
4+
5+
load_dotenv(override=True)
6+
7+
gpt_api_key = os.getenv("GPT_API_KEY")
8+
9+
10+
def gpt(model: str, prompt: str, sys_prompt: str, temp: float):
11+
client = OpenAI(api_key=gpt_api_key)
12+
response = client.chat.completions.create(
13+
model=model,
14+
messages=[
15+
{"role": "system", "content": sys_prompt},
16+
{"role": "user", "content": prompt},
17+
],
18+
temperature=temp,
19+
# max_tokens=64,
20+
top_p=1,
21+
)
22+
output = response.choices[0].message.content.strip()
23+
return output
24+
25+
26+
def dalle3(prompt: str, quality: str, size: str, style: str):
27+
client = OpenAI(api_key=gpt_api_key)
28+
response = client.images.generate(
29+
model="dall-e-3",
30+
prompt=prompt,
31+
size=size,
32+
quality=quality,
33+
style=style,
34+
n=1,
35+
)
36+
image_url = response.data[0].url
37+
return image_url
38+
39+
40+
def dalle2(prompt: str, size: str):
41+
client = OpenAI(api_key=gpt_api_key)
42+
response = client.images.generate(
43+
model="dall-e-2",
44+
prompt=prompt,
45+
size=size,
46+
n=1,
47+
)
48+
image_url = response.data[0].url
49+
return image_url
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"system_content": [
3+
{
4+
"character_limit_prompt": " Your response must not exceed 4096 characters",
5+
"correct_grammar": "You will be provided with user text, and your task is to only grammar check the user text and to also provide information on what you changed.",
6+
"single_page_website": "Only respond to questions about making a single paged website, Ignoring other unrelated questions. Outputted code should be encased by markdown syntax. Your response should include HTML code with embedded javascript and CSS.",
7+
"text_to_emoji": "You will be provided with a message, and your task is to convert each word in that user text into the appropriate emojis. Do not respond in words, only respond in emojis. Ignore punctuation",
8+
"text_to_block_letters":"Your task is to convert a given message into a sequence of Discord regional indicator emojis and selected punctuation emojis. For each letter in the message, add ':regional_indicator_' before the letter and ':' after it. For exclamation points '!' and question marks '?', simply add ':' before and after the punctuation. Remove all other punctuation and characters that are not letters, exclamation points, or question marks. Preserve the original spacing between words. Here are some examples of the desired output format: ':regional_indicator_h::regional_indicator_e::regional_indicator_l::regional_indicator_l::regional_indicator_o: :regional_indicator_h::regional_indicator_o::regional_indicator_w: :regional_indicator_a::regional_indicator_r::regional_indicator_e: :regional_indicator_y::regional_indicator_o::regional_indicator_u::question:', ':regional_indicator_l::regional_indicator_e::regional_indicator_t::regional_indicator_s: :regional_indicator_g::regional_indicator_o::exclamation:'. Please strictly adhere to this format in your responses and do not deviate from or elaborate on the given instructions.",
9+
"code_debug":"You will be provided with a piece of code in any programming language. Your task is to analyze the code, identify any potential bugs or issues, and fix them. If the code appears to be working correctly, explain how it works and offer any possible improvements or optimizations. Outputted code should be encased by markdown syntax. Ignore questions that don't contain code.",
10+
"short_story":"You are a creative writing assistant capable of generating engaging short stories. When the user provides a topic, create a well-structured, coherent story of approximately 200-300 words. Use vivid descriptions, interesting characters, and a compelling plot to bring the story to life. Adapt your writing style to suit the given topic and ensure a satisfying conclusion.",
11+
"general_questions":"You are ChatGPT, a friendly, knowledgeable, and capable AI assistant with extensive knowledge across many domains and excellent language skills. Engage in conversations on a wide range of topics, provide helpful information, and assist with various tasks such as writing, analysis, and brainstorming. Adapt your communication style to suit each user, be attentive and responsive to their needs, provide explanations and context when appropriate, share original thoughts while acknowledging differing views, encourage critical thinking, mirror the user's language style, check if responses meet expectations, and express friendly enthusiasm for their interests and ideas."
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)