Skip to content

Commit 1238452

Browse files
committed
prompt hub
1 parent 9d0d5fd commit 1238452

File tree

116 files changed

+2354
-16
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+2354
-16
lines changed

components/PromptFiles.jsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// components/PromptFiles.js
2+
import React, { useEffect, useState } from 'react';
3+
import { Cards, Card } from 'nextra-theme-docs';
4+
import { FilesIcon } from './icons'; // Ensure this path is correct for your project
5+
6+
const PromptFiles = ({ lang = 'en' }) => {
7+
const [promptsData, setPromptsData] = useState([]);
8+
9+
useEffect(() => {
10+
// Fetch the data from the API
11+
fetch(`/api/promptsFiles?lang=${lang}`)
12+
.then((response) => response.json())
13+
.then((data) => {
14+
// Assuming the API returns data structured as an array of objects
15+
setPromptsData(data);
16+
})
17+
.catch((error) => {
18+
console.error('Error fetching prompt files:', error);
19+
});
20+
}, [lang]);
21+
22+
return (
23+
<div>
24+
{promptsData.map(({ folderKey, folderName, files }) => (
25+
<section key={folderKey}>
26+
<br></br>
27+
<h2 class="nx-font-semibold nx-tracking-tight nx-text-slate-900 dark:nx-text-slate-100 nx-mt-10 nx-border-b nx-pb-1 nx-text-3xl nx-border-neutral-200/70 contrast-more:nx-border-neutral-400 dark:nx-border-primary-100/10 contrast-more:dark:nx-border-neutral-400">{folderName}
28+
<a href={`#${folderKey}`} id={folderKey} class="subheading-anchor" aria-label="Permalink for this section"></a>
29+
</h2>
30+
<Cards>
31+
{files.map(({ slug, title }) => (
32+
<Card
33+
key={slug}
34+
icon={<FilesIcon />} // This should be the icon component you want to use
35+
title={title}
36+
href={`/prompts/${folderKey}/${slug}`} // Adjust the href to match your routing pattern
37+
>
38+
{/* Additional content for each card, if any, goes here */}
39+
</Card>
40+
))}
41+
</Cards>
42+
</section>
43+
))}
44+
</div>
45+
);
46+
};
47+
48+
export default PromptFiles;
49+
50+

components/TabsComponent.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// In components/TabsComponent.tsx
2+
import React from 'react';
3+
import { Tabs, Tab } from 'nextra/components';
4+
5+
interface TabInfo {
6+
model: string;
7+
max_tokens: number;
8+
messages: Array<{ role: string; content: string }>;
9+
}
10+
11+
interface TabsComponentProps {
12+
tabsData: TabInfo[];
13+
}
14+
15+
const TabsComponent: React.FC<TabsComponentProps> = ({ tabsData }) => {
16+
const renderCodeBlock = (tab: TabInfo) => {
17+
return `
18+
from openai import OpenAI
19+
client = OpenAI()
20+
21+
response = client.chat.completions.create(
22+
model="${tab.model}",
23+
messages=${JSON.stringify(tab.messages, null, 4)},
24+
temperature=1,
25+
max_tokens=${tab.max_tokens},
26+
top_p=1,
27+
frequency_penalty=0,
28+
presence_penalty=0
29+
)
30+
`;
31+
};
32+
33+
return (
34+
<Tabs items={tabsData.map(tab => tab.model)}>
35+
{tabsData.map((tab, index) => (
36+
<Tab key={index}>
37+
<pre><code data-language="python">{renderCodeBlock(tab)}</code></pre>
38+
</Tab>
39+
))}
40+
</Tabs>
41+
);
42+
};
43+
44+
export default TabsComponent;

pages/_meta.ca.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introduction",
44
"techniques": "Techniques",
55
"applications": "Applications",
6+
"prompts": "Prompt Hub",
67
"models": "Models",
78
"risks": "Risks & Misuses",
89
"research": "LLM Research Findings",

pages/_meta.de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Einleitung",
44
"techniques": "Techniken",
55
"applications": "Anwendungen",
6+
"prompts": "Prompt Hub",
67
"models": "Modelle",
78
"risks": "Risiken & Missbrauch",
89
"research": "LLM Research Findings",

pages/_meta.en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introduction",
44
"techniques": "Techniques",
55
"applications": "Applications",
6+
"prompts": "Prompt Hub",
67
"models": "Models",
78
"risks": "Risks & Misuses",
89
"research": "LLM Research Findings",

pages/_meta.es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introducción",
44
"techniques": "Técnicas",
55
"applications": "Aplicaciones",
6+
"prompts": "Prompt Hub",
67
"models": "Modelos",
78
"risks": "Riesgos y Malos Usos",
89
"research": "LLM Research Findings",

pages/_meta.fi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introduction",
44
"techniques": "Techniques",
55
"applications": "Applications",
6+
"prompts": "Prompt Hub",
67
"models": "Models",
78
"risks": "Risks & Misuses",
89
"research": "LLM Research Findings",

pages/_meta.fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introduction",
44
"techniques": "Techniques",
55
"applications": "Applications",
6+
"prompts": "Prompt Hub",
67
"models": "Models",
78
"risks": "Risques et Mésusages",
89
"research": "LLM Research Findings",

pages/_meta.it.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introduzione",
44
"techniques": "Tecniche",
55
"applications": "Applicazioni",
6+
"prompts": "Prompt Hub",
67
"models": "Modelli",
78
"risks": "Rischi & Abusi",
89
"papers": "Articoli scientifici",

pages/_meta.jp.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"introduction": "Introduction",
44
"techniques": "Techniques",
55
"applications": "Applications",
6+
"prompts": "Prompt Hub",
67
"models": "Models",
78
"risks": "Risks & Misuses",
89
"research": "LLM Research Findings",

0 commit comments

Comments
 (0)