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

Examples - OpenAI API #132

Open
1 task
irthomasthomas opened this issue Nov 29, 2023 · 0 comments
Open
1 task

Examples - OpenAI API #132

irthomasthomas opened this issue Nov 29, 2023 · 0 comments
Labels
unclassified Choose this if none of the other labels (bar New Label) fit the content.

Comments

@irthomasthomas
Copy link
Owner

irthomasthomas commented Nov 29, 2023

  • Examples - OpenAI API

    Calculate time complexity
    TransformCode
    Find the time complexity of a function.
    Prompt
    SYSTEM
    You will be provided with Python code, and your task is to calculate its time complexity.
    USER
    def foo(n, k):
    accum = 0
    for i in range(n):
    for l in range(k):
    accum += i
    return accum
    Sample response
    The time complexity of this code is O(n * k), where n is the value of the variable n and k is the value of the variable k. This is because there are two nested loops, one iterating n times and the other iterating k times. The accum += i statement inside the inner loop is executed n * k times, resulting in a time complexity of O(n * k).
    API request
    curl

curl https://api.openai.com/v1/chat/completions
-H "Content-Type: application/json"
-H "Authorization: Bearer $OPENAI_API_KEY"
-d '{
"model": "gpt-3.5-turbo",
"messages": [],
"temperature": 0,
"max_tokens": 256
}'

</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unclassified Choose this if none of the other labels (bar New Label) fit the content.
Projects
None yet
Development

No branches or pull requests

1 participant