You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for creating jupytee, this is an impressive tool!
And I want to suggest an idea:
The chat could happen directly in cells with the following code pattern.
importmatplotlib.pyplotaspltplt.plot([1,2], [10,20], c="orange") # @chat change the color to green
Like this, one can use already existing python code with an extra # @chat in the end of a line, no cell magic needed.
Here is how a prototype could look like (made with a drawing tool):
How to get there?
First challenge: Find a way for the AI to understand that it should manipulate a certain line. That is straight forward:
Second challenge:
Find a way to write an IPython input transformer that does the following things:
takes the code
extracts the line that contains # @chat"
creates the request message from the screenshot above.
That can be done like this:
defrun_with_gpt_listener(lines):
contains_gpt_call=Falsemy_message=""fornum, lineinenumerate(lines):
if"# @chat"inline:
_ , new_suggestion=line.split("# @chat")
contains_gpt_call=Truemy_message+=f"take the following code and make the following change to line {num+1}:"my_message+=new_suggestionmy_message+="\n"my_message+="```python\n"forlineinlines:
if"# @chat"inline:
code_without_comment , _=line.split("# @chat")
l=code_without_commentelse:
l=linemy_message+=lmy_message+="\n"my_message+="```"print(my_message)
returnlinesip=get_ipython()
ip.input_transformers_cleanup.append(run_with_gpt_listener)
and can be used like this:
Third challenge
Sent the request to OpenAI and print its response.
I did not implement that, but this request can be sent the same way it's also sent in the %%codemagic:
The prompt can be purely an instruction (in natural language), or it can consist of both an instruction and a block of code. If you want to provide code, it should come below the instruction, after a separator (which defaults to `##` but can be set with the `--sep` argumet).
The code is displayed as syntax-highlighted Markdown. If you want to get the code directly inserted into a cell for later execution, call the `%get_code` magic.
Example:
```
%%code
Please add a docstring to this function.
##
def add(a, b): return a+b
```
"""
args=parse_argstring(self.code, line)
input=""
ifcellisNone:
instruction=' '.join(args.prompt)
else:
parts=cell.split(args.sep)
iflen(parts) ==1:
instruction=cell
eliflen(parts) ==2:
instruction, input=parts
else:
print("Only one ## marker is supported", file=sys.stderr)
Thanks for creating jupytee, this is an impressive tool!
And I want to suggest an idea:
The chat could happen directly in cells with the following code pattern.
Like this, one can use already existing python code with an extra
# @chat
in the end of a line, no cell magic needed.Here is how a prototype could look like (made with a drawing tool):
How to get there?
First challenge: Find a way for the AI to understand that it should manipulate a certain line. That is straight forward:
Second challenge:
Find a way to write an IPython input transformer that does the following things:
# @chat"
That can be done like this:
and can be used like this:
Third challenge
Sent the request to OpenAI and print its response.
I did not implement that, but this request can be sent the same way it's also sent in the
%%code
magic:jupytee/jupytee/jupytee.py
Lines 117 to 159 in 3e19b0e
The text was updated successfully, but these errors were encountered: