Skip to content

Commit

Permalink
Merge pull request #61 from aziontech/stage
Browse files Browse the repository at this point in the history
Stage Release 1.9.0 #59
  • Loading branch information
jotanarciso authored Oct 28, 2024
2 parents 346e944 + 823ea5a commit 10fef3b
Show file tree
Hide file tree
Showing 37 changed files with 2,351 additions and 461 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/code-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Azion AI Code Review

on:
pull_request:
types: [opened, synchronize]
branches:
- main
- stage

permissions:
contents: read
pull-requests: write
checks: write

jobs:
ai-code-review:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install dependencies
run: |
npm install
npm run compile
npm install @actions/github
- name: Run Azion AI Code Review
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AZION_TOKEN: ${{ secrets.AZION_TOKEN }}
run: |
node ./scripts/code-review.mjs
continue-on-error: true
id: code_review

- name: Display error logs
if: failure() && steps.code_review.outcome == 'failure'
run: |
echo "Error during code review execution:"
cat ${{ github.workspace }}/*.log
- name: Update PR Status
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Azion AI Code Review',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: 'success',
output: {
title: 'Code review completed',
summary: 'The code review was completed successfully.'
}
})
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
## [1.9.0-stage.3](https://github.com/aziontech/lib/compare/v1.9.0-stage.2...v1.9.0-stage.3) (2024-10-21)


### Bug Fixes

* azion/ai exports ([81c636e](https://github.com/aziontech/lib/commit/81c636eda6be676db07f738c9117e7aee0659d93))

## [1.9.0-stage.2](https://github.com/aziontech/lib/compare/v1.9.0-stage.1...v1.9.0-stage.2) (2024-10-19)


### Features

* azion/ai (#58) ([f873a00](https://github.com/aziontech/lib/commit/f873a00becc4e174a9457e29087509eafdb68992))

## [1.9.0-stage.1](https://github.com/aziontech/lib/compare/v1.8.2...v1.9.0-stage.1) (2024-10-16)


### Features

* improve fetch error handling (#57) ([bb901e5](https://github.com/aziontech/lib/commit/bb901e5d039beab758a5f0652255c9e96ac51437))

### [1.8.2](https://github.com/aziontech/lib/compare/v1.8.1...v1.8.2) (2024-10-03)


Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ These libraries are designed to be versatile and can be used both within and out
- [Jwt](./packages/jwt/README.md)
- [WASM Image Processor](./packages/wasm-image-processor/README.md)
- [Utils](./packages/utils/README.md)
- [AI](./packages/ai/README.md)
- [Types](#types)
- [AzionConfig](#config)
- [Contributing](#contributing)
Expand Down
23 changes: 21 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "azion",
"version": "1.8.2",
"version": "1.9.0-stage.3",
"description": "Azion Packages for Edge Computing.",
"bin": {
"azion": "./bin/azion"
"azion": "./bin/azion",
"azlib": "./bin/azion"
},
"scripts": {
"prepare": "husky",
Expand Down Expand Up @@ -81,6 +82,11 @@
"import": "./packages/client/dist/index.mjs",
"types": "./packages/client/dist/index.d.ts"
},
"./ai": {
"require": "./packages/ai/dist/index.js",
"import": "./packages/ai/dist/index.mjs",
"types": "./packages/ai/dist/index.d.ts"
},
"./applications": {
"require": "./packages/applications/dist/index.js",
"import": "./packages/applications/dist/index.mjs",
Expand Down Expand Up @@ -144,6 +150,9 @@
},
"typesVersions": {
"*": {
"ai": [
"./packages/ai/dist/index.d.ts"
],
"application": [
"./packages/application/dist/index.d.ts"
],
Expand Down
163 changes: 163 additions & 0 deletions packages/ai/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Azion AI Client

The Azion AI Client provides a simple interface to interact with the Azion AI API. This AI is specialized and has contextual knowledge about all Azion products, services, and technologies, allowing for precise and relevant responses about Azion's Edge Computing platform.

## Table of Contents

- [Installation](#installation)
- [Environment Variables](#environment-variables)
- [Debug Mode](#debug-mode)
- [Usage](#usage)
- [API Reference](#api-reference)
- [Types](#types)
- [Contributing](#contributing)

## Installation

Install the package using npm or yarn:

```
npm install azion
```

or

```
yarn add azion
```

## Environment Variables

Configure the client using the following environment variables:

- `AZION_TOKEN`: Your Azion API token.
- `AZION_DEBUG`: Enable debug mode (true/false).

Example `.env` file:

```
AZION_TOKEN=your-api-token
AZION_DEBUG=true
```

## Debug Mode

Debug mode provides detailed logging of API requests and responses. Enable it by setting the `AZION_DEBUG` environment variable to `true` or passing `true` as the `debug` parameter in the methods.

## Usage

### Using Environment Variables

You can use environment variables to configure the client without directly passing the token and debug parameters.

### Direct Method Calls

Use the provided wrapper methods to perform AI chat operations directly.

### Client Configuration

Create a client instance with specific configurations.

### API Examples

#### Chat

```typescript
import { chat } from 'azion/ai';
import type { AzionAIRequest, AzionAIResponse, AzionAIResult } from '@azion/ai';

const request: AzionAIRequest = {
messages: [{ role: 'user', content: 'Explain what Azion Edge Computing is.' }]
};
const { data: response, error }: AzionAIResult<AzionAIResponse> = await chat(request, { debug: true });
if (response) {
console.log('AI response:', response.choices[0].message.content);
} else {
console.error('Chat failed', error);
}
```

#### Streaming Chat

```typescript
import { streamChat } from 'azion/ai';
import type { AzionAIRequest, AzionAIStreamResponse, AzionAIResult } from '@azion/ai';

const request: AzionAIRequest = {
messages: [{ role: 'user', content: 'List 5 use cases for Azion Edge Functions.' }]
};
const stream = streamChat(request, { debug: true });
for await (const chunk: AzionAIResult<AzionAIStreamResponse> of stream) {
if (chunk.data) {
process.stdout.write(chunk.data.choices[0].delta.content || '');
} else {
console.error('Error:', chunk.error);
}
}
```
## API Reference
### `chat`
Sends a chat request to the Azion AI service.
**Parameters:**
- `request: AzionAIRequest` - Request object containing chat parameters.
- `options?: AzionClientOptions` - Additional client options.
**Returns:**
- `Promise<AzionAIResult<AzionAIResponse>>` - A promise that resolves to the chat result or an error.
### `streamChat`
Sends a streaming chat request to the Azion AI service.
**Parameters:**
- `request: AzionAIRequest` - Request object containing chat parameters.
- `options?: AzionClientOptions` - Additional client options.
**Returns:**
- `AsyncGenerator<AzionAIResult<AzionAIStreamResponse>>` - An async generator that produces partial chat results.
### `createClient`
Creates an Azion AI client with methods to interact with AI services.
**Parameters:**
- `config?: Partial<{ token: string; options?: AzionClientOptions }>` - Optional configuration for the client.
**Returns:**
- `AzionAIClient` - A client object with methods to interact with AI services.
## Types
Here are the main types used in the Azion AI Client:
```typescript
import type {
AzionAIMessage,
AzionAIConfig,
AzionAIRequest,
AzionAIResponse,
AzionAIStreamResponse,
AzionAIResult,
AzionAIClient,
AzionClientOptions,
CreateAzionAIClient
} from '@azion/ai';

// AzionAIMessage
```
For more detailed information about these types, please refer to the source code.
## Contributing
Feel free to submit issues or pull requests to improve the functionality or documentation.
18 changes: 18 additions & 0 deletions packages/ai/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

import type { Config } from 'jest';

const config: Config = {
displayName: 'AI',
clearMocks: true,
coverageProvider: 'v8',
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testPathIgnorePatterns: ['/node_modules/'],
};

export default config;
Loading

0 comments on commit 10fef3b

Please sign in to comment.