Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ refactor: Refactor api #11

Merged
merged 24 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a7c0095
♻️ refactor: Refactor api
canisminor1990 Nov 14, 2023
26a4ad7
:bookmark: chore(release): v1.12.1-beta.1 [skip ci]
semantic-release-bot Nov 15, 2023
80b24e8
:recycle: refactor: 将react 部分抽取到 /react 子级路径下
semantic-release-bot Nov 15, 2023
cdcb9cc
:bookmark: chore(release): v1.12.1-beta.2 [skip ci]
semantic-release-bot Nov 15, 2023
6a4631d
:recycle: refactor: fix react entry
arvinxx Nov 15, 2023
1ec2701
:bookmark: chore(release): v1.12.1-beta.3 [skip ci]
semantic-release-bot Nov 15, 2023
9262608
🐛 fix: Fix client fetch
canisminor1990 Nov 15, 2023
e7296c4
:bookmark: chore(release): v1.12.1-beta.4 [skip ci]
semantic-release-bot Nov 15, 2023
e69bb5f
:wrench: chore: fix build
arvinxx Nov 15, 2023
7338a9e
:wrench: chore: fix build
arvinxx Nov 15, 2023
d875be6
:wrench: refactor: refactor to fix build
arvinxx Nov 15, 2023
761f22b
:bookmark: chore(release): v1.12.1-beta.5 [skip ci]
semantic-release-bot Nov 15, 2023
9858fcb
:wrench: refactor: refactor to fix build
arvinxx Nov 15, 2023
4c22bea
:bookmark: chore(release): v1.12.1-beta.6 [skip ci]
semantic-release-bot Nov 15, 2023
9c41986
:wrench: ci: use pure esm to fix build
arvinxx Nov 15, 2023
07245e3
✨ feat: Add class
canisminor1990 Nov 15, 2023
1593a5a
:bookmark: chore(release): v1.13.0-beta.1 [skip ci]
semantic-release-bot Nov 15, 2023
b559207
:wrench: chore: try to fix
arvinxx Nov 15, 2023
6be487f
:wrench: chore: try to fix
arvinxx Nov 15, 2023
7da2821
:wrench: chore: try to fix
arvinxx Nov 15, 2023
2c49e02
✨ feat: Add SWR config to hooks
canisminor1990 Nov 15, 2023
fbc6cfe
:bookmark: chore(release): v1.13.0-beta.2 [skip ci]
semantic-release-bot Nov 15, 2023
802c59a
:recycle: refactor: refactor the demo usage
arvinxx Nov 15, 2023
1a73072
:bookmark: chore(release): v1.13.0-beta.3 [skip ci]
semantic-release-bot Nov 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions .dumirc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'dumi';
import path from 'node:path';

import { description, homepage, name } from './package.json';

Expand Down Expand Up @@ -41,6 +42,9 @@ const themeConfig = {
};

