Skip to content

Commit

Permalink
feat(2.0): update minor style nits across docs (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd authored May 3, 2024
2 parents 3e2921a + 019e269 commit 1eaa4f3
Show file tree
Hide file tree
Showing 20 changed files with 227 additions and 37 deletions.
2 changes: 1 addition & 1 deletion docs/evaluation/migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def predict(inputs: dict):
return my_pipeline.invoke(inputs)
```

####4. If you were using LangChain evaluators, wrap them with `LangChainStringEvaluator`:
#### 4. If you were using LangChain evaluators, wrap them with `LangChainStringEvaluator`:

```python
from langsmith.evaluation import LangChainStringEvaluator
Expand Down
2 changes: 1 addition & 1 deletion docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ We offer Python and Typescript SDKs for all your LangSmith needs.

## Create an API key

To create an API key head to the [setting pages](https://smith.langchain.com/settings). Then click **Create API Key.**
To create an API key head to the [Settings page](https://smith.langchain.com/settings). Then click **Create API Key.**

## Setup your environment

Expand Down
21 changes: 11 additions & 10 deletions docs/tracing/quick_start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ConfigureSDKEnvironmentCodeTabs,
} from "@site/src/components/QuickStart";
import { ClientInstallationCodeTabs } from "@site/src/components/ClientInstallation";
import { CodeTabs, shell } from "@site/src/components/InstructionsWithCode";

# Tracing Quick Start

Expand All @@ -36,9 +37,7 @@ First, create an API key by navigating to the <a href="https://smith.langchain.c
<TabItem value="python-sdk">
<h2>1. Install the LangSmith library</h2>
<p>Start by installing the Python library.</p>
<pre>
<code>pip install langsmith</code>
</pre>
<CodeTabs tabs={[shell`pip install langsmith`]} />
<h2>2. Configure your environment</h2>
<ConfigureSDKEnvironmentCodeTabs />
<h2>3. Log a trace</h2>
Expand All @@ -65,13 +64,14 @@ First, create an API key by navigating to the <a href="https://smith.langchain.c
<TabItem value="typescript-sdk">
<h2>1. Install the LangSmith library</h2>
<p>Start by installing the TypeScript library.</p>
<pre>
<code>npm install langsmith</code>
</pre>
or
<pre>
<code>yarn add langsmith</code>
</pre>
<CodeTabs
tabs={[
shell({ value: "npm", label: "npm" })`npm install langsmith`,
shell({ value: "yarn", label: "yarn" })`yarn add langsmith`,
shell({ value: "pnpm", label: "pnpm" })`pnpm add langsmith`,
shell({ value: "bun", label: "bun" })`bun add langsmith`,
]}
/>
<h2>2. Configure your environment</h2>
<ConfigureSDKEnvironmentCodeTabs />
<h2>3. Log a Trace</h2>
Expand All @@ -95,6 +95,7 @@ First, create an API key by navigating to the <a href="https://smith.langchain.c
here
</a>.
</p>

</TabItem>
<TabItem value="langchain">
<h2>1. Install or upgrade LangChain</h2>
Expand Down
7 changes: 6 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ const config = {
defaultSidebarItemsGenerator,
...args
}) {
const sidebarItems = await defaultSidebarItemsGenerator(args);
let sidebarItems = await defaultSidebarItemsGenerator(args);

sidebarItems = sidebarItems.filter(
(i) => !(i.type === "doc" && i.id.split("/").at(-1) === "index")
);

sidebarItems.forEach((subItem) => {
// This allows breaking long sidebar labels into multiple lines
// by inserting a zero-width space after each slash.
Expand Down
28 changes: 27 additions & 1 deletion src/components/InstructionsWithCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export function ShellBlock(content, value = "shell", label = "Shell") {
value,
label,
content,
language: "shell",
};
}

Expand Down Expand Up @@ -93,13 +94,14 @@ function formatCode(code, language) {

export function CodeTabs({ tabs, groupId }) {
return (
<Tabs groupId={groupId}>
<Tabs groupId={groupId} className="code-tabs">
{tabs.map((tab, index) => {
const key = `${groupId}-${index}`;
return (
<TabItem key={key} value={tab.value} label={tab.label}>
{tab.caption && (
<div
className="code-caption"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(marked.parse(tab.caption)),
Expand Down Expand Up @@ -134,3 +136,27 @@ export const python = (strings, ...values) => {
});
return PythonBlock(dedent(result));
};

export const shell = (strings, ...values) => {
if (
values.length === 0 &&
typeof strings === "object" &&
strings != null &&
!Array.isArray(strings)
) {
const { value, label } = strings;
return (innerStrings, ...innerValues) => {
let result = "";
innerStrings.forEach((string, i) => {
result += string + String(innerValues[i] ?? "");
});
return ShellBlock(dedent(result), value ?? undefined, label ?? undefined);
};
}

let result = "";
strings.forEach((string, i) => {
result += string + String(values[i] ?? "");
});
return ShellBlock(dedent(result));
};
2 changes: 1 addition & 1 deletion src/components/QuickStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const model = new ChatOpenAI({
await model.invoke("Hello, world!", { callbacks: [tracer] })`;

return (
<Tabs groupId="client-language">
<Tabs groupId="client-language" className="code-tabs">
<TabItem key="python" value="python" label="Python">
<CodeBlock className="python" language="python">
{`from langchain_openai import ChatOpenAI
Expand Down
152 changes: 136 additions & 16 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
*/

@font-face {
font-family: 'Manrope';
src: url('/fonts/Manrope-VariableFont_wght.ttf') format('truetype');
font-family: "Manrope";
src: url("/fonts/Manrope-VariableFont_wght.ttf") format("truetype");
}

@font-face {
font-family: 'Public Sans';
src: url('/fonts/PublicSans-VariableFont_wght.ttf') format('truetype');
font-family: "Public Sans";
src: url("/fonts/PublicSans-VariableFont_wght.ttf") format("truetype");
}

/* You can override the default Infima variables here. */
Expand Down Expand Up @@ -49,8 +49,12 @@
--docusaurus-highlighted-code-line-bg: var(--joy-palette-primary-800);
}

nav, h1, h2, h3, h4 {
font-family: 'Manrope';
nav,
h1,
h2,
h3,
h4 {
font-family: "Manrope";
}

html[data-theme="dark"] {
Expand Down Expand Up @@ -110,10 +114,45 @@ html[data-theme="dark"] {
z-index: 1;
}

.menu__list {
display: flex !important;
flex-direction: column;
gap: 0.125rem;

position: relative;
}

.menu__list:not(.theme-doc-sidebar-menu) {
padding-left: 1.125rem !important;
}

.menu__list::before {
content: "";
width: 1px;
left: 0.75rem;
top: 0.125rem;
bottom: 0.125rem;

position: absolute;

background-color: var(--joy-palette-divider);
}

.theme-doc-sidebar-menu.menu__list::before {
display: none;
}

.menu__link {
padding-left: 0.5rem;
}

.theme-doc-sidebar-menu > .theme-doc-sidebar-item-category:not(:first-of-type),
.theme-doc-sidebar-menu > .theme-doc-sidebar-item-link,
.theme-doc-sidebar-menu > .theme-doc-sidebar-item-link.theme-doc-sidebar-item-link-level-1:not(:first-of-type) {
margin-top: .5rem;
.theme-doc-sidebar-menu
> .theme-doc-sidebar-item-link.theme-doc-sidebar-item-link-level-1:not(
:first-of-type
) {
margin-top: 0.125rem;
}

.theme-doc-sidebar-menu .theme-doc-sidebar-item-link,
Expand All @@ -132,8 +171,9 @@ html[data-theme="dark"] {
margin-top: 0;
}

.theme-doc-sidebar-item-category, .theme-doc-sidebar-menu > .theme-doc-sidebar-item-link {
font-size: 1rem;
.theme-doc-sidebar-item-category,
.theme-doc-sidebar-item-link {
font-size: 0.9rem !important;
font-weight: 500;
}

Expand All @@ -142,8 +182,9 @@ html[data-theme="dark"] {
width: 1.25rem;
}

.theme-doc-sidebar-item-link, .theme-doc-sidebar-item-category .theme-doc-sidebar-item-category {
font-size: .9rem;
.theme-doc-sidebar-item-link,
.theme-doc-sidebar-item-category .theme-doc-sidebar-item-category {
font-size: 0.9rem;
font-weight: 500;
}

Expand All @@ -162,19 +203,25 @@ html[data-theme="dark"] {
opacity: 0.5;
}

.markdown > h1 {
margin-top: 1rem;
margin-bottom: 1rem !important;
font-size: 2.5rem !important;
}

.markdown > h2 {
margin-top: 3rem;
margin-top: 2.5rem;
border-bottom-color: var(--ifm-color-primary);
border-bottom-width: 2px;
padding-bottom: 1rem;
font-size: 1.8rem !important;
}

.markdown > :not(h2) + h3 {
margin-top: 4rem;
margin-top: 2.5rem;
}

.markdown > h4 {
margin-bottom: 0.2rem;
margin-bottom: 1rem;
font-weight: 600;
}

Expand All @@ -191,3 +238,76 @@ html[data-theme="dark"] {
.DocSearch {
width: 250px;
}

.card {
padding: 1.5rem !important;
box-shadow: none !important;
}

.theme-code-block {
border-color: var(--joy-palette-divider) !important;
padding-left: 0 !important;
}

.theme-code-block::before {
display: none !important;
}

.tabs-container > .code-tabs + div {
margin-top: 0 !important;
box-shadow: none !important;
}

.tabs-container > .code-tabs {
border: 1px solid var(--joy-palette-divider);
border-bottom: none;
border-top-left-radius: var(--ifm-code-border-radius);
border-top-right-radius: var(--ifm-code-border-radius);
}

.tabs-container > .code-tabs > [role="tab"] {
padding: 0.5rem 1rem !important;
}

.tabs-container > .code-tabs + div .theme-code-block {
box-shadow: none !important;
border-top-left-radius: 0px !important;
border-top-right-radius: 0px !important;
}

.tabs-container > .code-tabs + div .code-caption {
border: 1px solid var(--joy-palette-divider);
border-bottom: none;
padding: 1rem;
}

.tabs-container > .code-tabs + div .code-caption p:last-child {
margin-bottom: 0;
}

.tabs-container:has(> .code-tabs) {
box-shadow: var(--ifm-global-shadow-lw);
border-radius: var(--ifm-code-border-radius);
}

.menu__list-item > .menu__list {
transition: all 0.2s ease-in-out !important;
}

.menu__list-item:not(.menu__list-item--collapsed) > .menu__list {
opacity: 1;
transform: scale(1);
}

.menu__list-item.menu__list-item--collapsed > .menu__list {
opacity: 0;
transform: scale(0.95);
}

/* prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
.menu__list-item > .menu__list {
transition: none !important;
opacity: 1 !important;
}
}
2 changes: 1 addition & 1 deletion src/theme/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default function Feedback() {
paddingBottom: "10px",
paddingLeft: "22px",
paddingRight: "22px",
border: "1px solid gray",
border: "1px solid var(--joy-palette-divider)",
borderRadius: "6px",
gap: "10px",
cursor: "pointer",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Datasets",
"collapsed": true,
"collapsible": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "Evaluation",
"collapsed": true,
"collapsible": true
}
3 changes: 2 additions & 1 deletion versioned_docs/version-2.0/how_to_guides/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_position: 1
sidebar_label: How-to guides
sidebar_position: 0
---

# How-to guides
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Setup",
"collapsed": true,
"collapsible": true,
"position": 1
}
Loading

0 comments on commit 1eaa4f3

Please sign in to comment.