Skip to content

Commit

Permalink
docs: azure types
Browse files Browse the repository at this point in the history
docs: types
  • Loading branch information
xiaohuoni authored Nov 22, 2023
2 parents ad1b1c8 + 254efaa commit 45a1bf1
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-bobcats-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alita/plugin-azure': patch
---

docs: add types
14 changes: 7 additions & 7 deletions examples/with-azure/config/pluginazure.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { IApi } from 'umi';
import type { IOnIntlAzure, IAzureSend } from '@alita/plugin-azure';

let _send = (_: any) => {};
export default (api: IApi) => {
// @ts-ignore
// api.onIntlAzure(async({send})=>{
let _send: IAzureSend;
export default (api: IApi & { onIntlAzure: IOnIntlAzure }) => {
// api.onIntlAzure(async ({ send }) => {
// _send = send;
// })
// api.onDevCompileDone(async()=>{
// });
// api.onDevCompileDone(async () => {
// const result = await _send('你好');
// console.log(result.choices[0]!.message?.content);
// })
// });
};
14 changes: 7 additions & 7 deletions packages/plugin-azure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ export default () => {

```ts
import { IApi } from 'umi';
import type { IOnIntlAzure, IAzureSend } from '@alita/plugin-azure';

let _send = (_: any) => {};
export default (api: IApi) => {
// @ts-ignore
api.onIntlAzure(async({send,openai})=>{
let _send: IAzureSend;
export default (api: IApi & { onIntlAzure: IOnIntlAzure }) => {
api.onIntlAzure(async ({ send }) => {
_send = send;
})
api.onDevCompileDone(async()=>{
});
api.onDevCompileDone(async () => {
const result = await _send('你好');
console.log(result.choices[0]!.message?.content);
})
});
};
```
2 changes: 1 addition & 1 deletion packages/plugin-azure/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alita/plugin-azure",
"version": "3.0.0",
"version": "3.0.1",
"description": "@alita/plugin-azure",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
18 changes: 18 additions & 0 deletions packages/plugin-azure/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import { IApi } from 'umi';
import { dirname } from 'path';
import OpenAI from 'openai';
export interface IEvent<T> {
(fn: { (args: T): void }): void;
(args: {
fn: {
(args: T): void;
};
name?: string;
before?: string | string[];
stage?: number;
}): void;
}
export declare type IAzureSend = (
content: string | Array<OpenAI.ChatCompletionMessageParam>,
) => Promise<OpenAI.Chat.Completions.ChatCompletion>;
export declare type IOnIntlAzure = IEvent<{
openapi: OpenAI;
send: IAzureSend;
}>;

export default (api: IApi) => {
api.describe({
Expand Down

0 comments on commit 45a1bf1

Please sign in to comment.