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

[BREAKING] [Feat] Multi round responding #13

Merged
merged 7 commits into from
Jul 8, 2023
Merged

Conversation

RockChinQ
Copy link
Owner

@RockChinQ RockChinQ commented Jul 8, 2023

This PR made some Breaking Changes

  • Session.ask is now a iterator
  • Session.ask yield GPT's response before calling function
  • If GPT returns a non-function-calling(normal message) response, Session.ask yield it and finish.

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
Copy link
Owner Author

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

@RockChinQ RockChinQ added the enhancement New feature or request label Jul 8, 2023
@RockChinQ RockChinQ marked this pull request as ready for review July 8, 2023 02:09
@RockChinQ RockChinQ merged commit f775613 into main Jul 8, 2023
@RockChinQ RockChinQ deleted the feat-multi-round-resp branch July 8, 2023 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to bypass function excecution return msg, only show next TEXT return msg
1 participant