RockChinQ / CallingGPT

Build your own ChatGPT plugin platform with GPT's function calling ability | func call by GPT
66 stars 3 forks source link

[BREAKING] [Feat] Multi round responding #13

Closed RockChinQ closed 1 year ago

RockChinQ commented 1 year ago

This PR made some Breaking Changes

Practice

from CallingGPT.session.session import Session

from examples import draw_and_wrapper_md

import openai
import os

openai.api_key = os.environ["openai_apikey"]

ns = Session([draw_and_wrapper_md])

iter = ns.ask("draw a cat, then convert to markdown")

for n in iter:
    print(n)

outputs:

$ python test.py 
{
  "role": "assistant",
  "content": null,
  "function_call": {
    "name": "examples-draw_and_wrapper_md-draw",
    "arguments": "{\n  \"prompt\": \"cat\"\n}"
  }
}
{
  "role": "assistant",
  "content": null,
  "function_call": {
    "name": "examples-draw_and_wrapper_md-output_img_as_md",
    "arguments": "{\n  \"img\": \"https://oaidalleapiprodscus.blob.core.windows.net/private/org-VS9HEpJba78GXVfOcmVo7qaM/user-OHa7Jo3kL4XJDg9lo7AzdWNT/img-qsC6f6I0mg7WGa1U5M7IdgpY.png?st=2023-07-08T00%3A32%3A39Z&se=2023-07-08T02%3A32%3A39Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-07-07T22%3A11%3A30Z&ske=2023-07-08T22%3A11%3A30Z&sks=b&skv=2021-08-06&sig=L6RCx9RFpbjYZaixlNYWUov9kakIgdDN32KnKFQEBIg%3D\"\n}"
  }
}
{
  "role": "assistant",
  "content": "![Generated Image](https://oaidalleapiprodscus.blob.core.windows.net/private/org-VS9HEpJba78GXVfOcmVo7qaM/user-OHa7Jo3kL4XJDg9lo7AzdWNT/img-qsC6f6I0mg7WGa1U5M7IdgpY.png?st=2023-07-08T00%3A32%3A39Z&se=2023-07-08T02%3A32%3A39Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-07-07T22%3A11%3A30Z&ske=2023-07-08T22%3A11%3A30Z&sks=b&skv=2021-08-06&sig=L6RCx9RFpbjYZaixlNYWUov9kakIgdDN32KnKFQEBIg%3D)"
}
RockChinQ commented 1 year ago

For the sake of API simplicity, I have removed the previous ask function. Please understand.