Skip to content

Commit

Permalink
Merge pull request #361 from cofacts/choosing-media-articles
Browse files Browse the repository at this point in the history
refactor: combine processMedia and processImage
  • Loading branch information
MrOrz committed Sep 2, 2023
2 parents 355f2f6 + 03f2cf8 commit 29d596e
Show file tree
Hide file tree
Showing 17 changed files with 1,805 additions and 2,082 deletions.
386 changes: 195 additions & 191 deletions i18n/ja.po

Large diffs are not rendered by default.

385 changes: 196 additions & 189 deletions i18n/zh_TW.po

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions src/graphql/cofacts-api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ type Article implements Node {
Automated reply from AI before human fact checkers compose an fact check
"""
aiReplies: [AIReply!]!

"""Automated transcript"""
aiTranscripts: [AITranscript!]!
articleCategories(
"""
Deprecated. Please use statuses instead. When specified, returns only article categories with the specified status
Expand Down Expand Up @@ -684,6 +687,9 @@ interface AIResponse implements Node {
enum AIResponseTypeEnum {
"""The AI Response is an automated analysis / reply of an article."""
AI_REPLY

"""AI transcribed text of the specified article."""
TRANSCRIPT
}

enum AIResponseStatusEnum {
Expand All @@ -698,6 +704,30 @@ type OpenAICompletionUsage {
totalTokens: Int!
}

"""
Transcript from OCR or speech-to-text AI models for the specified MediaEntry ID as docId.
"""
type AITranscript implements Node & AIResponse {
id: ID!

"""The id for the document that this AI response is for."""
docId: ID

"""AI response type"""
type: AIResponseTypeEnum!

"""The user triggered this AI response"""
user: User

"""Processing status of AI"""
status: AIResponseStatusEnum!

"""AI response text. Populated after status becomes SUCCESS."""
text: String
createdAt: String!
updatedAt: String
}

"""The linkage between an Article and a Category"""
type ArticleCategory implements Node {
id: ID!
Expand Down Expand Up @@ -841,6 +871,12 @@ type ArticleConnectionEdge implements Edge {
cursor: String!
score: Float
highlight: Highlights

"""
The search hit's similarity with provided mediaUrl.
Ranges from 0 to 1. 0 if mediaUrl is not provided, or the hit is not matched by mediaUrl.
"""
mediaSimilarity: Float!
}

type ArticleConnectionPageInfo implements PageInfo {
Expand Down
74 changes: 0 additions & 74 deletions src/webhook/handlers/__fixtures__/processImage.js

This file was deleted.

54 changes: 0 additions & 54 deletions src/webhook/handlers/__fixtures__/processMedia.js

This file was deleted.

124 changes: 124 additions & 0 deletions src/webhook/handlers/__fixtures__/processMedia.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { ListArticlesInProcessMediaQuery } from 'typegen/graphql';

export const oneImageArticle: GqlResponse<ListArticlesInProcessMediaQuery> = {
data: {
ListArticles: {
edges: [
{
score: 87,
node: {
articleType: 'IMAGE',
attachmentUrl: 'http://foo/image.jpeg',
id: 'image-article-1',
},
mediaSimilarity: 0.87,
highlight: null,
},
],
},
},
};

export const oneIdenticalImageArticle: GqlResponse<ListArticlesInProcessMediaQuery> =
{
data: {
ListArticles: {
edges: [
{
score: 100,
node: {
articleType: 'IMAGE',
attachmentUrl: 'http://foo/image.jpeg',
id: 'image-article-1',
},
mediaSimilarity: 1,
highlight: null,
},
],
},
},
};

export const identicalImageAndTextFound: GqlResponse<ListArticlesInProcessMediaQuery> =
{
data: {
ListArticles: {
edges: [
{
score: 100,
mediaSimilarity: 1,
node: {
articleType: 'IMAGE',
attachmentUrl: 'http://foo/image.jpeg',
id: 'image-article-1',
},
highlight: null,
},
{
score: 87.6656,
mediaSimilarity: 0,
node: {
articleType: 'TEXT',
attachmentUrl: null,
id: 'text-article-1',
},
highlight: {
text: 'Text matching <HIGHLIGHT>query transcript</HIGHLIGHT>',
hyperlinks: [
{
title:
'Hyperlink title matching <HIGHLIGHT>query transcript</HIGHLIGHT>',
summary:
'Hyperlink summary matching <HIGHLIGHT>query transcript</HIGHLIGHT>',
},
],
},
},
],
},
},
};

export const twelveImageArticles: GqlResponse<ListArticlesInProcessMediaQuery> =
{
data: {
ListArticles: {
edges: Array.from(Array(6)).reduce<
NonNullable<ListArticlesInProcessMediaQuery['ListArticles']>['edges']
>(
(arr) =>
arr.concat([
{
score: 100,
mediaSimilarity: 1,
node: {
articleType: 'IMAGE',
attachmentUrl: 'http://foo/image.jpeg',
id: 'image-article-1',
},
highlight: null,
},
{
score: 87.6656,
mediaSimilarity: 0.87,
node: {
articleType: 'IMAGE',
attachmentUrl: 'http://foo/image2.jpeg',
id: 'image-article-2',
},
highlight: null,
},
]),
[]
),
},
},
};

export const notFound: GqlResponse<ListArticlesInProcessMediaQuery> = {
data: {
ListArticles: {
edges: [],
},
},
};
Loading

0 comments on commit 29d596e

Please sign in to comment.