DSPy: The framework for programming—not prompting—language models
Python
Added Author Box
Herumb Shandilyadef8fffe7629
diff --git a/docs/components-in-dspy/data-handling/built-in-datasets.md b/docs/components-in-dspy/data-handling/built-in-datasets.mdxsimilarity index 98%rename from docs/components-in-dspy/data-handling/built-in-datasets.mdrename to docs/components-in-dspy/data-handling/built-in-datasets.mdxindex 6dc45d6de..b639ca2dc 100644--- a/docs/components-in-dspy/data-handling/built-in-datasets.md+++ b/docs/components-in-dspy/data-handling/built-in-datasets.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Utilizing Built-in DatasetsIt's easy to use your own data in DSPy: a dataset is just a list of `Example` objects. Using DSPy well involves being able to find and re-purpose existing datasets for your own pipelines in new ways; DSPy makes this a particularly powerful strategy.@@ -98,3 +100,7 @@ The `_shuffle_and_sample()` method does two things:Converting the raw examples into `Example` objects allows the Dataset class to process them in a standardized way later. For example, the collate method, which is used by the PyTorch DataLoader, expects each item to be an `Example`.To summarize, the `Dataset` class handles all the necessary data processing and provides a simple API to access the different splits. This differentiates from the dataset classes like HotpotQA which require only definitions on how to load the raw data.++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/components-in-dspy/data-handling/examples.md b/docs/components-in-dspy/data-handling/examples.mdxsimilarity index 97%rename from docs/components-in-dspy/data-handling/examples.mdrename to docs/components-in-dspy/data-handling/examples.mdxindex 5fc3c150a..2403600ee 100644--- a/docs/components-in-dspy/data-handling/examples.md+++ b/docs/components-in-dspy/data-handling/examples.mdx@@ -2,6 +2,8 @@sidebar_position: 1---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Examples in DSPyWorking in DSPy involves training sets, development sets, and test sets. This is like traditional ML, but you usually need far fewer labels (or zero labels) to use DSPy effectively.@@ -111,3 +113,7 @@ question = This is a question?answer = This is an answer.rationale = This is a rationale.```++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/components-in-dspy/data-handling/loading-custom-data.md b/docs/components-in-dspy/data-handling/loading-custom-data.mdxsimilarity index 98%rename from docs/components-in-dspy/data-handling/loading-custom-data.mdrename to docs/components-in-dspy/data-handling/loading-custom-data.mdxindex 3c78747e4..9102d1ec8 100644--- a/docs/components-in-dspy/data-handling/loading-custom-data.md+++ b/docs/components-in-dspy/data-handling/loading-custom-data.mdx@@ -2,6 +2,8 @@sidebar_position: 3---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Creating a Custom DatasetWe've seen how to work with with `Example` objects and use the `HotPotQA` class to load the HuggingFace HotPotQA dataset as a list of `Example` objects. But in production, such structured datasets are rare. Instead, you'll find yourself working on a custom dataset and might question: how do I create my own dataset or what format should it be?@@ -115,3 +117,7 @@ To prevent that you'll just need to make sure `_test` is not `None` and populateYou can overide the methods in `Dataset` class to customize your class even more.In summary, the Dataset base class provides a simplistic way to load and preprocess custom datasets with minimal code!++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/components-in-dspy/language_model_clients/custom-lm-client.md b/docs/components-in-dspy/language_model_clients/custom-lm-client.mdxsimilarity index 98%rename from docs/components-in-dspy/language_model_clients/custom-lm-client.mdrename to docs/components-in-dspy/language_model_clients/custom-lm-client.mdxindex 7b5549b39..edef34da3 100644--- a/docs/components-in-dspy/language_model_clients/custom-lm-client.md+++ b/docs/components-in-dspy/language_model_clients/custom-lm-client.mdx@@ -2,6 +2,8 @@sidebar_position: 3---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Creating a Custom Local Model (LM) ClientDSPy provides you with multiple LM clients that you can use to execute any of your pipelines. However, if you have an API or LM that is unable to be executed by any of the existing clients hosted in DSPy, you can create one yourself!! It's not too difficult so let's see how!!@@ -150,4 +152,8 @@ import dspyclaude = Claude(model='claude-2')dspy.settings.configure(lm=claude)-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/language_model_clients/local_models/HFClientTGI.md b/docs/components-in-dspy/language_model_clients/local_models/HFClientTGI.mdxsimilarity index 97%rename from docs/components-in-dspy/language_model_clients/local_models/HFClientTGI.mdrename to docs/components-in-dspy/language_model_clients/local_models/HFClientTGI.mdxindex f264acdb4..0a0f4531b 100644--- a/docs/components-in-dspy/language_model_clients/local_models/HFClientTGI.md+++ b/docs/components-in-dspy/language_model_clients/local_models/HFClientTGI.mdx@@ -1,3 +1,5 @@+import AuthorDetails from '@site/src/components/AuthorDetails';+## [HFClient TGI](https://github.com/huggingface/text-generation-inference)### Prerequisites - Launching TGI Server locally@@ -81,4 +83,8 @@ print(response.answer)```pythonresponse = tgi_llama2._generate(prompt='What is the capital of Paris?')print(response)-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/language_model_clients/local_models/HFClientVLLM.md b/docs/components-in-dspy/language_model_clients/local_models/HFClientVLLM.mdxsimilarity index 96%rename from docs/components-in-dspy/language_model_clients/local_models/HFClientVLLM.mdrename to docs/components-in-dspy/language_model_clients/local_models/HFClientVLLM.mdxindex 3fb2108fa..66eb63f1d 100644--- a/docs/components-in-dspy/language_model_clients/local_models/HFClientVLLM.md+++ b/docs/components-in-dspy/language_model_clients/local_models/HFClientVLLM.mdx@@ -1,3 +1,5 @@+import AuthorDetails from '@site/src/components/AuthorDetails';+## [HFClient vLLM](https://github.com/vllm-project/vllm)### Prerequisites - Launching vLLM Server locally@@ -73,4 +75,8 @@ print(response.answer)```pythonresponse = vllm_llama2._generate(prompt='What is the capital of Paris?')print(response)-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/language_model_clients/remote_models/Anyscale.md b/docs/components-in-dspy/language_model_clients/remote_models/Anyscale.mdxsimilarity index 96%rename from docs/components-in-dspy/language_model_clients/remote_models/Anyscale.mdrename to docs/components-in-dspy/language_model_clients/remote_models/Anyscale.mdxindex 213892030..9dc946542 100644--- a/docs/components-in-dspy/language_model_clients/remote_models/Anyscale.md+++ b/docs/components-in-dspy/language_model_clients/remote_models/Anyscale.mdx@@ -1,3 +1,5 @@+import AuthorDetails from '@site/src/components/AuthorDetails';+## Anyscale### Prerequisites@@ -80,4 +82,8 @@ print(response.answer)```pythonresponse = anyscale(prompt='What is the capital of Paris?')print(response)-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/language_model_clients/remote_models/Cohere.md b/docs/components-in-dspy/language_model_clients/remote_models/Cohere.mdxsimilarity index 96%rename from docs/components-in-dspy/language_model_clients/remote_models/Cohere.mdrename to docs/components-in-dspy/language_model_clients/remote_models/Cohere.mdxindex e00afbb3a..a582da08b 100644--- a/docs/components-in-dspy/language_model_clients/remote_models/Cohere.md+++ b/docs/components-in-dspy/language_model_clients/remote_models/Cohere.mdx@@ -1,3 +1,5 @@+import AuthorDetails from '@site/src/components/AuthorDetails';+## Cohere### Prerequisites@@ -80,4 +82,8 @@ print(response.answer)```pythonresponse = cohere(prompt='What is the capital of Paris?')print(response)-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/language_model_clients/remote_models/OpenAI.md b/docs/components-in-dspy/language_model_clients/remote_models/OpenAI.mdxsimilarity index 96%rename from docs/components-in-dspy/language_model_clients/remote_models/OpenAI.mdrename to docs/components-in-dspy/language_model_clients/remote_models/OpenAI.mdxindex 1a6dbea3d..235da1aaf 100644--- a/docs/components-in-dspy/language_model_clients/remote_models/OpenAI.md+++ b/docs/components-in-dspy/language_model_clients/remote_models/OpenAI.mdx@@ -1,3 +1,5 @@+import AuthorDetails from '@site/src/components/AuthorDetails';+## OpenAI### Prerequisites@@ -75,3 +77,7 @@ print(response.answer)response = turbo(prompt='What is the capital of Paris?')print(response)```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/modules/chain-of-thought-with-hint.md b/docs/components-in-dspy/modules/chain-of-thought-with-hint.mdxsimilarity index 90%rename from docs/components-in-dspy/modules/chain-of-thought-with-hint.mdrename to docs/components-in-dspy/modules/chain-of-thought-with-hint.mdxindex 230e4cb7d..62691cf42 100644--- a/docs/components-in-dspy/modules/chain-of-thought-with-hint.md+++ b/docs/components-in-dspy/modules/chain-of-thought-with-hint.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# ChainOfThoughtWithHintThis class builds upon the `ChainOfThought` class by introducing an additional input field to provide hints for reasoning. The inclusion of a hint allows for a more directed problem-solving process, which can be especially useful in complex scenarios.@@ -27,4 +29,8 @@ pred = generate_answer(question=question, hint=hint)print(f"Question: {question}")print(f"Predicted Answer: {pred.answer}")-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/modules/guide.md b/docs/components-in-dspy/modules/guide.mdxsimilarity index 97%rename from docs/components-in-dspy/modules/guide.mdrename to docs/components-in-dspy/modules/guide.mdxindex b780904e8..eb511f39c 100644--- a/docs/components-in-dspy/modules/guide.md+++ b/docs/components-in-dspy/modules/guide.mdx@@ -1,4 +1,6 @@-## Guide: **DSPy Modules**+import AuthorDetails from '@site/src/components/AuthorDetails';++# Guide: DSPy Modules[<img align="center" src="https://colab.research.google.com/assets/colab-badge.svg" />](https://colab.research.google.com/github/stanfordnlp/dspy/blob/main/docs/guides/modules.ipynb)@@ -157,3 +159,7 @@ DSPy is just Python code that uses modules in any control flow you like. (There'What this means is that, you can just call the modules freely. No weird abstractions for chaining calls.This is basically PyTorch's design approach for define-by-run / dynamic computation graphs. Refer to the intro tutorials for examples.++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/modules/program-of-thought.md b/docs/components-in-dspy/modules/program-of-thought.mdxsimilarity index 98%rename from docs/components-in-dspy/modules/program-of-thought.mdrename to docs/components-in-dspy/modules/program-of-thought.mdxindex 27887b925..ecb676000 100644--- a/docs/components-in-dspy/modules/program-of-thought.md+++ b/docs/components-in-dspy/modules/program-of-thought.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Program of Thought## Background@@ -135,4 +137,8 @@ Reasoning: Let's think step by step in order to produce the answer. We start witAnswer: 12-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/modules/react.md b/docs/components-in-dspy/modules/react.mdxsimilarity index 98%rename from docs/components-in-dspy/modules/react.mdrename to docs/components-in-dspy/modules/react.mdxindex 930a59c90..bff31f648 100644--- a/docs/components-in-dspy/modules/react.md+++ b/docs/components-in-dspy/modules/react.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# ReAct## Background@@ -183,4 +185,8 @@ Thought 3: I have found that the Apple Remote and the Siri Remote can control thAction 3: Finish[The Apple Remote and the Siri Remote can control the Front Row media program.]Answer: The Apple Remote and the Siri Remote can control the Front Row media program.-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/modules/retrieve.md b/docs/components-in-dspy/modules/retrieve.mdxsimilarity index 95%rename from docs/components-in-dspy/modules/retrieve.mdrename to docs/components-in-dspy/modules/retrieve.mdxindex 922c2a6ed..8d4b38a9f 100644--- a/docs/components-in-dspy/modules/retrieve.md+++ b/docs/components-in-dspy/modules/retrieve.mdx@@ -1,3 +1,5 @@+import AuthorDetails from '@site/src/components/AuthorDetails';+# Retrieve## Background@@ -60,4 +62,8 @@ Top 3 passages for question: When was the first FIFA World Cup held?2] 1950 FIFA World Cup | The 1950 FIFA World Cup, held in Brazil from 24 June to 16 July 1950, [...].3] 1970 FIFA World Cup | The 1970 FIFA World Cup was the ninth FIFA World Cup, the quadrennial [...].-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/retrieval_models_clients/Azure.md b/docs/components-in-dspy/retrieval_models_clients/Azure.mdxsimilarity index 95%rename from docs/components-in-dspy/retrieval_models_clients/Azure.mdrename to docs/components-in-dspy/retrieval_models_clients/Azure.mdxindex 62d885847..24ee86222 100644--- a/docs/components-in-dspy/retrieval_models_clients/Azure.md+++ b/docs/components-in-dspy/retrieval_models_clients/Azure.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# AzureCognitiveSearch## Prerequisites@@ -74,4 +76,8 @@ retrieval_response = TODO('When was the first FIFA World Cup held?', k=5)for result in retrieval_response:print("Text:", result['text'], "\n")-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/retrieval_models_clients/ColBERTv2.md b/docs/components-in-dspy/retrieval_models_clients/ColBERTv2.mdxsimilarity index 96%rename from docs/components-in-dspy/retrieval_models_clients/ColBERTv2.mdrename to docs/components-in-dspy/retrieval_models_clients/ColBERTv2.mdxindex 40456916c..4a3288ba3 100644--- a/docs/components-in-dspy/retrieval_models_clients/ColBERTv2.md+++ b/docs/components-in-dspy/retrieval_models_clients/ColBERTv2.mdx@@ -2,6 +2,8 @@sidebar_position: 1---+import AuthorDetails from '@site/src/components/AuthorDetails';+# ColBERTv2## Setting up the ColBERTv2 Client@@ -70,4 +72,8 @@ retrieval_response = colbertv2_wiki17_abstracts('When was the first FIFA World Cfor result in retrieval_response:print("Text:", result['text'], "\n")-```\ No newline at end of file+```++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/retrieval_models_clients/custom-rm-client.md b/docs/components-in-dspy/retrieval_models_clients/custom-rm-client.mdxsimilarity index 98%rename from docs/components-in-dspy/retrieval_models_clients/custom-rm-client.mdrename to docs/components-in-dspy/retrieval_models_clients/custom-rm-client.mdxindex c3d2a323c..7b8d9c4c7 100644--- a/docs/components-in-dspy/retrieval_models_clients/custom-rm-client.md+++ b/docs/components-in-dspy/retrieval_models_clients/custom-rm-client.mdx@@ -2,6 +2,8 @@sidebar_position: 3---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Creating Custom RM ClientDSPy provides support for various retrieval modules out of the box like `ColBERTv2`, `AzureCognitiveSearch`, `Pinecone`, `Weaviate`, etc. Unlike Language Model (LM) modules, creating a custom RM module is much more simple and flexible.@@ -232,4 +234,8 @@ Now if you'd like to use a different RM, you can just update the `rm` parameterWhen we call `dspy.Retrieve` the `__call__` method will execute the `forward` method as is. In `forward`, the top-k passages are received by the `dsp.retrieveEnsemble` method in [search.py](https://github.com/stanfordnlp/dspy/blob/main/dsp/primitives/search.py).If an `rm` is not initialized in `dsp.settings`, this would raise an error.-:::\ No newline at end of file+:::++***++<AuthorDetails name="Arnav Singhvi"/>\ No newline at end of filediff --git a/docs/components-in-dspy/signature/executing-signatures.md b/docs/components-in-dspy/signature/executing-signatures.mdxsimilarity index 97%rename from docs/components-in-dspy/signature/executing-signatures.mdrename to docs/components-in-dspy/signature/executing-signatures.mdxindex 75f777309..07c104774 100644--- a/docs/components-in-dspy/signature/executing-signatures.md+++ b/docs/components-in-dspy/signature/executing-signatures.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Executing SignaturesSo far we've understood what signatures are and how we can use them to craft our prompt, but now let's take a look at how to execute them.@@ -119,4 +121,8 @@ How does `Predict` module actually 'predict' though? Here is a step-by-step breaIn case you are wondering how the prompt is constructed, the DSPy Signature framework internally handles the prompt structure, utilizing the DSP Template primitive to craft the prompt.-Predict gives you a predefined pipeline to execute signature which is nice but you can build much more complicated pipelines with this by creating custom Modules.\ No newline at end of file+Predict gives you a predefined pipeline to execute signature which is nice but you can build much more complicated pipelines with this by creating custom Modules.++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/components-in-dspy/signature/understanding-signatures.md b/docs/components-in-dspy/signature/understanding-signatures.mdxsimilarity index 98%rename from docs/components-in-dspy/signature/understanding-signatures.mdrename to docs/components-in-dspy/signature/understanding-signatures.mdxindex c47fb508f..0c14fd35a 100644--- a/docs/components-in-dspy/signature/understanding-signatures.md+++ b/docs/components-in-dspy/signature/understanding-signatures.mdx@@ -2,6 +2,8 @@sidebar_position: 1---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Understanding SignaturesA DSPy Signature is the most basic form of task description which simply requires inputs and outputs and optionally, a small description about them and the task too.@@ -115,3 +117,7 @@ Question:As you can see, the instruction is more well-defined by our task's instruction in the docstring. The prefix and description for the `answer` field reflects our definitions. This ensures a more refined prompt structure, giving the user more control on defining its contents per task requirements.++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/components-in-dspy/teleprompter/bootstrap-fewshot.md b/docs/components-in-dspy/teleprompter/bootstrap-fewshot.mdxsimilarity index 98%rename from docs/components-in-dspy/teleprompter/bootstrap-fewshot.mdrename to docs/components-in-dspy/teleprompter/bootstrap-fewshot.mdxindex 8268808f2..c2d85c9a1 100644--- a/docs/components-in-dspy/teleprompter/bootstrap-fewshot.md+++ b/docs/components-in-dspy/teleprompter/bootstrap-fewshot.mdx@@ -2,6 +2,8 @@sidebar_position: 1---+import AuthorDetails from '@site/src/components/AuthorDetails';+# BootstrapFewShotWhen compiling a DSPy program, we generally invoke a teleprompter, which is an optimizer that takes the program, a training set, and a metric—and returns a new optimized program. Different teleprompters apply different strategies for optimization. This family of teleprompters is focused on optimizing the few shot examples. Let's take an example of a Sample pipeline and see how we can use teleprompter to optimizes it.@@ -119,4 +121,8 @@ cot_compiled.save('turbo_gsm8k.json')8. If the prediction is successful, a demonstration (demo) is created for each step in the trace. This demo includes the inputs to the predictor and the outputs it generated.-This is how it works, aside from that. `BootstrapFewShotWithOptuna`, `BootstrapFewShotWithRandomSearch` etc. which work on the same principle with slight changes in the example discovery process.\ No newline at end of file+This is how it works, aside from that. `BootstrapFewShotWithOptuna`, `BootstrapFewShotWithRandomSearch` etc. which work on the same principle with slight changes in the example discovery process.++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/components-in-dspy/teleprompter/signature-optimizer.md b/docs/components-in-dspy/teleprompter/signature-optimizer.mdxsimilarity index 98%rename from docs/components-in-dspy/teleprompter/signature-optimizer.mdrename to docs/components-in-dspy/teleprompter/signature-optimizer.mdxindex 323430609..eef93d9de 100644--- a/docs/components-in-dspy/teleprompter/signature-optimizer.md+++ b/docs/components-in-dspy/teleprompter/signature-optimizer.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Signature Optimizer`SignatureOptimizer` which aims to improve the output prefixes and instruction of the signatures in a module in a zero/few shot setting. This teleprompter is especially beneficial for fine-tuning the prompt for language models and ensure they perform tasks more effectively, all from a vague and un refine prompt.@@ -158,3 +160,7 @@ Let's break down the process stepwise:4. **Outcome:** After m iterations, the system ideally converges to a set of highly optimized instructions and corresponding prefixes that lead to better performance of the language model on the given task.This iterative approach allows for continuous refinement of instructions and prefixes, leveraging the strengths of the teleprompter and improving task performance over time.++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docs/quick-start/minimal-example.md b/docs/quick-start/minimal-example.mdxsimilarity index 96%rename from docs/quick-start/minimal-example.mdrename to docs/quick-start/minimal-example.mdxindex 6e05bf850..92f5ab9c3 100644--- a/docs/quick-start/minimal-example.md+++ b/docs/quick-start/minimal-example.mdx@@ -2,6 +2,8 @@sidebar_position: 2---+import AuthorDetails from '@site/src/components/AuthorDetails';+# Minimal Working ExampleIn this blog post, we walk you through a minimal working example using the DSPy library.@@ -83,3 +85,7 @@ And there you have it! You've successfully created a working example using the DThis example showcases how to set up your environment, define a custom module, compile a model, and rigorously evaluate its performance using the provided dataset and teleprompter configurations.Feel free to adapt and expand upon this example to suit your specific use case while exploring the extensive capabilities of DSPy.++***++<AuthorDetails name="Herumb Shandilya"/>\ No newline at end of filediff --git a/docusaurus.config.ts b/docusaurus.config.tsindex a3afbf686..f12f39548 100644--- a/docusaurus.config.ts+++ b/docusaurus.config.ts@@ -120,6 +120,14 @@ const config: Config = {label: 'Omar Khattab',href: 'https://twitter.com/lateinteraction',},+ {+ label: 'Herumb Shandilya',+ href: 'https://twitter.com/krypticmouse',+ },+ {+ label: 'Arnav Singhvi',+ href: 'https://twitter.com/arnav_thebigman',+ },],},// Additional links under the 'More' sectiondiff --git a/src/components/AuthorDetails/index.tsx b/src/components/AuthorDetails/index.tsxnew file mode 100644index 000000000..32ea6737e--- /dev/null+++ b/src/components/AuthorDetails/index.tsx@@ -0,0 +1,65 @@+import clsx from 'clsx';+import Heading from '@theme/Heading';+import Link from '@docusaurus/Link';+import styles from './styles.module.css';++type FeatureItem = {+ name: string;+ twitterLink?: string;+ linkedinLink?: string;+ portfolioLink?: string;+};++const FeatureList: FeatureItem[] = [+ {+ name: 'Herumb Shandilya',+ twitterLink: 'https://twitter.com/krypticmouse',+ linkedinLink: 'https://www.linkedin.com/in/herumb-shandilya/',+ portfolioLink: 'https://herumbshandilya.com/',+ },+ {+ name: 'Arnav Singhvi',+ twitterLink: 'https://twitter.com/arnav_thebigman',+ linkedinLink: 'https://www.linkedin.com/in/arnav-singhvi-1323a7189/',+ portfolioLink: 'https://arnavsinghvi11.github.io/',+ },+];++export default function AuthorDetails(props: FeatureItem): JSX.Element {+ if (props.name && !props.twitterLink && !props.bio && !props.img) {+ const author = FeatureList.find((i) => i.name === props.name);+ if (!author) {+ throw new Error(`Author not found for name: ${props.name}.`);+ }+ props = author;+ }++ return (+ <div>+ <div>+ <p style={{ fontSize: "1.2rem", margin: 1, paddingBottom:"0.4rem" }}><span style={{ fontWeight: "600" }}>Written By:</span> {props.name}</p>+ {props.twitterLink &&+ <Link href={props.twitterLink}>+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="25px" height="25px" className={clsx(styles.svg)}>+ <path d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z" />+ </svg>+ </Link>+ }+ {props.linkedinLink &&+ <Link href={props.linkedinLink}>+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" width="25px" height="25px" className={clsx(styles.svg)} style={{ marginLeft:"0.8rem" }}>+ <path d="M100.3 448H7.4V148.9h92.9zM53.8 108.1C24.1 108.1 0 83.5 0 53.8a53.8 53.8 0 0 1 107.6 0c0 29.7-24.1 54.3-53.8 54.3zM447.9 448h-92.7V302.4c0-34.7-.7-79.2-48.3-79.2-48.3 0-55.7 37.7-55.7 76.7V448h-92.8V148.9h89.1v40.8h1.3c12.4-23.5 42.7-48.3 87.9-48.3 94 0 111.3 61.9 111.3 142.3V448z"/>+ </svg>+ </Link>+ }+ {props.portfolioLink &&+ <Link href={props.portfolioLink}>+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="25px" height="25px" className={clsx(styles.svg)} style={{ marginLeft:"0.8rem" }}>+ <path d="M352 256c0 22.2-1.2 43.6-3.3 64H163.3c-2.2-20.4-3.3-41.8-3.3-64s1.2-43.6 3.3-64H348.7c2.2 20.4 3.3 41.8 3.3 64zm28.8-64H503.9c5.3 20.5 8.1 41.9 8.1 64s-2.8 43.5-8.1 64H380.8c2.1-20.6 3.2-42 3.2-64s-1.1-43.4-3.2-64zm112.6-32H376.7c-10-63.9-29.8-117.4-55.3-151.6c78.3 20.7 142 77.5 171.9 151.6zm-149.1 0H167.7c6.1-36.4 15.5-68.6 27-94.7c10.5-23.6 22.2-40.7 33.5-51.5C239.4 3.2 248.7 0 256 0s16.6 3.2 27.8 13.8c11.3 10.8 23 27.9 33.5 51.5c11.6 26 20.9 58.2 27 94.7zm-209 0H18.6C48.6 85.9 112.2 29.1 190.6 8.4C165.1 42.6 145.3 96.1 135.3 160zM8.1 192H131.2c-2.1 20.6-3.2 42-3.2 64s1.1 43.4 3.2 64H8.1C2.8 299.5 0 278.1 0 256s2.8-43.5 8.1-64zM194.7 446.6c-11.6-26-20.9-58.2-27-94.6H344.3c-6.1 36.4-15.5 68.6-27 94.6c-10.5 23.6-22.2 40.7-33.5 51.5C272.6 508.8 263.3 512 256 512s-16.6-3.2-27.8-13.8c-11.3-10.8-23-27.9-33.5-51.5zM135.3 352c10 63.9 29.8 117.4 55.3 151.6C112.2 482.9 48.6 426.1 18.6 352H135.3zm358.1 0c-30 74.1-93.6 130.9-171.9 151.6c25.5-34.2 45.2-87.7 55.3-151.6H493.4z"/>+ </svg>+ </Link>+ }+ </div>+ </div>+ );+}diff --git a/src/components/AuthorDetails/styles.module.css b/src/components/AuthorDetails/styles.module.cssnew file mode 100644index 000000000..a2b80409f--- /dev/null+++ b/src/components/AuthorDetails/styles.module.css@@ -0,0 +1,21 @@+.authorBox {+ display: flex;+ align-items: center;+ border: 1px solid var(--author-box-border);+ padding: 20px;+ border-radius: 8px;+ background-color: var(--author-box-bg);+}++.authorProfilePicture {+ width: 80px;+ height: 80px;+ border-radius: 50%;+ margin-right: 20px;+ object-fit: cover;+}++.svg {+ fill: var(--author-links-svg-color);+}+\ No newline at end of filediff --git a/src/css/custom.css b/src/css/custom.cssindex 3048c1687..da4fda8c2 100644--- a/src/css/custom.css+++ b/src/css/custom.css@@ -17,6 +17,9 @@--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);--bg-color: #f5f6f7;--hero-text-color: #222831;+ --author-box-bg: #f9f9f9;+ --author-box-border: #ddd;+ --author-links-svg-color: #1c1e21;}/* For readability concerns, you should choose a lighter palette in dark mode. */@@ -31,4 +34,7 @@--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);--bg-color: #1c1e21;--hero-text-color: #f5f6f7;+ --author-box-bg: #2e2e2e;+ --author-box-border: #333;+ --author-links-svg-color: #f5f6f7;}