Skip to content

Commit

Permalink
Merge pull request #32 from edgenai/feat/issue10
Browse files Browse the repository at this point in the history
Feat/issue10
  • Loading branch information
toschoo authored Feb 6, 2024
2 parents ddf3e7c + 28620f8 commit fde11ba
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 6 deletions.
40 changes: 40 additions & 0 deletions crates/edgen_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ async fn start_server(args: &cli::Serve) -> EdgenResult {
}

async fn run_server(args: &cli::Serve) -> bool {
status::set_chat_completions_active_model(
&SETTINGS
.read()
.await
.read()
.await
.chat_completions_model_name,
)
.await;

status::set_audio_transcriptions_active_model(
&SETTINGS
.read()
.await
.read()
.await
.audio_transcriptions_model_name,
)
.await;

let http_app = Router::new()
// -- AI endpoints -----------------------------------------------------
// ---- Chat -----------------------------------------------------------
Expand Down Expand Up @@ -275,6 +295,26 @@ async fn run_server(args: &cli::Serve) -> bool {
reset_channels.clear();
block_on(crate::llm::reset_environment());
block_on(crate::whisper::reset_environment());
block_on(async {
status::set_chat_completions_active_model(
&SETTINGS
.read()
.await
.read()
.await
.chat_completions_model_name,
)
.await;
status::set_audio_transcriptions_active_model(
&SETTINGS
.read()
.await
.read()
.await
.audio_transcriptions_model_name,
)
.await;
});
});

loop {
Expand Down
11 changes: 5 additions & 6 deletions crates/edgen_server/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,13 @@ async fn observe_progress(
let mut timestamp = Instant::now();
while m.is_ok() {
let s = m.unwrap().len() as u64;
let t = size;
let p = (s * 100) / t;
let p = (s * 100) / size;

if size > last_size {
last_size = size;
if s > last_size {
last_size = s;
timestamp = Instant::now();
} else if Instant::now().duration_since(timestamp) > Duration::from_secs(60) {
warn!("progress observer: no download progress in a minute. Giving up");
} else if Instant::now().duration_since(timestamp) > Duration::from_secs(180) {
warn!("progress observer: no download progress in three minutes. Giving up");
return;
};

Expand Down
47 changes: 47 additions & 0 deletions docs/src/app/api-reference/audio/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,50 @@ Discover how to convert audio to text or text to audio. OpenAI compliant. {{ cla

</Col>
</Row>

---

## Transcription status {{ tag: 'GET', label: 'http://localhost:33322/v1/audio/transcriptions/status' }}

<Row>
<Col>

Shows the current status of the audio transcriptions endpoint (e.g. downloads)

</Col>
<Col sticky>

<CodeGroup title="Request" tag="GET" label="v1/audio/transcriptions/status">

```bash {{ title: 'cURL' }}
curl http://localhost:33322/v1/audio/transcriptions/status \
-H "Authorization: Bearer no-key-required"
```

```python
from edgen import Edgen
client = Edgen()
status = client.audio.transcriptions.status.create()
print(status)
```

```ts
import Edgen from "edgen";
const client = new Edgen();
async function main() {
const status = await client.audio.transcriptions.status.create({});
console.log(status.text);
}
main();
```
</CodeGroup>

```json {{ title: 'Response' }}
{"active_model":"neural-chat-7b-v3-3.Q4_K_M.gguf","last_activity":"download","last_activity_result":"success","completions_ongoing":false,"download_ongoing":false,"download_progress":100,"last_errors":["Custom { kind: PermissionDenied, error: \"verboten\" }]}
```
</Col>
</Row>

0 comments on commit fde11ba

Please sign in to comment.