Skip to content

Commit

Permalink
align to Function SDK updates (#16)
Browse files Browse the repository at this point in the history
* align to Function SDK updates

* dictionary and link updates

* more updates

* Update sdk/inference.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update sdk/inference.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* remove Schema note from Manifest

* Update deploy.mdx

* Update sdk/functions-sdk.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update sdk/connection.mdx

* Update sdk/connection.mdx

* Update sdk/connection.mdx

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update sdk/functions-sdk.mdx

* formatting

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update connection.mdx

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* Update connection.mdx

* Update sdk/connection.mdx

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>

* separate response types

* edits

* Update http.mdx

* URL config

---------

Co-authored-by: Matt Johnson-Pint <mattjohnsonpint@gmail.com>
  • Loading branch information
ryanfoxtyler and mattjohnsonpint authored May 30, 2024
1 parent 0c1a7d4 commit b13463c
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .trunk/configs/.markdownlint.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"MD013": false,
"MD033": false
"MD033": false,
"MD034": false
}
2 changes: 1 addition & 1 deletion deploy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Hypermode leverages a native GitHub integration for the deployment of Hypermode

## Build

A GitHub Action is available in the [template project](https://github.com/hypermodeAI/sample-project) to handle the build of your project's functions. This Action must complete successfully before your functions deploy.
The [template project](https://github.com/hypermodeAI/template-project) includes a GitHub Action to build your project's functions. On success, the action deploys your functions to Hypermode when committing or merging to the branch defined in the Hypermode Console.```

## Deploy

Expand Down
3 changes: 2 additions & 1 deletion mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@
"group": "Write Functions",
"pages": [
"sdk/functions-sdk",
"sdk/http",
"sdk/connection",
"sdk/inference",
"sdk/search",
"sdk/console"
]
},
{
"group": "Iterate Constantly",
"group": "Observe and Iterate",
"pages": ["deploy", "function-observability"]
}
],
Expand Down
55 changes: 49 additions & 6 deletions sdk/connection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,64 @@ Connection APIs allow you to securely access an API endpoint at a defined host.
Make a query or mutation against a GraphQL API endpoint.

```TypeScript
invokeGraphqlApi (
invokeGraphqlApi<TData> (
hostName: string,
query: string,
variables?: Map<string, string>
): string
statement: string,
variables?: QueryVariables
): GQLResponse<TData>
```

<ResponseField name="TData" type="Type" required>
Type of object to use for the data returned from the query.
</ResponseField>

<ResponseField name="hostName" type="string" required>
Internal name of your host, as [defined in your manifest](../define-hosts).
</ResponseField>

<ResponseField name="query" type="string" required>
<ResponseField name="statement" type="string" required>
GraphQL operation for execution on your API server to retrieve or write data.
</ResponseField>

<ResponseField name="variables" type="string">
<ResponseField name="variables" type="QueryVariables">
Optional variables added to the query.

Example:

```TypeScript
const vars = new QueryVariables();
vars.set("firstName", firstName);
vars.set("lastName", lastName);
```

</ResponseField>

### GQLResponse object

A response object from the GraphQL query.

<ResponseField name="data" type="TData">
The results of the GraphQL operation.
</ResponseField>
<ResponseField name="errors" type="GQLError[]">
Any errors incurred as part of your GraphQL request.
<Expandable title="properties">
<ResponseField name="message" type="string">
Description of the error incurred.
</ResponseField>
<ResponseField name="path" type="string[]">
Query path of the error incurred. Each item in the array represents a
segment of the path.
</ResponseField>
<ResponseField name="locations" type="GQLErrorLocation[]">
<Expandable title="properties">
<ResponseField name="line" type="u32">
Specific line number of the request that points to the error.
</ResponseField>
<ResponseField name="column" type="u32">
Specific column number of the request that points to the error.
</ResponseField>
</Expandable>
</ResponseField>
</Expandable>
</ResponseField>
12 changes: 8 additions & 4 deletions sdk/functions-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ The Functions SDK gives your project access to a set of APIs that simplify the d

<Note>
The Functions SDK includes support for AssemblyScript, a portable
TypeScript-like language. Support for Golang is in development.
TypeScript-like language. Additional language support is in development.
</Note>

