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

Support AI reply for articles #299

Merged
merged 21 commits into from
Apr 1, 2023
Merged

Support AI reply for articles #299

merged 21 commits into from
Apr 1, 2023

Conversation

MrOrz
Copy link
Member

@MrOrz MrOrz commented Mar 26, 2023

Design doc: https://g0v.hackmd.io/@cofacts/rd/%2F%40cofacts%2FrknFrmdk3

  • AIResponse type has been extended to an interface, with AIReply being one of the implementation
    • In the future we may leverage OpenAI's whisper for speech-to-text. Its response is slightly different (no usage field).
    • Thus it makes sense we use different object types to model these different AI responses.
  • CreateAIReply mutation that returns AIReply
    • As planned in design doc
    • It creates an AIResponse with its type being AIReply, and status being LOADING initially, turns SUCCESS (or FAIL) after ChatGPT API returns.
    • If there is another process that inserted a loading AIReply, CreateAIReply will start polling Elasticsearch until one of the following happens:
      • Any AIReply for the article turns "SUCCESS"
      • There are no loading AI Replies in the latest 1 minute anymore
  • aiReplies field in Article
    • As planned in design doc
  • Move delayForMs to under src/util/
    • Because it's also used in resolver logic now

Article's aiReplies

image

@coveralls
Copy link

coveralls commented Mar 26, 2023

Coverage Status

Coverage: 88.029% (+0.03%) from 88.003% when pulling f2f9aa9 on ai-response into 7886f6d on master.

@MrOrz
Copy link
Member Author

MrOrz commented Mar 26, 2023

Deploy steps

  1. npm run schema -- airesponses in rumors-db
  2. Supply OPENAI_API_KEY to API env
  3. Update API server

@MrOrz MrOrz requested a review from nonumpa April 1, 2023 14:54
@MrOrz MrOrz marked this pull request as ready for review April 1, 2023 14:54
@MrOrz MrOrz self-assigned this Apr 1, 2023
@MrOrz MrOrz merged commit 306e2ea into master Apr 1, 2023
@MrOrz MrOrz deleted the ai-response branch April 1, 2023 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants