DeepTeam is a framework to red team LLMs and AI agents.
added schema injection
A-Vamshi981a7820326e
diff --git a/docs/src/components/SchemaInjector/SchemaInjector.tsx b/docs/src/components/SchemaInjector/SchemaInjector.tsxnew file mode 100644index 00000000..8a1d3a28--- /dev/null+++ b/docs/src/components/SchemaInjector/SchemaInjector.tsx@@ -0,0 +1,20 @@+import React from 'react';+import Head from '@docusaurus/Head';++interface SchemaInjectorProps {+ schema: Record<string, any> | null | undefined;+}++export default function SchemaInjector({ schema }: SchemaInjectorProps) {+ if (!schema || Object.keys(schema).length === 0) {+ return null;+ }++ return (+ <Head>+ <script type="application/ld+json">+ {JSON.stringify(schema)}+ </script>+ </Head>+ );+}\ No newline at end of filediff --git a/docs/src/pages/blog.tsx b/docs/src/pages/blog.tsxindex 1d672c7f..7c0dcb3c 100644--- a/docs/src/pages/blog.tsx+++ b/docs/src/pages/blog.tsx@@ -4,6 +4,8 @@ import LayoutProvider from "@theme/Layout/Provider";import Footer from "@theme/Footer";import Navbar from "@theme/Navbar";import Link from "@docusaurus/Link";+import SchemaInjector from "../components/SchemaInjector/SchemaInjector";+import { buildBlogHomeSchema } from "@site/src/utils/schema-helpers";interface AuthorData {name: string;@@ -189,8 +191,11 @@ class Index extends React.Component<Record<string, unknown>, IndexState> {render(): ReactNode {const { blogs, authors, loading, error } = this.state;+ const blogHomeSchema = blogs.length > 0 ? buildBlogHomeSchema(blogs) : null;+return (<div className={styles.blogHomeContainer}>+ {blogHomeSchema && <SchemaInjector schema={blogHomeSchema} />}<div className={styles.blogHeroCard}><div className={styles.content}><span className={styles.tag}>Blog</span>diff --git a/docs/src/theme/BlogPostPage/index.tsx b/docs/src/theme/BlogPostPage/index.tsxnew file mode 100644index 00000000..c12ecd7d--- /dev/null+++ b/docs/src/theme/BlogPostPage/index.tsx@@ -0,0 +1,33 @@+import React, { type ReactNode, useMemo } from 'react';+import BlogPostPage from '@theme-original/BlogPostPage';+import type BlogPostPageType from '@theme/BlogPostPage';+import type { WrapperProps } from '@docusaurus/types';+import SchemaInjector from '@site/src/components/SchemaInjector/SchemaInjector';+import { buildArticleSchema } from '@site/src/utils/schema-helpers';++type Props = WrapperProps<typeof BlogPostPageType>;++export default function BlogPostPageWrapper(props: Props): ReactNode {+ const { metadata, frontMatter } = props.content;++ const articleSchema = useMemo(() => {++ const authorNames = metadata.authors?.map((author: any) => author.name) || frontMatter.authors;++ return buildArticleSchema({+ title: metadata.title,+ description: frontMatter.description as string || metadata.description,+ url: metadata.permalink,+ datePublished: metadata.date,+ authors: authorNames as string[] | undefined,+ image: frontMatter.image as string | undefined,+ });+ }, [metadata, frontMatter]);++ return (+ <>+ <SchemaInjector schema={articleSchema} />+ <BlogPostPage {...props} />+ </>+ );+}diff --git a/docs/src/theme/DocItem/Layout/index.tsx b/docs/src/theme/DocItem/Layout/index.tsxnew file mode 100644index 00000000..8ea54216--- /dev/null+++ b/docs/src/theme/DocItem/Layout/index.tsx@@ -0,0 +1,53 @@+import React, { type ReactNode, useMemo } from 'react';+import Layout from '@theme-original/DocItem/Layout';+import type LayoutType from '@theme/DocItem/Layout';+import type { WrapperProps } from '@docusaurus/types';+import { useDoc } from '@docusaurus/plugin-content-docs/client';+import SchemaInjector from '@site/src/components/SchemaInjector/SchemaInjector';+import { buildArticleSchema, buildProductSchema, buildBreadcrumbSchema } from '@site/src/utils/schema-helpers';++type Props = WrapperProps<typeof LayoutType>;++export default function LayoutWrapper(props: Props): ReactNode {+ const { frontMatter, metadata } = useDoc();++ const breadcrumbs = (props as any).route?.context?.breadcrumbs || [];+ const breadcrumbTrail = breadcrumbs.map((crumb: any) => ({+ name: crumb.label,+ url: crumb.href,+ }));+ const breadcrumbSchema = useMemo(() => buildBreadcrumbSchema(breadcrumbTrail), [breadcrumbs]);++ const isProduct =+ metadata.permalink.includes('adversarial-attacks-') ||+ metadata.permalink.includes('agentic-attacks-') ||+ metadata.permalink.includes('vulnerabilities-');++ const mainSchema = useMemo(() => {+ if (isProduct) {+ return buildProductSchema({+ name: metadata.title,+ description: frontMatter.description as string || metadata.description || `Learn about ${metadata.title} in LLM red teaming.`,+ url: metadata.permalink,+ image: frontMatter.image as string | undefined,+ });+ } else {+ return buildArticleSchema({+ title: metadata.title,+ description: frontMatter.description as string || metadata.description,+ url: metadata.permalink,+ datePublished: (frontMatter as any).date ? new Date((frontMatter as any).date as string).toISOString() : undefined,+ authors: (frontMatter as any).authors as string[] | undefined,+ image: frontMatter.image as string | undefined,+ });+ }+ }, [metadata, frontMatter, isProduct]);++ return (+ <>+ <SchemaInjector schema={breadcrumbSchema} />+ <SchemaInjector schema={mainSchema} />+ <Layout {...props} />+ </>+ );+}diff --git a/docs/src/utils/schema-helpers.ts b/docs/src/utils/schema-helpers.tsnew file mode 100644index 00000000..300b95b9--- /dev/null+++ b/docs/src/utils/schema-helpers.ts@@ -0,0 +1,181 @@+const BASE_URL = "https://trydeepteam.com";++export interface ArticleSchemaProps {+ title: string+ url: string;+ description?: string;+ datePublished?: string;+ dateModified?: string;+ authors?: (string | undefined)[] | undefined;+ image?: string;+}++export interface BreadcrumbItem {+ name: string;+ url?: string;+}++export interface ProductSchemaProps {+ name: string;+ description: string;+ url: string;+ image?: string;+}++export interface Author {+ name: string;+ title: string;+ url: string;+ image_url: string;+}++export interface BlogPost {+ title: string;+ description: string;+ slug: string;+ authors: string[];+ date: string;+}++export function buildWebSiteSchema(): object {+ return {+ "@context": "https://schema.org",+ "@type": "WebSite",+ name: "DeepTeam by Confident AI - The LLM Red Teaming Framework",+ url: BASE_URL,+ };+}++export function buildArticleSchema({+ title,+ description,+ url,+ datePublished,+ dateModified,+ authors,+ image,+}: ArticleSchemaProps): object {+ const authorSchema = authors && authors.length > 0+ ? authors.map(name => ({+ "@type": "Person",+ name: name,+ }))+ : undefined;++ return {+ "@context": "https://schema.org",+ "@type": "TechArticle",+ headline: title,+ ...(description ? { description } : {}),+ ...(image ? { image } : {}),+ ...(datePublished ? { datePublished } : {}),+ ...(dateModified ? { dateModified } : {}),+ mainEntityOfPage: {+ "@type": "WebPage",+ "@id": `${BASE_URL}${url}`+ },+ ...(authorSchema+ ? { author: authorSchema.length === 1 ? authorSchema[0] : authorSchema }+ : {}+ ),+ publisher: {+ "@type": "Organization",+ name: "Confident AI Inc.",+ url: BASE_URL,+ logo: {+ "@type": "ImageObject",+ url: `${BASE_URL}/icons/DeepTeam.svg`+ },+ },+ };+}++export function buildBreadcrumbSchema(trail: BreadcrumbItem[]): object | null {+ if (!trail || trail.length === 0) return null;++ const items: object[] = [+ { "@type": "ListItem", position: 1, name: "Home", item: BASE_URL }+ ];++ let currentPosition = 2;++ trail.forEach((crumb, i) => {+ const isLast = i === trail.length - 1;+ let itemUrl = crumb.url;++ if (itemUrl) {+ if (itemUrl.startsWith('/')) {+ itemUrl = `${BASE_URL}${itemUrl}`;+ } else if (!itemUrl.startsWith('http')) {+ itemUrl = `${BASE_URL}/${itemUrl}`;+ }+ }++ if (itemUrl || isLast) {+ items.push({+ "@type": "ListItem",+ position: currentPosition,+ name: crumb.name,+ ...(!isLast && itemUrl ? { item: itemUrl } : {}),+ });+ currentPosition++;+ }+ });++ return {+ "@context": "https://schema.org",+ "@type": "BreadcrumbList",+ itemListElement: items,+ };+}++export function buildBlogHomeSchema(posts: BlogPost[]): object {+ return {+ "@context": "https://schema.org",+ "@type": "Blog",+ name: "DeepTeam AI Safety Blog",+ description: "Insights, research, and discoveries in LLM red teaming, AI safety, and adversarial testing from the DeepTeam community.",+ url: `${BASE_URL}/blog`,+ publisher: {+ "@type": "Organization",+ name: "Confident AI Inc.",+ logo: {+ "@type": "ImageObject",+ url: `${BASE_URL}/icons/DeepTeam.svg`,+ },+ },+ blogPost: posts.map((post) => ({+ "@type": "BlogPosting",+ headline: post.title,+ url: `${BASE_URL}/blog/${post.slug}`,+ datePublished: post.date,+ description: post.description,+ })),+ };+}++export function buildProductSchema({+ name,+ description,+ url,+ image,+}: ProductSchemaProps): object {+ return {+ "@context": "https://schema.org",+ "@type": "Product",+ name,+ description,+ url: `${BASE_URL}${url}`,+ image: image ? image : `${BASE_URL}/icons/DeepTeam.svg`,+ brand: {+ "@type": "Organization",+ name: "Confident AI Inc.",+ },+ offers: {+ "@type": "Offer",+ price: "0",+ priceCurrency: "USD",+ availability: "https://schema.org/InStock",+ },+ };+}