For inspiration on getting started, reference the [examples in the Function SDK repo](https://github.com/hypermodeAI/functions-as/tree/main/examples).

## APIs

<CardGroup cols={2}>
<Card title="Connection" icon="server" href="/sdk/connection">
<Card title="HTTP" icon="server" href="/sdk/http">
Securely call and fetch data from an HTTP endpoint.
</Card>
<Card title="Connection" icon="database" href="/sdk/connection">
Augment functions with secure access to data in your databases and APIs.
</Card>
<Card title="Inference" icon="message-plus" href="/sdk/inference">
Use AI models for classification, summarization, and other generation use
cases.
Use AI models for classifying, summarizing, and generation use cases.
</Card>
<Card title="Search" icon="searchengin" href="/sdk/search">
Use embeddings for semantic similarity search, clustering, and outlier
Expand Down
72 changes: 72 additions & 0 deletions sdk/http.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
title: HTTP
description: ""
---

The HTTP API allows you to securely call and fetch data from an HTTP endpoint.

<Tip>
We're introducing new APIs consistently through ongoing development with build
partners. [Let's chat](mailto:help@hypermode.com) about what would make the
Functions SDK even more powerful for your next use case!
</Tip>

### fetch

Invoke an HTTP endpoint to retrieve data or trigger external action.

```TypeScript
fetch (
request: Request,
): Response
```

<ResponseField name="request" type="Request" required>
A [Request](#request-object) object for calling an HTTP endpoint.
</ResponseField>

<ResponseField name="response" type="Response">
A [Response](#response-object) object from the HTTP endpoint.
</ResponseField>

### Request object

<ResponseField name="url" type="string">
The URL to send the request to. You must have a corresponding
[Host](/define-hosts) in your project's manifest.

Example: https://example.com/whatever

</ResponseField>
<ResponseField name="method" type="string">
The HTTP method to use for the request.

Example: "GET"

</ResponseField>
<ResponseField name="headers" type="Headers">
The HTTP headers for the request, as [defined in your
manifest](../define-hosts).
</ResponseField>
<ResponseField name="body" type="ArrayBuffer">
The raw HTTP request body, as an `ArrayBuffer`.
</ResponseField>

### Response object

<ResponseField name="status" type="u16">
The HTTP response status code. Example: 200
</ResponseField>
<ResponseField name="statusText" type="string">
The HTTP response status text. Example: "OK"
</ResponseField>
<ResponseField name="headers" type="Headers">
The HTTP response headers.
</ResponseField>
<ResponseField name="body" type="ArrayBuffer">
The raw HTTP response body, as an `ArrayBuffer`.

<Tip>
The response body isn't normally read directly. Instead, use `response.text()` or `response.json<T>()` functions.
</Tip>
</ResponseField>
103 changes: 96 additions & 7 deletions sdk/inference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,41 @@ generateText (
Queries for response within the context of the given instruction.
</ResponseField>

### computeClassificationLabels
### classifyText

Invoke a fine-tuned classification model with a text input, resulting in a single classification label that exceeds the provided threshold.

```TypeScript
classifyText (
modelName: string,
text: string,
threshold: f32
): string
```

<ResponseField name="modelName" type="string" required>
Internal name of your model, as [defined in your manifest](../define-models).
</ResponseField>

<ResponseField name="text" type="string" required>
Text input for classification amongst labels defined in the fine-tuning
process.
</ResponseField>

<ResponseField name="threshold" type="f32" required>
Confidence factor for classification. If no labels exist with a probability
higher than this threshold, the model won't produce a result.
</ResponseField>

### getClassificationLabelsForText

Invoke a fine-tuned classification model with a text input, resulting in an array of labels and probabilities.

```TypeScript
computeClassificationLabels (
getClassificationLabelsForText (
modelName: string,
text: string
): Map<string, number>
): Map<string, f32>
```

<ResponseField name="modelName" type="string" required>
Expand All @@ -55,15 +81,59 @@ computeClassificationLabels (
process.
</ResponseField>

### embedText
### getClassificationLabelsForTexts

Invoke an embedding model with a text input, resulting in a vector embedding.
Invoke a fine-tuned classification model with multiple text inputs, resulting in an array of an array of labels and probabilities.

```TypeScript
getClassificationLabelsForTexts (
modelName: string,
texts: Map<string, string>
): Map<string, Map<string, f32>>
```

<ResponseField name="modelName" type="string" required>
Internal name of your model, as [defined in your manifest](../define-models).
</ResponseField>

<ResponseField name="texts" type="Map<string, string>" required>
Text inputs for classification amongst labels defined in the fine-tuning
process.
</ResponseField>

### getClassificationProbability

Invoke a fine-tuned classification model with a text input, resulting in the probability of the provided label.

```TypeScript
embedText (
getClassificationProbability (
modelName: string,
text: string,
): number
label: string
): f32
```

<ResponseField name="modelName" type="string" required>
Internal name of your model, as [defined in your manifest](../define-models).
</ResponseField>

<ResponseField name="text" type="string" required>
Text input for classification based on the label provided.
</ResponseField>

<ResponseField name="label" type="string" required>
The label to classify the provided text against.
</ResponseField>

### getTextEmbedding

Invoke an embedding model with a text input, resulting in a vector embedding.

```TypeScript
getTextEmbedding (
modelName: string,
text: string
): f64[]
```

<ResponseField name="modelName" type="string" required>
Expand All @@ -73,3 +143,22 @@ embedText (
<ResponseField name="text" type="string" required>
Text input for embedding.
</ResponseField>

### getTextEmbeddings

Invoke an embedding model with multiple text inputs, resulting in an array of vector embeddings.

```TypeScript
getTextEmbeddings (
modelName: string,
texts: Map<string, string>
): Map<string, f64[]>
```

<ResponseField name="modelName" type="string" required>
Internal name of your model, as [defined in your manifest](../define-models).
</ResponseField>

<ResponseField name="texts" type="Map<string, string>" required>
Text inputs for embedding.
</ResponseField>
2 changes: 1 addition & 1 deletion sdk/search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ description: "Add search into your functions"
Functions SDK even more powerful for your next use case!
</Tip>

The [embedText](/sdk/inference#embedtext) API creates text embeddings for use in semantic similarity search use cases.
The [getTextEmbedding](/sdk/inference#getTextEmbedding) API creates text embeddings for use in semantic similarity search use cases.
13 changes: 10 additions & 3 deletions styles/config/vocabularies/general/accept.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

APIs
inferencing
repo

invokeGraphqlApi
fetch
generateText
computeClassificationLabels
embedText
log
classifyText
getClassificationLabelsForText
getClassificationLabelsForTexts
getClassificationProbability
getTextEmbedding
getTextEmbeddings
log
GQLResponse

0 comments on commit b13463c

Please # to comment.