export default defineConfig({
alias: {
'@lobehub/tts/react': path.join(__dirname, './src/react'),
},
apiParser: isProduction ? {} : false,
base: '/',
define: {
Expand All @@ -51,11 +55,10 @@ export default defineConfig({
mfsu: isWin ? undefined : {},
npmClient: 'pnpm',
publicPath: '/',
resolve: isProduction
? {
entryFile: './src/index.ts',
}
: undefined,
resolve: {
atomDirs: [{ dir: 'src/react', type: 'component' }],
entryFile: isProduction ? './src/index.ts' : undefined,
},
styles: [
`html, body { background: transparent; }

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
225 changes: 225 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,231 @@

# Changelog

## [Version 1.13.0-beta.3](https://github.com/lobehub/lobe-tts/compare/v1.13.0-beta.2...v1.13.0-beta.3)

<sup>Released on **2023-11-15**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor the demo usage.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Refactor the demo usage ([802c59a](https://github.com/lobehub/lobe-tts/commit/802c59a))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

## [Version 1.13.0-beta.2](https://github.com/lobehub/lobe-tts/compare/v1.13.0-beta.1...v1.13.0-beta.2)

<sup>Released on **2023-11-15**</sup>

#### ✨ Features

- **misc**: Add SWR config to hooks.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

- **misc**: Add SWR config to hooks ([2c49e02](https://github.com/lobehub/lobe-tts/commit/2c49e02))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

## [Version 1.13.0-beta.1](https://github.com/lobehub/lobe-tts/compare/v1.12.1-beta.6...v1.13.0-beta.1)

<sup>Released on **2023-11-15**</sup>

#### ✨ Features

- **misc**: Add class.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

- **misc**: Add class ([07245e3](https://github.com/lobehub/lobe-tts/commit/07245e3))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.12.1-beta.6](https://github.com/lobehub/lobe-tts/compare/v1.12.1-beta.5...v1.12.1-beta.6)

<sup>Released on **2023-11-15**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor to fix build.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Refactor to fix build ([9858fcb](https://github.com/lobehub/lobe-tts/commit/9858fcb))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.12.1-beta.5](https://github.com/lobehub/lobe-tts/compare/v1.12.1-beta.4...v1.12.1-beta.5)

<sup>Released on **2023-11-15**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor to fix build.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Refactor to fix build ([d875be6](https://github.com/lobehub/lobe-tts/commit/d875be6))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.12.1-beta.4](https://github.com/lobehub/lobe-tts/compare/v1.12.1-beta.3...v1.12.1-beta.4)

<sup>Released on **2023-11-15**</sup>

#### 🐛 Bug Fixes

- **misc**: Fix client fetch.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's fixed

- **misc**: Fix client fetch ([9262608](https://github.com/lobehub/lobe-tts/commit/9262608))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.12.1-beta.3](https://github.com/lobehub/lobe-tts/compare/v1.12.1-beta.2...v1.12.1-beta.3)

<sup>Released on **2023-11-15**</sup>

#### ♻ Code Refactoring

- **misc**: Fix react entry.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Fix react entry ([6a4631d](https://github.com/lobehub/lobe-tts/commit/6a4631d))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.12.1-beta.2](https://github.com/lobehub/lobe-tts/compare/v1.12.1-beta.1...v1.12.1-beta.2)

<sup>Released on **2023-11-15**</sup>

#### ♻ Code Refactoring

- **misc**: 将 react 部分抽取到 /react 子级路径下.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: 将 react 部分抽取到 /react 子级路径下 ([80b24e8](https://github.com/lobehub/lobe-tts/commit/80b24e8))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

### [Version 1.12.1-beta.1](https://github.com/lobehub/lobe-tts/compare/v1.12.0...v1.12.1-beta.1)

<sup>Released on **2023-11-15**</sup>

#### ♻ Code Refactoring

- **misc**: Refactor api.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

- **misc**: Refactor api ([a7c0095](https://github.com/lobehub/lobe-tts/commit/a7c0095))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>

## [Version 1.12.0](https://github.com/lobehub/lobe-tts/compare/v1.11.1...v1.12.0)

<sup>Released on **2023-11-13**</sup>
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ Click button below to deploy your private plugins' gateway.

This project provides some additional configuration items set with environment variables:

| Environment Variable | Description | Default |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| `ALLOW_ORIGINS` | Allow origins , string or string array | |
| `OPENAI_API_KEY` | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
| `OPENAI_PROXY_URL` | If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL | `https://api.openai.com/v1` |
| `AZURE_SPEECH_KEY` | This is the API key of Azure Speech Service | |
| `AZURE_SPEECH_REGION` | This is the region of Azure Speech Service | |
| `AZURE_SPEECH_PROXY_URL` | If you manually configure the AZURE Speech interface proxy, you can use this configuration item to override the default Speech API request base URL | `/api/azure-speech` |
| `MICROSOFT_SPEECH_PROXY_URL` | If you manually configure the Microsoft Speech interface proxy, you can use this configuration item to override the default Speech API request base URL | `/api/microsoft-speech` |
| `EDDGE_API_TOKEN` | This is the API key of Edge Speech Service | |
| `EDDGE_PROXY_URL` | If you manually configure the Edge interface proxy, you can use this configuration item to override the default Edge wss request base URL | |
| Environment Variable | Description | Default |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| `ALLOW_ORIGINS` | Allow origins , string or string array | |
| `OPENAI_API_KEY` | This is the API key you apply on the OpenAI account page | `sk-xxxxxx...xxxxxx` |
| `OPENAI_PROXY_URL` | If you manually configure the OpenAI interface proxy, you can use this configuration item to override the default OpenAI API request base URL | `https://api.openai.com/v1` |
| `AZURE_SPEECH_KEY` | This is the API key of Azure Speech Service | |
| `AZURE_SPEECH_REGION` | This is the region of Azure Speech Service | |
| `AZURE_SPEECH_PROXY_URL` | If you manually configure the AZURE Speech interface proxy, you can use this configuration item to override the default Speech API request base URL | `/api/azure-speech` |
| `MICROSOFT_SPEECH_API_URL` | If you manually configure the Microsoft Speech interface proxy, you can use this configuration item to override the default Speech API request base URL | `/api/microsoft-speech` |
| `EDGE_API_TOKEN` | This is the API key of Edge Speech Service | |
| `EDGE_SPEECH_API_URL` | If you manually configure the Edge interface proxy, you can use this configuration item to override the default Edge wss request base URL | |

<div align="right">

Expand Down
28 changes: 0 additions & 28 deletions api/azure-speech.ts

This file was deleted.

14 changes: 14 additions & 0 deletions api/edge-speech.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { createEdgeSpeechComletion } from '../src/server/createEdgeSpeechComletion';
import { EdgeSpeechPayload } from '../src/server/types';

export const config = {
runtime: 'edge',
};

export default async (req: Request) => {
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 });

const payload = (await req.json()) as EdgeSpeechPayload;

return createEdgeSpeechComletion({ payload });
};
12 changes: 5 additions & 7 deletions api/microsoft-speech.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import cors from '../src/server/cors';
import { getAllowOrigins } from '../src/server/getAllowOrigins';
import { handleMicrosoftSpeechRequest } from '../src/server/handleMicrosoftSpeechRequest';
import { createMicrosoftSpeechComletion } from '../src/server/createMicrosoftSpeechComletion';
import { MicrosoftSpeechPayload } from '../src/server/types';

export const config = {
runtime: 'edge',
};

export default async (req: Request) => {
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 });
const origin = getAllowOrigins(req);
if (!origin) return new Response('Origin Not Allowed', { status: 403 });
const res = await handleMicrosoftSpeechRequest(req);
return cors(req, new Response(res.body, res), { methods: ['POST'], origin });
const payload = (await req.json()) as MicrosoftSpeechPayload;

return createMicrosoftSpeechComletion({ payload });
};
28 changes: 28 additions & 0 deletions api/open-stt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import OpenAI from 'openai';

import { createOpenaiAudioTranscriptionsCompletion } from '../src/server/createOpenaiAudioTranscriptionsCompletion';
import { OpenAISTTPayload } from '../src/server/types';

export const config = {
runtime: 'edge',
};

export default async (req: Request) => {
if (req.method !== 'POST') return new Response('Method Not Allowed', { status: 405 });

const OPENAI_API_KEY = process.env.OPENAI_API_KEY;
const OPENAI_PROXY_URL = process.env.OPENAI_PROXY_URL;

if (!OPENAI_API_KEY) return new Response('OPENAI_API_KEY is not set', { status: 500 });

const payload = (await req.json()) as OpenAISTTPayload;

const openai = new OpenAI({ apiKey: OPENAI_API_KEY, baseURL: OPENAI_PROXY_URL });
const res = await createOpenaiAudioTranscriptionsCompletion({ openai, payload });

return new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json;charset=UTF-8',
},
});
};
Loading
Loading