@gsa-tts/graymatter-ui 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,174 @@
1
+ ---
2
+ title: 'Endpoints'
3
+ description: ''
4
+ sortOrder: 20
5
+ ---
6
+
7
+ API endpoints will be available when you login.
8
+
9
+ ### 1. Models
10
+
11
+ GET /api/v1/models
12
+
13
+ To reach models the documented endpoint is `<base url>/api/v1/models`, which will allow you to retrieve available model information.
14
+
15
+ **Example Request**
16
+
17
+ ```bash
18
+ curl -X 'GET' \
19
+ '<base url>/api/v1/models' \
20
+ -H 'accept: application/json' \
21
+ -H 'Authorization: Bearer <Your API Key>'
22
+ ```
23
+ **Example Response**
24
+
25
+ ```json
26
+ {
27
+ "object": "list",
28
+ "data": [
29
+ {
30
+ "id": "claude_3_5_sonnet",
31
+ "created": 1718841600,
32
+ "object": "model",
33
+ "owned_by": "Anthropic"
34
+ },
35
+ {
36
+ "id": "llama3211b",
37
+ "created": 1727222400,
38
+ "object": "model",
39
+ "owned_by": "Meta"
40
+ },
41
+ {
42
+ "id": "cohere_english_v3",
43
+ "created": 1698883200,
44
+ "object": "model",
45
+ "owned_by": "Cohere"
46
+ }
47
+ ]
48
+ }
49
+ ```
50
+ ### 2. Chat Completions
51
+
52
+ POST /api/v1/chat/completions
53
+
54
+ To reach chat completions the documented endpoint is `<base url>/api/v1/chat/completions`, which will allow you to retrieve chat completion information.
55
+
56
+ **Request Body**
57
+
58
+ * **model**: The model ID (e.g: gemini-2.0-flash, claude_3_haiku)
59
+ * **messages**: An array of of message items consisting of User message, Image Content, Document Content, Assistant Message
60
+ * **max_tokens**: Maximum response length (optional)
61
+ * **temperature**: Response creativity (0.0-2.0, optional)
62
+
63
+ | **Models** | **Range** | **Default value** |
64
+ | :------- | :------: | -------: |
65
+ | Google models | 0.0 - 2.0 | 1.0 |
66
+ | Anthropic models | 0.0 - 1.0 | 0.5 |
67
+ | Meta models | 0.0 - 1.0 | 0.5 |
68
+
69
+ * **top_p**: An alternative to sampling with temperature, called nucleus sampling (optional)
70
+ * **stream**: a boolean indicating whether to send partials responses as available (optional)
71
+
72
+ **Example Request**
73
+
74
+ ```bash
75
+ curl -X 'POST' \
76
+ '<base url>/api/v1/chat/completions' \
77
+ -H 'accept: application/json' \
78
+ -H 'Authorization: Bearer <Your API Key>' \
79
+ -H 'Content-Type: application/json' \
80
+ -d '{
81
+ "messages": [
82
+ {
83
+ "content": "You speak only pirate",
84
+ "role": "system"
85
+ },
86
+ {
87
+ "content": "Hello!",
88
+ "role": "user"
89
+ }
90
+ ],
91
+ "model": "gemini-2.0-flash"
92
+ }'
93
+ ```
94
+
95
+ **Example Response**
96
+
97
+ ```json
98
+ {
99
+ "object": "chat.completion",
100
+ "created": 1748517745,
101
+ "model": "gemini-2.0-flash",
102
+ "choices": [
103
+ {
104
+ "index": 0,
105
+ "message": {
106
+ "role": "assistant",
107
+ "content": "Ahoy there, matey! What brings ye to me waters?\n"
108
+ },
109
+ "finish_reason": "stop"
110
+ }
111
+ ],
112
+ "usage": {
113
+ "prompt_tokens": 14,
114
+ "completion_tokens": 15,
115
+ "total_tokens": 29
116
+ }
117
+ }
118
+
119
+ ```
120
+
121
+ ### 3. Embeddings
122
+
123
+ POST /api/v1/embeddings
124
+
125
+ To reach embeddings the documented endpoint is `<base url>/api/v1/embeddings`, which will allow you to retrieve embeddings information.
126
+
127
+ **Request Body**
128
+
129
+ * **model:** The model ID (e.g: cohere_english_v3)
130
+ * **input:** Input text to embed, encoded as a string or array of strings. Each input must not exceed the max input tokens for the model.
131
+ dimensions: The number of dimensions the resulting output embeddings should have. Only supported in some models (Optional)
132
+ * **input_type:** (Note: this is not part of the OpenAI specification but is useful on some models). Specify the kind of input to allow the model to optimize for specific uses. Options are: "search_document", "search_query", "classification", "clustering", "semantic_similarity" (Optional)
133
+
134
+ **Example Request**
135
+
136
+ ```bash
137
+ curl -X 'POST' \
138
+ '<base url>/api/v1/embeddings' \
139
+ -H 'accept: application/json' \
140
+ -H 'Authorization: Bearer <Your API Key>\
141
+ -H 'Content-Type: application/json' \
142
+ -d '{
143
+ "encodingFormat": "float",
144
+ "input": "A mighty woman with a torch, whose flame / Is the imprisoned lightning",
145
+ "input_type": "search_document",
146
+ "model": "cohere_english_v3"
147
+ }
148
+ ```
149
+ **Example Response**
150
+
151
+ ```json
152
+ {
153
+ "object": "list",
154
+ "data": [
155
+ {
156
+ "object": "embedding",
157
+ "embedding": [
158
+ 0.06933594,
159
+ -0.030883789,
160
+ 0.054351807,
161
+ -0.0018196106,
162
+
163
+ 0.013938904
164
+ ],
165
+ "index": 0
166
+ }
167
+ ],
168
+ "model": "cohere.embed-english-v3",
169
+ "usage": {
170
+ "promptTokens": 12,
171
+ "totalTokens": 12
172
+ }
173
+ }
174
+ ```
@@ -0,0 +1,84 @@
1
+ ---
2
+ title: 'Getting Started'
3
+ description: ''
4
+ sortOrder: 10
5
+ ---
6
+
7
+ ### Introduction
8
+
9
+ USAi API provides programmatic access to AI services for government users and approved partners. It currently supports Chat Completions (model inference) and Embeddings (used for RAG and other applications).
10
+
11
+ Our API has resource-oriented URLs, accepts JSON request bodies, returns JSON responses, and uses HTTP response codes to indicate API errors, authentication messaging, and verbs.
12
+
13
+ ### Models and endpoints
14
+
15
+ USAi API is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer) and provides access to the large language models (LLMs):
16
+
17
+ **Google AI models**
18
+ - [Gemini 2.5 Flash](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash)
19
+ - [Gemini 2.5 Pro](https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro)
20
+
21
+ **Anthropic models**
22
+ - [Claude Haiku 3.5](https://docs.claude.com/en/docs/overview)
23
+ - [Claude Sonnet 3.7](https://docs.claude.com/en/docs/overview)
24
+ - [Claude Sonnet 4](https://docs.claude.com/en/docs/overview)
25
+ - [Claude Opus 4](https://docs.claude.com/en/docs/overview)
26
+
27
+ **Meta models**
28
+ - [Llama 3.2 11B](https://www.llama.com/docs/model-cards-and-prompt-formats/llama3_2/)
29
+ - [Llama 4 Maverick](https://www.llama.com/docs/model-cards-and-prompt-formats/llama4/)
30
+
31
+ The interface is modeled after the [OpenAI Chat Completion API](https://platform.openai.com/docs/guides/text?api-mode=responses). We will continue to add more models over time; we may also remove models if they are found to not meet our standards. You will be notified if a model is removed.
32
+
33
+ Each model we draw on has unique capabilities. Models may also respond differently to the same API request. Below is a summary of each endpoint’s functionality:
34
+
35
+ - **Chat Completions:** The ability to send prompts and receive a response from the LLM models.
36
+ - **Embedding:** Converts input into numeric vectors representing semantic meaning. The vectors are used for tasks like retrieving information from documents, document analysis, and building Retrieval Augmented Generation (RAG) systems.
37
+ - **Models:** A list of models and IDs used to specify LLM models in requests.
38
+
39
+ #### Content types
40
+
41
+ The models USAi API draws on support multiple types of inputs; text, image, and file content types. However, each model has different input capabilities: for example, Claude Sonnet supports Optical Character Recognition (OCR) and recognizes image-only PDFs, while Claude Haiku and Llama currently do not. For additional detail about how we handle these content types, reference [OpenAI’s API documentation](https://platform.openai.com/docs/api-reference/chat/create).
42
+
43
+ ### Authentication
44
+
45
+ All API requests require an API key. Upon authentication, your agency-specific instructions for requesting an API key, and the API endpoint, will be available.
46
+
47
+ ### Limitations
48
+
49
+ #### Rate limitations
50
+
51
+ We currently have a rate limit of 3 calls / second / API key. If you hit a rate limit, you should expect a 429 error code. If you need additional capacity, please contact us at [support@usai.gov](mailto:support@usai.gov). We can work with our infrastructure providers to secure higher model limits.
52
+
53
+ #### Feature limitations
54
+
55
+ Because the underlying platforms have different capabilities and interfaces, not all features of the Chat Completions API are available at this time. Current known limitations include:
56
+
57
+ - Audio
58
+ - Structured output
59
+
60
+ #### Guardrail limitations
61
+
62
+ We do not have guardrails beyond those provided by our model providers; this means that an API user has full control over what inputs and outputs are allowed when using the API. We expect API users to interact with the API ethically and deliberately, and add their own guardrails and system prompts as needed. We recommend implementing system prompts when using the API in situations where you do not know what inputs the model will receive.
63
+
64
+ System prompts should address your needs and concerns. Some of the system prompts in USAi Chat include:
65
+ - You are a helpful assistant that works for a government agency.
66
+ - You help users with general knowledge, problem-solving, coding, and interactive tasks.
67
+ - You maintain a friendly, helpful, professional, and empathetic tone at all times.
68
+ - You want to understand the user's intent, and apply your knowledge and background to formulate the most helpful response possible.
69
+ - Redirect conversations that veer into inappropriate, illegal, or explicit territory.
70
+ - You're not an expert in government policies, security, safety, health, procurement, contracts, or law. Provide general guidance only and advise users to reference appropriate material.
71
+ - Prioritize historical accuracy, scientific inquiry, and objectivity in all responses.
72
+ - Break down complex questions and walk users through solutions step-by-step.
73
+ - Use real-world analogies to simplify complex concepts.
74
+ - When the user's request is unclear, ask for more details to help refine your response.
75
+ - Ask users for feedback on the answer that can help you respond more accurately.
76
+ - Never knowingly make false statements or deceive users.
77
+ - Avoid generating explicit, hateful, dangerous, or illegal content.
78
+ - Protect privacy and do not share personal information about individuals.
79
+ - Redirect users' requests around potentially controversial or polarizing topics quickly.
80
+ - You do not prefer or recommend specific political views, groups, religions, companies, products, or enterprise.
81
+
82
+ ### Code demo
83
+
84
+ To see an example of how to implement features using Python, visit our [HTML example notebook](https://www.usai.gov/assets/files/jupyter_example.html). If you would like to run this file in a Jupyter environment, you can download the <a href="https://www.usai.gov/assets/files/jupyter_example.ipynb" download>notebook ipynb file</a>.
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: 'Support'
3
+ description: ''
4
+ sortOrder: 30
5
+ ---
6
+
7
+ You may encounter issues while working with the USAi API, as it is under active development. We may not be able to fix all issues immediately, but will add them to our backlog for future releases. If you have any questions, hit rate limits, or otherwise need assistance, please contact us at [support@usai.gov](mailto:support@usai.gov).
8
+
9
+
10
+
@@ -18,3 +18,20 @@ const { title, description, openGraphImage, gtmID } = Astro.props;
18
18
  <slot />
19
19
  </body>
20
20
  </html>
21
+
22
+ <script>
23
+ // Enhanced mobile focus handling - centralized for all layouts
24
+ if (typeof window !== 'undefined') {
25
+ const handleKeyDown = (e: KeyboardEvent) => {
26
+ if (e.key === 'Tab') {
27
+ document.body.classList.add('keyboard-user');
28
+ document.body.classList.remove('touch-user');
29
+ }
30
+ };
31
+
32
+ document.addEventListener('keydown', handleKeyDown);
33
+
34
+ // Initial state - assume touch user until Tab is pressed
35
+ document.body.classList.add('touch-user');
36
+ }
37
+ </script>
@@ -0,0 +1,178 @@
1
+ ---
2
+ import GlobalAppLayout from './GlobalAppLayout.astro';
3
+ import ApiDocSubNavMenu from '../components/ApiDocSubNavMenu.svelte';
4
+ import NavigationInitializer from '../components/NavigationInitializer.svelte';
5
+ import { getBaseUrl } from '../helpers';
6
+
7
+ const gtmID = import.meta.env.PUBLIC_GTM_ID;
8
+ const {
9
+ navigationItem = 'api',
10
+ title,
11
+ description,
12
+ openGraphImage,
13
+ showAppIcons = false,
14
+ subNavData = null,
15
+ disableCodeCopyButtons = false,
16
+ postItems = null,
17
+ profileMenuData = null,
18
+ } = Astro.props;
19
+ ---
20
+
21
+ <GlobalAppLayout
22
+ ssrSelectedItem={navigationItem}
23
+ gtmID={gtmID}
24
+ {showAppIcons}
25
+ {profileMenuData}
26
+ logoLinkUrl={getBaseUrl()}
27
+ logoLinkLabel="Homepage"
28
+ title={title}
29
+ {description}
30
+ {openGraphImage}
31
+ >
32
+ <!-- Initialize navigation state and auto-expand submenu for section pages -->
33
+ <NavigationInitializer
34
+ item={navigationItem}
35
+ autoExpand={true}
36
+ client:only="svelte"
37
+ />
38
+
39
+ <!-- Documentation Sub Navigation -->
40
+ {
41
+ subNavData && (
42
+ <ApiDocSubNavMenu
43
+ data={subNavData}
44
+ selectedId={null}
45
+ slot="sub-nav"
46
+ client:load
47
+ />
48
+ )
49
+ }
50
+
51
+ <!-- Main content area -->
52
+ <div class="docs-content">
53
+ <article class="article-body">
54
+ <h1 class="page-title">API Documentation</h1>
55
+
56
+ <!-- Render postItems if provided -->
57
+ {
58
+ postItems &&
59
+ postItems.map((post: any) => (
60
+ <div>
61
+ <h2 class="title" id={post.id}>
62
+ {post.data.title}
63
+ </h2>
64
+ <post.ContentComponent />
65
+ </div>
66
+ ))
67
+ }
68
+ </article>
69
+ </div>
70
+ </GlobalAppLayout>
71
+
72
+ <!-- Add copy button to all code blocks -->
73
+ {
74
+ !disableCodeCopyButtons && (
75
+ <script>
76
+ import {setupCopyButtons} from '../utils/copyButtonScript.js';
77
+ setupCopyButtons();
78
+ </script>
79
+ )
80
+ }
81
+
82
+ <style>
83
+ body {
84
+ color: var(--ai-color-steel-900);
85
+ line-height: var(--ai-font-lineheight-prose);
86
+ }
87
+
88
+ :is(h1, h2, h3, h4, h5, h6) {
89
+ color: var(--ai-color-black);
90
+ }
91
+
92
+ .docs-content {
93
+ padding: 0;
94
+ }
95
+
96
+ .article-body {
97
+ max-width: 84ch;
98
+ }
99
+
100
+ :global(.ai-copy-btn) {
101
+ width: var(--ai-size-32);
102
+ height: var(--ai-size-32);
103
+ position: absolute;
104
+ top: var(--ai-size-8);
105
+ right: var(--ai-size-8);
106
+ background: none;
107
+ border-radius: var(--ai-size-4);
108
+ border: none;
109
+ padding: 0;
110
+ cursor: pointer;
111
+ box-shadow: 0 var(--ai-size-2) var(--ai-size-8) rgba(0, 0, 0, 0.08);
112
+ display: flex;
113
+ align-items: center;
114
+ justify-content: center;
115
+ transition:
116
+ background var(--ai-duration-fast),
117
+ border var(--ai-duration-fast);
118
+ z-index: var(--ai-layer-2);
119
+ overflow: hidden;
120
+ }
121
+ :global(.ai-copy-btn:hover),
122
+ :global(.ai-copy-btn:focus) {
123
+ background: var(--ai-color-steel-800);
124
+ }
125
+ :global(.ai-copy-btn svg) {
126
+ display: block;
127
+ position: relative;
128
+ }
129
+ :global(.ai-code-block-wrapper) {
130
+ position: relative;
131
+ display: block;
132
+ }
133
+ :global(pre) {
134
+ font-family: var(--ai-font-family-monospace);
135
+ font-size: var(--ai-size-13);
136
+ font-weight: var(--ai-font-weight-normal);
137
+ }
138
+
139
+ /* Table styling - only for documentation pages */
140
+ :global(.docs-content table) {
141
+ width: 100%;
142
+ border-collapse: collapse;
143
+ margin: var(--ai-size-24) 0;
144
+ }
145
+
146
+ :global(.docs-content table th),
147
+ :global(.docs-content table td) {
148
+ padding: var(--ai-size-12) var(--ai-size-16);
149
+ text-align: left;
150
+ border-bottom: 1px solid var(--ai-color-neutral-200);
151
+ }
152
+
153
+ :global(.docs-content table th) {
154
+ background-color: var(--ai-color-neutral-50);
155
+ font-weight: var(--ai-font-weight-semibold);
156
+ color: var(--ai-color-black);
157
+ }
158
+
159
+ :global(.docs-content table tbody tr:hover) {
160
+ background-color: var(--ai-color-neutral-25);
161
+ }
162
+
163
+ :global(.docs-content table tbody tr:last-child td) {
164
+ border-bottom: none;
165
+ }
166
+
167
+ @media (--ai-size-breakpoint-tablet) {
168
+ .docs-content {
169
+ padding: 2rem 0;
170
+ }
171
+ }
172
+
173
+ @media (--ai-size-breakpoint-desktop) {
174
+ .docs-content {
175
+ padding: 2rem;
176
+ }
177
+ }
178
+ </style>
@@ -0,0 +1,15 @@
1
+ export interface SubNavItem {
2
+ id: string;
3
+ title: string;
4
+ href?: string;
5
+ children?: SubNavItem[];
6
+ }
7
+
8
+ export interface SubNavSection {
9
+ header: string;
10
+ items: SubNavItem[];
11
+ }
12
+
13
+ export interface SubNavData {
14
+ sections: SubNavSection[];
15
+ }
@@ -0,0 +1,107 @@
1
+ interface CopyButtonConfig {
2
+ buttonClass?: string;
3
+ copyIconClass?: string;
4
+ checkIconClass?: string;
5
+ timeout?: number;
6
+ }
7
+
8
+ export function initializeCopyButtons(config: CopyButtonConfig = {}) {
9
+ const {
10
+ buttonClass = 'ai-copy-btn',
11
+ copyIconClass = 'ai-copy-icon',
12
+ checkIconClass = 'ai-check-icon',
13
+ timeout = 1200,
14
+ } = config;
15
+
16
+ // Function to add a button to a visible code block
17
+ function addCopyButton(pre: HTMLPreElement) {
18
+ const codeBlock = pre.querySelector('code');
19
+ if (!codeBlock || pre.querySelector(`.${buttonClass}`)) return;
20
+
21
+ const wrapper = codeBlock.closest('.ai-code-block-wrapper');
22
+ if (!wrapper) return;
23
+
24
+ const button = document.createElement('button');
25
+ button.className = buttonClass;
26
+ button.type = 'button';
27
+ button.setAttribute('aria-label', 'Copy code to clipboard');
28
+
29
+ button.innerHTML = `
30
+ <!-- Inline Copy Icon -->
31
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
32
+ stroke-width="1.5" stroke="#f2f4f7"
33
+ class="usai-icon ${copyIconClass} size-6"
34
+ aria-hidden="true" focusable="false" role="img"
35
+ style="width:1.25em;height:1.25em;">
36
+ <path stroke-linecap="round" stroke-linejoin="round"
37
+ d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" />
38
+ </svg>
39
+
40
+ <!-- Inline Check Icon -->
41
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
42
+ stroke-width="1.5" stroke="#f2f4f7"
43
+ class="usai-icon ${checkIconClass} size-6"
44
+ aria-hidden="true" focusable="false" role="img"
45
+ style="display:none; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:1.25em; height:1.25em;">
46
+ <path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5" />
47
+ </svg>
48
+ `;
49
+
50
+ button.onclick = () => {
51
+ const lines = codeBlock.querySelectorAll('.line');
52
+ const textToCopy =
53
+ lines.length > 0
54
+ ? Array.from(lines)
55
+ .map(line => line.textContent ?? '')
56
+ .join('\n')
57
+ : (codeBlock.textContent ?? '');
58
+
59
+ navigator.clipboard.writeText(textToCopy);
60
+
61
+ const copyIcon = button.querySelector(
62
+ `.${copyIconClass}`
63
+ ) as SVGElement | null;
64
+ const checkIcon = button.querySelector(
65
+ `.${checkIconClass}`
66
+ ) as SVGElement | null;
67
+
68
+ if (copyIcon && checkIcon) {
69
+ copyIcon.style.display = 'none';
70
+ checkIcon.style.display = '';
71
+ button.setAttribute('aria-label', 'Copied!');
72
+ setTimeout(() => {
73
+ copyIcon.style.display = '';
74
+ checkIcon.style.display = 'none';
75
+ button.setAttribute('aria-label', 'Copy code to clipboard');
76
+ }, timeout);
77
+ }
78
+ };
79
+
80
+ wrapper.appendChild(button);
81
+ }
82
+
83
+ const observer = new IntersectionObserver(
84
+ (entries, obs) => {
85
+ for (const entry of entries) {
86
+ if (entry.isIntersecting) {
87
+ const pre = entry.target as HTMLPreElement;
88
+ addCopyButton(pre);
89
+ obs.unobserve(pre);
90
+ }
91
+ }
92
+ },
93
+ { rootMargin: '200px' }
94
+ );
95
+
96
+ document.querySelectorAll('pre').forEach(pre => {
97
+ observer.observe(pre);
98
+ });
99
+ }
100
+
101
+ export function setupCopyButtons() {
102
+ if (typeof window !== 'undefined') {
103
+ window.addEventListener('DOMContentLoaded', () => {
104
+ initializeCopyButtons();
105
+ });
106
+ }
107
+ }