ChatGPT
ChatGPT copied to clipboard
API to get auto-generated titles
Is your feature request related to a problem? Please describe. Webapp provides nicely summarized conversations. It'd be great if API you provide could use them
Describe the solution you'd like
Perfect (yet, likely impossible) solution would be to return title with ask()
callm, but since it's probably a separate call which might happen later, other solution would be to add new method def get_title(id:str) -> str:
or something like that.
Thanks for the nice library! And have a look at my other issue when possible (https://github.com/acheong08/ChatGPT/issues/418) :) Couldn't really resolve it myself since im not from the web\python world. Cheers o/
Looking at how webapp works, it doesn't look too complicated, or even long to process the request. smth like
def gen_title(self, id, message_id):
url = BASE_URL + f"backend-api/conversation/gen_title/{id}"
print(f"Request to '{url}")
response = self.session.post(url, data=f'{{"message_id": {message_id}, "model": "text-davinci-002-render"}}')
self.check_response(response)
data = json.loads(response.text)
return data
-def ask(self, prompt, conversation_id=None, parent_id=None):
+def ask(self, prompt, conversation_id=None, parent_id=None, gen_title = False):
...
+new_conv = data["conversation_id"] is None
...
- return {
- "message": message,
- "conversation_id": self.conversation_id,
- "parent_id": self.parent_id,
- }
+ res = {
+ "message": message,
+ "conversation_id": self.conversation_id,
+ "parent_id": self.parent_id,
+ }
+ if gen_title and new_conv:
+ try:
+ res["title"] = self.gen_title(self.conversation_id, self.parent_id)
+ except:
+ res["title"] = prompt[:16] + ("..." if len(prompt)>16 else "")
+
+ return res
Not opening a PR as I suppose my codestyle is off
tbh when I was testing for the Dec15 update features I saw this call in the network log but I didnt think it was important enougn to add, but if you feel its important, go make a PR
Yeah, I'll arrange one - fixed an error initial sample code above had
https://github.com/acheong08/ChatGPT/pull/431