B00TK1D / copilot-api

GitHub Copilot API
MIT License
175 stars 27 forks source link

complete code snippet #13

Open j0bekt01 opened 4 months ago

j0bekt01 commented 4 months ago

could you show us how to iteratively get a complete code snippet. I've tried many times but only got a first line.

rajagopalreddykontham commented 4 months ago

Do we require Copilot subscription to get replies when we sent prompt

j0bekt01 commented 4 months ago

yes

psybers commented 1 month ago

You can iterate like this:

def copilot_iter(prompt, language='python'):
    original = prompt
    while True:
        result = copilot(prompt, language)
        if result == '\n\n':
            break
        prompt += result
    return prompt[len(original) + 1:].replace('\n\n', '\n') + '\n'

Just add that function to the original app.py and then call it instead of calling copilot() on line 154:

https://github.com/B00TK1D/copilot-api/blob/27e36477866311ec9501f34b1fd95cb6d5a88e98/api.py#L154