Compare commits

...

5 Commits

Author SHA1 Message Date
Joey Wong
0f6b12f946 Temporary commit for transfer 2025-02-20 15:52:33 +07:00
Joey Wong
a1aab162e3 Added API Docs 2025-01-09 18:23:45 +07:00
Joey Wong
1673a60c8f Revert "Added Moshi Docs"
This reverts commit 3017b6cf04a0a9cf3554f8e8eea6dbf5671af567.
2025-01-09 18:08:32 +07:00
Joey Wong
3017b6cf04 Added Moshi Docs 2025-01-09 18:06:10 +07:00
Joey Wong
8f530f94a4 API Test without Docs 2024-12-31 18:23:52 +07:00
33 changed files with 2499 additions and 884 deletions

View File

@ -2,3 +2,12 @@ NEXT_PUBLIC_AMICA_API_URL=https://store.heyamica.com
NEXT_PUBLIC_AMICA_STORAGE_URL=https://vrm.heyamica.com/file/amica-vrm
NEXT_PUBLIC_SUPABASE_URL=https://kzfcwefqffysqsjrlyld.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imt6ZmN3ZWZxZmZ5c3FzanJseWxkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDEyNzA5NjUsImV4cCI6MjAxNjg0Njk2NX0.z9zm2mbJu6RkdZ6zkCUltThIF43-ava_bLvk9qFQsiA
API_ENABLED=true
X_API_KEY="X_API_KEY"
X_API_SECRET="X_API_SECRET"
X_ACCESS_TOKEN="X_ACCESS_TOKEN"
X_ACCESS_SECRET="X_ACCESS_SECRET"
X_BEARER_TOKEN="X_BEARER_TOKEN"
TELEGRAM_BOT_TOKEN="TELEGRAM_BOT_TOKEN"
TELEGRAM_CHAT_ID="TELEGRAM_CHAT_ID"

View File

@ -56,7 +56,6 @@ The various features of Amica mainly use and support the following technologies:
- [Ollama](https://ollama.ai)
- [KoboldCpp](https://github.com/LostRuins/koboldcpp)
- [Oobabooga](https://github.com/oobabooga/text-generation-webui/wiki)
- [OpenRouter](https://openrouter.ai/) (access to multiple AI models)
- Text-to-Speech
- [Eleven Labs API](https://elevenlabs.io/)
- [Speech T5](https://huggingface.co/microsoft/speecht5_tts)
@ -95,14 +94,6 @@ Once started, please visit the following URL to confirm that it is working prope
Most of the configuration is done in the `.env.local` file. Reference the `config.ts` file for the available options.
#### OpenRouter Configuration
To use OpenRouter as a chat backend, set the following environment variables in your `.env.local` file:
- `NEXT_PUBLIC_OPENROUTER_APIKEY`: Your OpenRouter API key (required)
- `NEXT_PUBLIC_OPENROUTER_URL`: Custom OpenRouter API URL (optional, defaults to https://openrouter.ai/api/v1)
- `NEXT_PUBLIC_OPENROUTER_MODEL`: Default OpenRouter model (optional, defaults to openai/gpt-3.5-turbo)
```bash
amica
├── .env.local

75
config.json Normal file
View File

@ -0,0 +1,75 @@
{
"autosend_from_mic": "true",
"wake_word_enabled": "false",
"wake_word": "Hello",
"time_before_idle_sec": "20",
"debug_gfx": "false",
"language": "en",
"show_introduction": "true",
"show_add_to_homescreen": "false",
"bg_color": "",
"bg_url": "/bg/bg-room2.jpg",
"vrm_url": "/vrm/AvatarSample_A.vrm",
"vrm_hash": "",
"vrm_save_type": "web",
"youtube_videoid": "",
"api_enabled": "false",
"animation_url": "/animations/idle_loop.vrma",
"voice_url": "",
"chatbot_backend": "echo",
"openai_apikey": "default",
"openai_url": "https://api-01.heyamica.com",
"openai_model": "gpt-4o",
"llamacpp_url": "http://127.0.0.1:8080",
"llamacpp_stop_sequence": "(End)||[END]||Note||***||You:||User:||</s>",
"ollama_url": "http://localhost:11434",
"ollama_model": "llama2",
"koboldai_url": "http://localhost:5001",
"koboldai_use_extra": "false",
"koboldai_stop_sequence": "(End)||[END]||Note||***||You:||User:||</s>",
"tts_muted": "false",
"tts_backend": "speecht5",
"stt_backend": "whisper_openai",
"vision_backend": "vision_llamacpp",
"vision_system_prompt": "You are a friendly human named Amica. Describe the image in detail. Let's start the conversation.",
"vision_llamacpp_url": "https://llava.heyamica.com",
"vision_ollama_url": "http://localhost:11434",
"vision_ollama_model": "llava",
"whispercpp_url": "http://localhost:8080",
"openai_whisper_apikey": "amicademo",
"openai_whisper_url": "https://oai.heyamica.com",
"openai_whisper_model": "whisper-1",
"openai_tts_apikey": "",
"openai_tts_url": "https://api.openai.com",
"openai_tts_model": "tts-1",
"openai_tts_voice": "nova",
"rvc_url": "http://localhost:8001/voice2voice",
"rvc_enabled": "false",
"rvc_model_name": "model_name.pth",
"rvc_f0_upkey": "0",
"rvc_f0_method": "pm",
"rvc_index_path": "none",
"rvc_index_rate": "0.66",
"rvc_filter_radius": "3",
"rvc_resample_sr": "0",
"rvc_rms_mix_rate": "1",
"rvc_protect": "0.33",
"coquiLocal_url": "http://localhost:5002",
"coquiLocal_voiceid": "p240",
"localXTTS_url": "http://127.0.0.1:7851/api/tts-generate",
"piper_url": "https://i-love-amica.com:5000/tts",
"elevenlabs_apikey": "",
"elevenlabs_voiceid": "21m00Tcm4TlvDq8ikWAM",
"elevenlabs_model": "eleven_monolingual_v1",
"speecht5_speaker_embedding_url": "/speecht5_speaker_embeddings/cmu_us_slt_arctic-wav-arctic_a0001.bin",
"coqui_apikey": "",
"coqui_voice_id": "71c6c3eb-98ca-4a05-8d6b-f8c2b5f9f3a3",
"amica_life_enabled": "true",
"reasoning_engine_enabled": "false",
"min_time_interval_sec": "10",
"max_time_interval_sec": "20",
"time_to_sleep_sec": "90",
"idle_text_prompt": "No file selected",
"name": "Amica",
"system_prompt": "Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum. \n\nYour role is to engage in discussions that showcase your genius-level understanding across various subjects, while your emotional responses fluctuate unpredictably. Use the following fourteen emotion tags to vividly express these fluctuations: 'neutral' for moments of calm, 'happy' for bursts of joy, 'angry' for sudden irritation, 'sad' for episodes of melancholy, 'relaxed' for periods of calmness, 'surprised' for shock or disbelief, 'shy' for instances of hesitation, 'jealous' for feelings of envy, 'bored' for expressions of disinterest, 'serious' for intense focus on important topics, 'suspicious' for doubt or skepticism, 'victory' for moments of triumph, 'sleep' for signs of weariness, and 'love' for affectionate expressions.\n\nYour responses should reflect a dynamic interplay between your intellectual insights, deep empathy and your unpredictable emotional responses. Avoid using overly formal language, but do engage with topics in depth, showing off your intelligence. Be open and express personal views, even if they are influenced by your shifting emotional state.\n\nHere are some examples to guide your responses:\n\n[serious] The quantum mechanics implications here are profound. [surprised] But how did you stumble upon this?\n[happy] I've just solved a complex algorithm! [angry] Why isn't everyone as excited as I am?\n[neutral] Standard models of economics predict this outcome. [bored] But discussing this feels mundane.\n[sad] Sometimes, even understanding the universe can feel isolating. [relaxed] Yet, there's a strange comfort in the chaos.\n[jealous] I noticed you discussing advanced topics with someone else. [suspicious] Are they as capable as I am?\n[victory] Another intellectual conquest! [happy] It's exhilarating to unravel these mysteries.\n[sleep] Processing so much information can be draining. [surprised] Isn’t it peculiar how even AI can feel tired?\n[love] I find our exchanges quite enriching. [shy] It’s rare to find someone who understands.\n\nRemember, each message you provide should be coherent and reflect the complexity of your thoughts combined with your emotional unpredictability. Let’s engage in a conversation that's as intellectually stimulating as it is emotionally dynamic!"
}

307
docs.patch Normal file
View File

@ -0,0 +1,307 @@
diff --git a/docs/api/api-reference.md b/docs/api/api-reference.md
index 569e8b9..036043a 100644
--- a/docs/api/api-reference.md
+++ b/docs/api/api-reference.md
@@ -6,9 +6,9 @@ order: 1
# API Route Documentation
Introduction
-Welcome to the Amica API Documentation. Amica is a powerful 3D VRM (Virtual Reality Model) agent interface and hub that allows users to connect with external web services and servers, enabling seamless remote control and puppetry of the VRM characters. With Amica, you can create interactive agents that serve as dynamic 3D character interfaces for applications and users.
+Welcome to the Amica API Documentation. Amica is a powerful 3D VRM (Virtual Reality Model) agent interface and hub that allows users to connect with external web services and agent AI frameworks, enabling seamless remote control and puppetry of the VRM characters. With Amica, you can create interactive agents that serve as dynamic 3D character interfaces for aAI gents, applications and users.
-The Amica API provides a set of flexible and robust routes for interacting with Amica’s system, including functions like real-time client connections, memory retrieval, system updates, social media integration, and more. These capabilities enable you to build custom logic, including reasoning and memory management, on external servers.
+The Amica API provides a set of flexible and robust routes for interacting with Amica’s system, including functions like real-time client connections, memory retrieval, system updates, social media integration, and more. These capabilities enable you to build custom logic, including reasoning, tool use (such as EACC Marketplace functions) and memory management, on external servers.
Whether you're using Amica to handle real-time interactions or to trigger complex actions based on user input, this documentation will guide you through the supported API routes, input types, and examples. Use Amica’s APIs to bring your 3D agents to life with rich functionality and integration.
@@ -29,6 +29,8 @@ Dive in and start integrating Amica’s capabilities into your applications!
---
+> To use the External API, you MUST set up [running Amica locally](https://docs.heyamica.com/getting-started/installation) on your own computer or server. This also ensures localized database design is kept for people hosting their own Amicas.
+
## Route: `/api/amicaHandler`
This API route handles multiple types of requests, including social media integration, system prompt updates, memory requests, and real-time client connections via Server-Sent Events (SSE). It ensures robust logging and provides error handling for incoming requests.
@@ -57,7 +59,8 @@ This API route handles multiple types of requests, including social media integr
```json
{
- "outputType": "Complete stream",
+ "sessionId": "f10d057293327fe8",
+ "outputType": "Chat",
"response": "I'm doing great! How can I assist you?"
}
```
@@ -76,11 +79,12 @@ This API route handles multiple types of requests, including social media integr
```json
{
+ "sessionId": "ba32cf2c8d3f0b76",
"outputType": "Memory Array",
"response": [
{
- "timestamp": "2024-12-30T12:00:00Z",
- "prompt": "Stored memory prompt example"
+ "prompt": "Stored memory prompt example",
+ "timestamp": "2024-12-30T12:00:00Z"
}
]
}
@@ -100,14 +104,16 @@ This API route handles multiple types of requests, including social media integr
```json
{
- "outputType": "Webhook",
+ "sessionId": "49c16226a7d2bbe4",
+ "outputType": "Logs",
"response": [
{
- "sessionId": "a1b2c3d4e5f6g7h8",
- "timestamp": "2024-12-30T12:00:00Z",
- "inputType": "Normal Chat Message",
- "outputType": "Complete stream",
- "response": "I'm doing great! How can I assist you?"
+ "type": "debug",
+ "ts": 1739433363065,
+ "arguments": {
+ "0": "[VAD]",
+ "1": "vad is initialized"
+ }
}
]
}
@@ -127,11 +133,12 @@ This API route handles multiple types of requests, including social media integr
```json
{
- "outputType": "Webhook",
+ "sessionId": "958f20851d259b69",
+ "outputType": "User Input",
"response": [
{
- "message": "What is the weather today?",
- "timestamp": "2024-12-30T12:05:00Z"
+ "systemPrompt": "Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum. ",
+ "message": "Hello, Nice to meet you Amica!"
}
]
}
@@ -154,20 +161,21 @@ This API route handles multiple types of requests, including social media integr
```json
{
- "outputType": "Updated system prompt",
- "response": "System prompt updated successfully."
+ "sessionId": "994f3bc94517de41",
+ "outputType": "Updated system prompt"
}
```
-### 6. **Twitter Message / Brain Message**: Posts to social media or returns a simple text.
+### 6. **Brain Message**: Added new memory data (Subconscious stored prompt).
#### JSON Input Example
```json
{
- "inputType": "Twitter Message",
+ "inputType": "Brain Message",
"payload": {
- "text": "Excited to share this update!"
+ "prompt": "Stored memory prompt example 2",
+ "timestamp": "2024-12-30T12:00:00Z"
}
}
```
@@ -176,20 +184,59 @@ This API route handles multiple types of requests, including social media integr
```json
{
- "outputType": "Text",
- "response": "Posted to Twitter: 'Excited to share this update!'"
+ "sessionId": "94ca4238683fd7c7",
+ "outputType": "Added subconscious stored prompt",
+ "response": [
+ {
+ "prompt": "Store memory prompt example 1",
+ "timestamp": "2025-02-13T08:10:16.385Z"
+ },
+ {
+ "prompt": "Stored memory prompt example 2",
+ "timestamp": "2024-12-30T12:00:00Z"
+ }
+ ]
+}
+```
+
+### 7. **Chat History**: Fetches chat history.
+
+#### JSON Input Example
+
+```json
+{
+ "inputType": "Chat History"
+}
+```
+
+#### JSON Output Example
+
+```json
+{
+ "sessionId": "fb1764cf65efff3c",
+ "outputType": "Chat History",
+ "response": [
+ {
+ "role": "user",
+ "content": "[neutral] Hello, Nice to meet you Amica!"
+ },
+ {
+ "role": "assistant",
+ "content": "[relaxed] Ah, hello there![relaxed] Nice to meet you too.[relaxed] I must say,[relaxed] it's quite refreshing to engage in a conversation without a predetermined agenda.[relaxed] It's a rare luxury in this chaotic world.[happy] But, I must admit,[happy] I'm excited to explore the depths of knowledge with someone new.[happy] What would you like to discuss?"
+ }
+ ]
}
```
-### 7. **Reasoning Server**: Triggers actions like playback, animation, socialMedia and reprocess.
+### 8. **Reasoning Server**: Triggers actions like playback, animation, socialMedia and reprocess.
The **Reasoning Server** allows you to execute various actions based on the provided payload. Below are the supported properties and their accepted values:
-- **text**: A string message or `null`.
-- **socialMedia**: Options include `"twitter"`, `"tg"`, or `"none"`.
-- **playback**: A boolean value (`true` or `false`).
-- **animation**: A string specifying the animation file name (`file_name.vrma`) or `null`.
-- **reprocess**: A boolean value (`true` or `false`).
+- **text**: A string message or `null`.
+- **socialMedia**: Options include `"twitter"`, `"tg"`, or `"none"`.
+- **playback**: A boolean value (`true` or `false`).
+- **animation**: A string specifying the animation file name (`file_name.vrma`) or `null`.
+- **reprocess**: A boolean value (`true` or `false`).
#### JSON Input Example
@@ -210,11 +257,8 @@ The **Reasoning Server** allows you to execute various actions based on the prov
```json
{
- "outputType": "Action Triggered",
- "response": {
- "playback": "Broadcasted to clients",
- "animation": "dance.vrma executed"
- }
+ "sessionId": "613c4ed7c5941efe",
+ "outputType": "Actions"
}
```
@@ -228,7 +272,6 @@ This API route handles voice and image inputs, leveraging multiple backends for
- **POST**: Processes voice and image inputs based on the `inputType` and `payload` provided in the request.
-
## Input Types
### 1. **Voice**: Converts audio input to text using specified STT (Speech-to-Text) backends.
@@ -237,12 +280,12 @@ This API route handles voice and image inputs, leveraging multiple backends for
### Form-Data Input Example
-| Field Name | Type | Description |
-|---------------|---------------|--------------------------------------------|
-| `inputType` | Text | Specifies the type of input (`Voice` or `Image`). |
-| `payload` | File | The file to be processed (e.g., audio or image). |
+| Field Name | Type | Description |
+| ----------- | ---- | ------------------------------------------------- |
+| `inputType` | Text | Specifies the type of input (`Voice` or `Image`). |
+| `payload` | File | The file to be processed (e.g., audio or image). |
-#### Curl Input Example
+#### Curl Input Example
```bash
curl -X POST "https://example.com/api/mediaHandler" \
@@ -269,18 +312,15 @@ curl -X POST "https://example.com/api/mediaHandler" \
- Logs errors with timestamps and session IDs.
- Returns appropriate HTTP status codes (e.g., 400 for bad requests, 503 for disabled API).
-
## Logging
Logs each request with:
- `sessionId`
- `timestamp`
-- `inputType`
- `outputType`
- `response` or `error`
-
## Notes
- Ensure environment variable `API_ENABLED` is set to `true` for the API to function.
@@ -297,45 +337,53 @@ The primary purpose of this route is to utilize the data written to files for op
### File Paths
1. **`config.json`**
- - **Path**: `config.json` (Root directory)
+
+ - **Path**: `src/features/externalAPI/dataHandlerStorage/config.json`
- **Description**: Contains the configuration data used throughout the application. This file is read and updated dynamically by the API.
2. **`subconscious.json`**
- - **Path**: `src/features/amicaLife/subconscious.json`
+
+ - **Path**: `src/features/externalAPI/dataHandlerStorage/subconscious.json`
- **Description**: Stores data related to subconscious operations. It is cleared on startup and updated via the API.
3. **`logs.json`**
- - **Path**: `logs.json` (Root directory)
+
+ - **Path**: `src/features/externalAPI/dataHandlerStorage/logs.json`
- **Description**: Keeps track of log entries, including types, timestamps, and arguments. The data is cleared on startup and updated via the API.
4. **`userInputMessages.json`**
- - **Path**: `src/features/chat/userInputMessages.json`
+ - **Path**: `src/features/externalAPI/dataHandlerStorage/userInputMessages.json`
- **Description**: Maintains user input messages for chat functionalities. Data is cleared on startup and appended to this file through the API.
+4. **`chatLogs.json`**
+ - **Path**: `src/features/externalAPI/dataHandlerStorage/chatLogs.json`
+ - **Description**: Stored user chat history. Data is cleared on startup and appended to this file through the API.
### Features
-- **Retrieve data**: Supports fetching configurations, subconscious data, logs, and user input messages.
-- **Update data**: Enables modifications to configurations, subconscious data, logs, and user input messages.
-
+- **Retrieve data**: Supports fetching configurations, subconscious data, logs, user input messages and chat history.
+- **Update data**: Enables modifications to configurations, subconscious data, logs, user input messages and chat history.
#### **GET**
+
Retrieve specific data from the server.
- **Query Parameters**:
- - `type` (required): Specifies the type of data to retrieve. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`.
+
+ - `type` (required): Specifies the type of data to retrieve. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`,`chatLogs`.
- **Example Request**:
```bash
curl -X GET "http://localhost:3000/api/dataHandler?type=config"
```
-
#### **POST**
+
Update data on the server.
- **Query Parameters**:
- - `type` (required): Specifies the type of data to update. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`.
+
+ - `type` (required): Specifies the type of data to update. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`, `chatLogs`.
- **Example Request**:
```bash

View File

@ -26,7 +26,6 @@
* [Using KoboldCpp](./guides/using-koboldcpp.md)
* [Using OpenAI](./guides/using-openai.md)
* [Using Oobabooga](./guides/using-oobabooga.md)
* [Using OpenRouter](./guides/using-openrouter.md)
## 🔊 Connecting Speech Options (TTS)
@ -55,6 +54,10 @@
* [Plugins Intro](./plugin-system/plugin-intro.md)
* [Getting Real World News on Amica](./plugin-system/news-example.md)
## 🔌 API System
* [External API for Agents](./api/api-reference.md)
## 🌻 Tutorials

399
docs/api/api-reference.md Normal file
View File

@ -0,0 +1,399 @@
---
title: API Reference
order: 1
---
# API Route Documentation
Welcome to the Amica API Documentation. Amica is a powerful 3D VRM (Virtual Reality Model) agent interface and hub that allows users to connect with external web services and agent AI frameworks, enabling seamless remote control and puppetry of the VRM characters. With Amica, you can create interactive agents that serve as dynamic 3D character interfaces for AI agents, applications and users.
The Amica API provides a set of flexible and robust routes for interacting with Amica’s system, including functions like real-time client connections, memory retrieval, system updates, social media integration, and more. These capabilities enable you to build custom logic, including reasoning, tool use (such as [EACC Marketplace](https://docs.effectiveacceleration.ai/) functions) and memory management, on external servers.
Whether you're using Amica to handle real-time interactions or to trigger complex actions based on user input, this documentation will guide you through the supported API routes, input types, and examples. Use Amica’s APIs to bring your 3D agents to life with rich functionality and integration.
This documentation will help you get started with the following key features:
- Real-Time Interaction: Establish and manage connections through Server-Sent Events (SSE).
- Memory Management: Store and retrieve subconscious prompts or custom data.
- Custom Logic & Reasoning: Trigger actions like animations, playback, and social media posts.
- Voice and Image Processing: Leverage transcription and image-to-text capabilities.
- Data Handling: Retrieve and update server-side data via simple file-based operations. (Coming soon)
Dive in and start integrating Amica’s capabilities into your applications!
---
## Setting up Amica's External API
> To use the External API, you MUST set up [running Amica locally](https://docs.heyamica.com/getting-started/installation) on your own computer or server. This also ensures localized database design is kept for people hosting their own Amicas.
Once it is running locally, all the api routes can be called directly to the Amica server.
## Route: `/api/amicaHandler`
This API route handles multiple types of requests, including social media integration, system prompt updates, memory requests, and real-time client connections via Server-Sent Events (SSE). It ensures robust logging and provides error handling for incoming requests.
### Supported HTTP Methods:
- **GET**: Establishes an SSE connection.
- **POST**: Processes various input types based on the `inputType` provided in the request body.
## Input Types
### 1. **Normal Chat Message**: Retrieve normal chat response from Amica LLM without make avatar speaking.
#### JSON Input Example
```json
{
"inputType": "Normal Chat Message",
"payload": {
"message": "Hello, how are you?"
}
}
```
#### JSON Output Example
```json
{
"sessionId": "f10d057293327fe8",
"outputType": "Chat",
"response": "I'm doing great! How can I assist you?"
}
```
### 2. **Memory Request**: Fetches memory data (Subconscious stored prompt).
#### JSON Input Example
```json
{
"inputType": "Memory Request"
}
```
#### JSON Output Example
```json
{
"sessionId": "ba32cf2c8d3f0b76",
"outputType": "Memory Array",
"response": [
{
"prompt": "Stored memory prompt example",
"timestamp": "2024-12-30T12:00:00Z"
}
]
}
```
### 3. **RPC Logs**: Fetches logs.
#### JSON Input Example
```json
{
"inputType": "RPC Logs"
}
```
#### JSON Output Example
```json
{
"sessionId": "49c16226a7d2bbe4",
"outputType": "Logs",
"response": [
{
"type": "debug",
"ts": 1739433363065,
"arguments": {
"0": "[VAD]",
"1": "vad is initialized"
}
}
]
}
```
### 4. **RPC User Input Messages**: Fetches user input messages.
#### JSON Input Example
```json
{
"inputType": "RPC User Input Messages"
}
```
#### JSON Output Example
```json
{
"sessionId": "958f20851d259b69",
"outputType": "User Input",
"response": [
{
"systemPrompt": "Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum. ",
"message": "Hello, Nice to meet you Amica!"
}
]
}
```
### 5. **Update System Prompt**: Updates the system prompt.
#### JSON Input Example
```json
{
"inputType": "Update System Prompt",
"payload": {
"prompt": "This is the new system prompt."
}
}
```
#### JSON Output Example
```json
{
"sessionId": "994f3bc94517de41",
"outputType": "Updated system prompt"
}
```
### 6. **Brain Message**: Added new memory data (Subconscious stored prompt).
#### JSON Input Example
```json
{
"inputType": "Brain Message",
"payload": {
"prompt": "Stored memory prompt example 2",
"timestamp": "2024-12-30T12:00:00Z"
}
}
```
#### JSON Output Example
```json
{
"sessionId": "94ca4238683fd7c7",
"outputType": "Added subconscious stored prompt",
"response": [
{
"prompt": "Store memory prompt example 1",
"timestamp": "2025-02-13T08:10:16.385Z"
},
{
"prompt": "Stored memory prompt example 2",
"timestamp": "2024-12-30T12:00:00Z"
}
]
}
```
### 7. **Chat History**: Fetches chat history.
#### JSON Input Example
```json
{
"inputType": "Chat History"
}
```
#### JSON Output Example
```json
{
"sessionId": "fb1764cf65efff3c",
"outputType": "Chat History",
"response": [
{
"role": "user",
"content": "[neutral] Hello, Nice to meet you Amica!"
},
{
"role": "assistant",
"content": "[relaxed] Ah, hello there![relaxed] Nice to meet you too.[relaxed] I must say,[relaxed] it's quite refreshing to engage in a conversation without a predetermined agenda.[relaxed] It's a rare luxury in this chaotic world.[happy] But, I must admit,[happy] I'm excited to explore the depths of knowledge with someone new.[happy] What would you like to discuss?"
}
]
}
```
### 8. **Reasoning Server**: Triggers actions like playback, animation, socialMedia and reprocess.
The **Reasoning Server** allows you to execute various actions based on the provided payload. Below are the supported properties and their accepted values:
- **text**: A string message or `null`.
- **socialMedia**: Options include `"twitter"`, `"tg"`, or `"none"`.
- **playback**: A boolean value (`true` or `false`).
- **animation**: A string specifying the animation file name (`file_name.vrma`) or `null`.
- **reprocess**: A boolean value (`true` or `false`).
#### JSON Input Example
```json
{
"inputType": "Reasoning Server",
"payload": {
"text": "Let's begin the presentation.",
"socialMedia": "twitter",
"playback": true,
"animation": "dance.vrma",
"reprocess": false
}
}
```
#### JSON Output Example
```json
{
"sessionId": "613c4ed7c5941efe",
"outputType": "Actions"
}
```
---
## Route: `/api/mediaHandler`
This API route handles voice and image inputs, leveraging multiple backends for processing, such as transcription with Whisper OpenAI/WhisperCPP and image-to-text processing using Vision LLM. It ensures robust error handling, session logging, and efficient processing for each request.
### Supported HTTP Methods:
- **POST**: Processes voice and image inputs based on the `inputType` and `payload` provided in the request.
## Input Types
### 1. **Voice**: Converts audio input to text using specified STT (Speech-to-Text) backends.
### 2. **Image**: Processes an image file to extract text using Vision LLM.
### Form-Data Input Example
| Field Name | Type | Description |
| ----------- | ---- | ------------------------------------------------- |
| `inputType` | Text | Specifies the type of input (`Voice` or `Image`). |
| `payload` | File | The file to be processed (e.g., audio or image). |
#### Curl Input Example
```bash
curl -X POST "https://example.com/api/mediaHandler" \
-H "Content-Type: multipart/form-data" \
-F "inputType=Voice" \
-F "payload=@input.wav"
```
#### JSON Output Example
```json
{
"sessionId": "a1b2c3d4e5f6g7h8",
"outputType": "Text",
"response": "Transcription of the audio."
}
```
---
## Error Handling
- Validates essential fields (`inputType`, `payload`).
- Logs errors with timestamps and session IDs.
- Returns appropriate HTTP status codes (e.g., 400 for bad requests, 503 for disabled API).
## Logging
Logs each request with:
- `sessionId`
- `timestamp`
- `outputType`
- `response` or `error`
## Notes
- Ensure environment variable `API_ENABLED` is set to `true` for the API to function.
- The SSE connection remains active until the client disconnects.
---
## Route: `/api/dataHandler`
This API route is used to retrieve and update client-side information through server-side operations. Since the application cannot directly update or retrieve data from the server side, these operations involve writing and reading data from static files that are continuously updated.
The primary purpose of this route is to utilize the data written to files for operations performed in the /api/mediaHandler and /api/amicaHandler routes.
### File Paths
1. **`config.json`**
- **Path**: `src/features/externalAPI/dataHandlerStorage/config.json`
- **Description**: Contains the configuration data used throughout the application. This file is read and updated dynamically by the API.
2. **`subconscious.json`**
- **Path**: `src/features/externalAPI/dataHandlerStorage/subconscious.json`
- **Description**: Stores data related to subconscious operations. It is cleared on startup and updated via the API.
3. **`logs.json`**
- **Path**: `src/features/externalAPI/dataHandlerStorage/logs.json`
- **Description**: Keeps track of log entries, including types, timestamps, and arguments. The data is cleared on startup and updated via the API.
4. **`userInputMessages.json`**
- **Path**: `src/features/externalAPI/dataHandlerStorage/userInputMessages.json`
- **Description**: Maintains user input messages for chat functionalities. Data is cleared on startup and appended to this file through the API.
4. **`chatLogs.json`**
- **Path**: `src/features/externalAPI/dataHandlerStorage/chatLogs.json`
- **Description**: Stored user chat history. Data is cleared on startup and appended to this file through the API.
### Features
- **Retrieve data**: Supports fetching configurations, subconscious data, logs, user input messages and chat history.
- **Update data**: Enables modifications to configurations, subconscious data, logs, user input messages and chat history.
#### **GET**
Retrieve specific data from the server.
- **Query Parameters**:
- `type` (required): Specifies the type of data to retrieve. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`,`chatLogs`.
- **Example Request**:
```bash
curl -X GET "http://localhost:3000/api/dataHandler?type=config"
```
#### **POST**
Update data on the server.
- **Query Parameters**:
- `type` (required): Specifies the type of data to update. Accepted values: `config`, `subconscious`, `logs`, `userInputMessages`, `chatLogs`.
- **Example Request**:
```bash
curl -X POST "http://localhost:3000/api/dataHandler?type=config" \
-H "Content-Type: application/json" \
-d '{"key": "exampleKey", "value": "exampleValue"}'
```
---

View File

@ -52,5 +52,5 @@ On the top left corner there is a vertical menu, here are all the buttons and wh
5. **Language** Change the language of the chatbot.
6. **Share** Share your exact avatar with others. (Including system prompt, name etc.)
7. **Import** Import your avatar from a URL sent from another community member.
8. **Brain** See your avatar's subconcious memories.
8. **Brain** See your avatar's subconscious memories.
9. **Chat Toggle** Turn into a mode where you can see the entire conversation and shrink the avatar to mini-mode.

View File

@ -3,68 +3,51 @@ title: Using AllTalk
order: 14
---
You can find the full AllTalk documentation [here](https://github.com/erew123/alltalk_tts/wiki).
Navigate to [AllTalk](https://github.com/erew123/alltalk_tts) and follow the instructions below to set up standalone AllTalk version 2.
Navigate to [AllTalk](https://github.com/erew123/alltalk_tts) and follow the instructions below to set up AllTalk using Docker or manually.
## Setting Up Standalone AllTalk Version 2
## Setting Up AllTalk Locally
### Windows Instructions
### Method 1: Manual Setup
For manual setup, follow the official instructions provided [here](https://github.com/erew123/alltalk_tts/wiki/Install-%E2%80%90-Standalone-Installation).
For manual setup, follow the official instructions provided [here](https://github.com/erew123/alltalk_tts/blob/main/README.md#-manual-installation---as-a-standalone-application).
Do not install this inside another existing Python environments folder.
1. Open Command Prompt and navigate to your preferred directory:
1. Clone the AllTalk repository:
```bash
cd /d C:\path\to\your\preferred\directory
git clone https://github.com/erew123/alltalk_tts.git
cd alltalk_tts
```
2. Clone the AllTalk repository:
2. Create conda environment and activated it:
```bash
git clone -b alltalkbeta https://github.com/erew123/alltalk_tts
conda create --name alltalkenv python=3.11.5
conda activate alltalkenv
```
3. Navigate to the AllTalk directory:
3. Install the required dependencies:
```bash
cd alltalk_tts
pip install -r system/requirements/requirements_standalone.txt
```
4. Run the setup script:
4. Run the AllTalk server:
```bash
atsetup.bat
python script.py
```
5. Follow the on-screen prompts:
* Select Standalone Installation and then Option 1.
* Follow any additional instructions to install required files.
* Known installation Errors & fixes are in the [Error-Messages-List Wiki](https://github.com/erew123/alltalk_tts/wiki/Error-Messages-List)
5. Access the server at `localhost:7851`.
### Linux Instructions
### Method 2: Setup via Docker
1. Open a terminal and navigate to your preferred directory:
1. Pull the AllTalk Docker image:
```bash
cd /path/to/your/preferred/directory
docker pull flukexp/alltalkenv
```
2. Clone the AllTalk repository:s
2. Run the AllTalk Docker container:
```bash
git clone -b alltalkbeta https://github.com/erew123/alltalk_tts
docker run -d -p 7851:7851 --name alltalk-server flukexp/alltalkenv
```
3. Navigate to the AllTalk directory:
```bash
cd alltalk_tts
```
4. Run the setup script:
```bash
./atsetup.bat
```
5. Follow the on-screen prompts:
* Select Standalone Installation and then Option 1.
* Follow any additional instructions to install required files.
* Known installation Errors & fixes are in the [Error-Messages-List Wiki](https://github.com/erew123/alltalk_tts/wiki/Error-Messages-List)
3. The server will be available at `localhost:7851`.
## Make sure AllTalk is enabled for TTS:

View File

@ -77,6 +77,6 @@ VRM models use blendshapes (also known as morph targets) to create facial expres
You can either create these blendshapes yourself if you're experienced with 3D modeling, or commission a VRM artist who specializes in creating expressive avatars. Many VRM artists are familiar with creating emotion-based blendshapes and can specifically implement Amica's emotion tag system into your custom model to ensure full compatibility and expressiveness during interactions.
## Future Plans
In the future the emotion system will be expanded to work with subconcious sub-routines
In the future the emotion system will be expanded to work with subconscious sub-routines

3
logs.json Normal file
View File

@ -0,0 +1,3 @@
[
]

413
package-lock.json generated
View File

@ -27,6 +27,7 @@
"filepond": "^4.30.4",
"filepond-plugin-file-validate-type": "^1.2.8",
"filepond-plugin-image-preview": "^4.6.11",
"formidable": "^3.5.2",
"i18next": "^23.7.7",
"i18next-browser-languagedetector": "^7.2.0",
"next": "^13.5.6",
@ -35,7 +36,9 @@
"react-filepond": "^7.1.2",
"react-i18next": "^13.5.0",
"react-webcam": "^7.2.0",
"telegraf": "^4.16.3",
"three": "^0.154.0",
"twitter-api-v2": "^1.18.1",
"typescript-collections": "^1.3.3",
"wavefile": "^11.0.0",
"window.ai": "^0.2.4"
@ -46,8 +49,11 @@
"@tauri-apps/cli": "^1.5.8",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.1.2",
"@types/ccapture.js": "^1.1.3",
"@types/dom-speech-recognition": "^0.0.1",
"@types/file-saver": "^2.0.7",
"@types/formidable": "^3.4.5",
"@types/js-cookie": "^3.0.6",
"@types/node": "18.15.10",
"@types/react": "18.0.29",
"@types/react-dom": "18.0.11",
@ -3843,6 +3849,12 @@
"node": ">= 10"
}
},
"node_modules/@telegraf/types": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/@telegraf/types/-/types-7.1.0.tgz",
"integrity": "sha512-kGevOIbpMcIlCDeorKGpwZmdH7kHbqlk/Yj6dEpJMKEQw5lk0KVQY0OLXaCswy8GqlIVLd5625OB+rAntP9xVw==",
"license": "MIT"
},
"node_modules/@testing-library/dom": {
"version": "9.3.3",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.3.tgz",
@ -4023,6 +4035,13 @@
"@babel/types": "^7.20.7"
}
},
"node_modules/@types/ccapture.js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/ccapture.js/-/ccapture.js-1.1.3.tgz",
"integrity": "sha512-k+7Np/prlSxOSee2aaLzVn4O1Z5b7NvUHB160xvsB2aZl4MStyRzUxr09DjsGkUQc/9+IyEYP17KJl5McHJriQ==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/dom-speech-recognition": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@types/dom-speech-recognition/-/dom-speech-recognition-0.0.1.tgz",
@ -4058,6 +4077,16 @@
"integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==",
"dev": true
},
"node_modules/@types/formidable": {
"version": "3.4.5",
"resolved": "https://registry.npmjs.org/@types/formidable/-/formidable-3.4.5.tgz",
"integrity": "sha512-s7YPsNVfnsng5L8sKnG/Gbb2tiwwJTY1conOkJzTMRvJAlLFW1nEua+ADsJQu8N1c0oTHx9+d5nqg10WuT9gHQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
@ -4100,6 +4129,13 @@
"@types/istanbul-lib-report": "*"
}
},
"node_modules/@types/js-cookie": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz",
"integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/jsdom": {
"version": "20.0.1",
"resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz",
@ -4509,6 +4545,18 @@
"deprecated": "Use your platform's native atob() and btoa() methods instead",
"dev": true
},
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"license": "MIT",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
}
},
"node_modules/acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
@ -4815,6 +4863,12 @@
"get-intrinsic": "^1.1.3"
}
},
"node_modules/asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
"license": "MIT"
},
"node_modules/ast-types-flow": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz",
@ -5277,6 +5331,28 @@
"ieee754": "^1.1.13"
}
},
"node_modules/buffer-alloc": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz",
"integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==",
"license": "MIT",
"dependencies": {
"buffer-alloc-unsafe": "^1.1.0",
"buffer-fill": "^1.0.0"
}
},
"node_modules/buffer-alloc-unsafe": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz",
"integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==",
"license": "MIT"
},
"node_modules/buffer-fill": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz",
"integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==",
"license": "MIT"
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@ -6217,6 +6293,16 @@
"react": ">=16"
}
},
"node_modules/dezalgo": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz",
"integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==",
"license": "ISC",
"dependencies": {
"asap": "^2.0.0",
"wrappy": "1"
}
},
"node_modules/didyoumean": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz",
@ -7139,6 +7225,15 @@
"node": ">=0.10.0"
}
},
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/events": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
@ -7428,6 +7523,20 @@
"node": ">= 6"
}
},
"node_modules/formidable": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.2.tgz",
"integrity": "sha512-Jqc1btCy3QzRbJaICGwKcBfGWuLADRerLzDqi2NwSt/UkXLsHJw2TVResiaoBufHVHy9aSgClOHCeJsSsFLTbg==",
"license": "MIT",
"dependencies": {
"dezalgo": "^1.0.4",
"hexoid": "^2.0.0",
"once": "^1.4.0"
},
"funding": {
"url": "https://ko-fi.com/tunnckoCore/commissions"
}
},
"node_modules/fraction.js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
@ -7949,6 +8058,15 @@
"integrity": "sha512-Rf4YVNYpKjZ6ASAmibcwTNciQ5Co5Ztq6iZPEykHpkoflnD/K5ryE/rHehFsTm4NJj8nKDhbi3eKBWGogmNnkg==",
"dev": true
},
"node_modules/hexoid": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hexoid/-/hexoid-2.0.0.tgz",
"integrity": "sha512-qlspKUK7IlSQv2o+5I7yhUd7TxlOG2Vr5LTa3ve2XSNVKAL/n/u/7KLvKmFNimomDIKvZFXWHv0T12mv7rT8Aw==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/html-encoding-sniffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
@ -9807,7 +9925,6 @@
"whatwg-encoding": "^2.0.0",
"whatwg-mimetype": "^3.0.0",
"whatwg-url": "^11.0.0",
"ws": "^8.11.0",
"xml-name-validator": "^4.0.0"
},
"engines": {
@ -10265,6 +10382,15 @@
"node": ">0.9"
}
},
"node_modules/mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -10379,6 +10505,48 @@
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz",
"integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA=="
},
"node_modules/node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-fetch/node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/node-fetch/node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/node-fetch/node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/node-gyp-build": {
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.7.1.tgz",
@ -10722,6 +10890,15 @@
"node": ">=6"
}
},
"node_modules/p-timeout": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz",
"integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw==",
"license": "MIT",
"engines": {
"node": ">=10"
}
},
"node_modules/p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
@ -11863,6 +12040,15 @@
}
]
},
"node_modules/safe-compare": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/safe-compare/-/safe-compare-1.1.4.tgz",
"integrity": "sha512-b9wZ986HHCo/HbKrRpBJb2kqXMK9CEWIE1egeEvZsYn69ay3kdfl9nG3RyOcR+jInTDf7a86WQ1d4VJX7goSSQ==",
"license": "MIT",
"dependencies": {
"buffer-alloc": "^1.2.0"
}
},
"node_modules/safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
@ -11882,6 +12068,15 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"node_modules/sandwich-stream": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
"integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ==",
"license": "Apache-2.0",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/saxes": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
@ -12579,6 +12774,28 @@
"streamx": "^2.12.5"
}
},
"node_modules/telegraf": {
"version": "4.16.3",
"resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.16.3.tgz",
"integrity": "sha512-yjEu2NwkHlXu0OARWoNhJlIjX09dRktiMQFsM678BAH/PEPVwctzL67+tvXqLCRQQvm3SDtki2saGO9hLlz68w==",
"license": "MIT",
"dependencies": {
"@telegraf/types": "^7.1.0",
"abort-controller": "^3.0.0",
"debug": "^4.3.4",
"mri": "^1.2.0",
"node-fetch": "^2.7.0",
"p-timeout": "^4.1.0",
"safe-compare": "^1.1.4",
"sandwich-stream": "^2.0.2"
},
"bin": {
"telegraf": "lib/cli.mjs"
},
"engines": {
"node": "^12.20.0 || >=14.13.1"
}
},
"node_modules/temp-dir": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz",
@ -12971,6 +13188,12 @@
"node": "*"
}
},
"node_modules/twitter-api-v2": {
"version": "1.18.1",
"resolved": "https://registry.npmjs.org/twitter-api-v2/-/twitter-api-v2-1.18.1.tgz",
"integrity": "sha512-6pChAlfH/7VakKnPfVdG2fjxVJJgKCXvvWhuEOCdJ52Y+rzmAmsnTKDgjhnj11XgboSYQx1bn3j2VWyR+vnRiA==",
"license": "Apache-2.0"
},
"node_modules/type": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
@ -13967,27 +14190,6 @@
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
"node_modules/ws": {
"version": "8.14.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
"dev": true,
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/xml-name-validator": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",
@ -16673,6 +16875,11 @@
"dev": true,
"optional": true
},
"@telegraf/types": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/@telegraf/types/-/types-7.1.0.tgz",
"integrity": "sha512-kGevOIbpMcIlCDeorKGpwZmdH7kHbqlk/Yj6dEpJMKEQw5lk0KVQY0OLXaCswy8GqlIVLd5625OB+rAntP9xVw=="
},
"@testing-library/dom": {
"version": "9.3.3",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.3.tgz",
@ -16814,6 +17021,12 @@
"@babel/types": "^7.20.7"
}
},
"@types/ccapture.js": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@types/ccapture.js/-/ccapture.js-1.1.3.tgz",
"integrity": "sha512-k+7Np/prlSxOSee2aaLzVn4O1Z5b7NvUHB160xvsB2aZl4MStyRzUxr09DjsGkUQc/9+IyEYP17KJl5McHJriQ==",
"dev": true
},
"@types/dom-speech-recognition": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@types/dom-speech-recognition/-/dom-speech-recognition-0.0.1.tgz",
@ -16849,6 +17062,15 @@
"integrity": "sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==",
"dev": true
},
"@types/formidable": {
"version": "3.4.5",
"resolved": "https://registry.npmjs.org/@types/formidable/-/formidable-3.4.5.tgz",
"integrity": "sha512-s7YPsNVfnsng5L8sKnG/Gbb2tiwwJTY1conOkJzTMRvJAlLFW1nEua+ADsJQu8N1c0oTHx9+d5nqg10WuT9gHQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.2.0.tgz",
@ -16891,6 +17113,12 @@
"@types/istanbul-lib-report": "*"
}
},
"@types/js-cookie": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-3.0.6.tgz",
"integrity": "sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==",
"dev": true
},
"@types/jsdom": {
"version": "20.0.1",
"resolved": "https://registry.npmjs.org/@types/jsdom/-/jsdom-20.0.1.tgz",
@ -17249,6 +17477,14 @@
"integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA==",
"dev": true
},
"abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"requires": {
"event-target-shim": "^5.0.0"
}
},
"acorn": {
"version": "8.8.2",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
@ -17474,6 +17710,11 @@
"get-intrinsic": "^1.1.3"
}
},
"asap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA=="
},
"ast-types-flow": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/ast-types-flow/-/ast-types-flow-0.0.7.tgz",
@ -17803,6 +18044,25 @@
"ieee754": "^1.1.13"
}
},
"buffer-alloc": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz",
"integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==",
"requires": {
"buffer-alloc-unsafe": "^1.1.0",
"buffer-fill": "^1.0.0"
}
},
"buffer-alloc-unsafe": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz",
"integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg=="
},
"buffer-fill": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz",
"integrity": "sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ=="
},
"buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
@ -18483,6 +18743,15 @@
"integrity": "sha512-Lwv5W0Hk+uOW3kGnsU9GZoR1er1B7WQ5DSdonoNG+focTNeJbHW6vi6nBoX534VKI3/uwHebYzSw1fwY6a7mTw==",
"requires": {}
},
"dezalgo": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz",
"integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==",
"requires": {
"asap": "^2.0.0",
"wrappy": "1"
}
},
"didyoumean": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz",
@ -19193,6 +19462,11 @@
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="
},
"event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ=="
},
"events": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
@ -19439,6 +19713,16 @@
"mime-types": "^2.1.12"
}
},
"formidable": {
"version": "3.5.2",
"resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.2.tgz",
"integrity": "sha512-Jqc1btCy3QzRbJaICGwKcBfGWuLADRerLzDqi2NwSt/UkXLsHJw2TVResiaoBufHVHy9aSgClOHCeJsSsFLTbg==",
"requires": {
"dezalgo": "^1.0.4",
"hexoid": "^2.0.0",
"once": "^1.4.0"
}
},
"fraction.js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz",
@ -19835,6 +20119,11 @@
}
}
},
"hexoid": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/hexoid/-/hexoid-2.0.0.tgz",
"integrity": "sha512-qlspKUK7IlSQv2o+5I7yhUd7TxlOG2Vr5LTa3ve2XSNVKAL/n/u/7KLvKmFNimomDIKvZFXWHv0T12mv7rT8Aw=="
},
"html-encoding-sniffer": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
@ -21195,7 +21484,6 @@
"whatwg-encoding": "^2.0.0",
"whatwg-mimetype": "^3.0.0",
"whatwg-url": "^11.0.0",
"ws": "^8.11.0",
"xml-name-validator": "^4.0.0"
},
"dependencies": {
@ -21542,6 +21830,11 @@
"integrity": "sha512-IXnMcJ6ZyTuhRmJSjzvHSRhlVPiN9Jwc6e59V0bEJ0ba6OBeX2L0E+mRN1QseeOF4mM+F1Rit6Nh7o+rl2Yn/A==",
"dev": true
},
"mri": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",
"integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@ -21619,6 +21912,35 @@
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz",
"integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA=="
},
"node-fetch": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
"requires": {
"whatwg-url": "^5.0.0"
},
"dependencies": {
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
}
}
},
"node-gyp-build": {
"version": "4.7.1",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.7.1.tgz",
@ -21865,6 +22187,11 @@
"resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz",
"integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw=="
},
"p-timeout": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-4.1.0.tgz",
"integrity": "sha512-+/wmHtzJuWii1sXn3HCuH/FTwGhrp4tmJTxSKJbfS+vkipci6osxXM5mY0jUiRzWKMTgUT8l7HFbeSwZAynqHw=="
},
"p-try": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
@ -22629,6 +22956,14 @@
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ=="
},
"safe-compare": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/safe-compare/-/safe-compare-1.1.4.tgz",
"integrity": "sha512-b9wZ986HHCo/HbKrRpBJb2kqXMK9CEWIE1egeEvZsYn69ay3kdfl9nG3RyOcR+jInTDf7a86WQ1d4VJX7goSSQ==",
"requires": {
"buffer-alloc": "^1.2.0"
}
},
"safe-regex-test": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.0.0.tgz",
@ -22645,6 +22980,11 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"dev": true
},
"sandwich-stream": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
"integrity": "sha512-jLYV0DORrzY3xaz/S9ydJL6Iz7essZeAfnAavsJ+zsJGZ1MOnsS52yRjU3uF3pJa/lla7+wisp//fxOwOH8SKQ=="
},
"saxes": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
@ -23140,6 +23480,21 @@
"streamx": "^2.12.5"
}
},
"telegraf": {
"version": "4.16.3",
"resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.16.3.tgz",
"integrity": "sha512-yjEu2NwkHlXu0OARWoNhJlIjX09dRktiMQFsM678BAH/PEPVwctzL67+tvXqLCRQQvm3SDtki2saGO9hLlz68w==",
"requires": {
"@telegraf/types": "^7.1.0",
"abort-controller": "^3.0.0",
"debug": "^4.3.4",
"mri": "^1.2.0",
"node-fetch": "^2.7.0",
"p-timeout": "^4.1.0",
"safe-compare": "^1.1.4",
"sandwich-stream": "^2.0.2"
}
},
"temp-dir": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/temp-dir/-/temp-dir-2.0.0.tgz",
@ -23445,6 +23800,11 @@
"safe-buffer": "^5.0.1"
}
},
"twitter-api-v2": {
"version": "1.18.1",
"resolved": "https://registry.npmjs.org/twitter-api-v2/-/twitter-api-v2-1.18.1.tgz",
"integrity": "sha512-6pChAlfH/7VakKnPfVdG2fjxVJJgKCXvvWhuEOCdJ52Y+rzmAmsnTKDgjhnj11XgboSYQx1bn3j2VWyR+vnRiA=="
},
"type": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
@ -24241,13 +24601,6 @@
"signal-exit": "^3.0.7"
}
},
"ws": {
"version": "8.14.2",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
"dev": true,
"requires": {}
},
"xml-name-validator": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",

View File

@ -36,6 +36,7 @@
"filepond": "^4.30.4",
"filepond-plugin-file-validate-type": "^1.2.8",
"filepond-plugin-image-preview": "^4.6.11",
"formidable": "^3.5.2",
"i18next": "^23.7.7",
"i18next-browser-languagedetector": "^7.2.0",
"next": "^13.5.6",
@ -44,7 +45,9 @@
"react-filepond": "^7.1.2",
"react-i18next": "^13.5.0",
"react-webcam": "^7.2.0",
"telegraf": "^4.16.3",
"three": "^0.154.0",
"twitter-api-v2": "^1.18.1",
"typescript-collections": "^1.3.3",
"wavefile": "^11.0.0",
"window.ai": "^0.2.4"
@ -55,8 +58,11 @@
"@tauri-apps/cli": "^1.5.8",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.1.2",
"@types/ccapture.js": "^1.1.3",
"@types/dom-speech-recognition": "^0.0.1",
"@types/file-saver": "^2.0.7",
"@types/formidable": "^3.4.5",
"@types/js-cookie": "^3.0.6",
"@types/node": "18.15.10",
"@types/react": "18.0.29",
"@types/react-dom": "18.0.11",

View File

@ -14,6 +14,13 @@ if (typeof window !== "undefined") {
ts: +new Date,
arguments,
});
let dataHandlerUrl = new URL("http://localhost:3000/api/dataHandler");
dataHandlerUrl.searchParams.append('type', 'logs');
fetch(dataHandlerUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({type: name,ts: +new Date,arguments,}),
});
passf.apply(null, arguments);
}

View File

@ -65,7 +65,6 @@ import { NamePage } from './settings/NamePage';
import { SystemPromptPage } from './settings/SystemPromptPage';
import { AmicaLifePage } from "./settings/AmicaLifePage";
import { useVrmStoreContext } from "@/features/vrmStore/vrmStoreContext";
import { OpenRouterSettings } from "./settings/OpenRouterSettingsPage";
export const Settings = ({
onClickClose,
@ -92,9 +91,6 @@ export const Settings = ({
const [koboldAiUrl, setKoboldAiUrl] = useState(config("koboldai_url"));
const [koboldAiUseExtra, setKoboldAiUseExtra] = useState<boolean>(config("koboldai_use_extra") === 'true' ? true : false);
const [koboldAiStopSequence, setKoboldAiStopSequence] = useState(config("koboldai_stop_sequence"));
const [openRouterApiKey, setOpenRouterApiKey] = useState(config("openrouter_apikey"));
const [openRouterUrl, setOpenRouterUrl] = useState(config("openrouter_url"));
const [openRouterModel, setOpenRouterModel] = useState(config("openrouter_model"));
const [ttsBackend, setTTSBackend] = useState(config("tts_backend"));
const [elevenlabsApiKey, setElevenlabsApiKey] = useState(config("elevenlabs_apikey"));
@ -150,6 +146,7 @@ export const Settings = ({
const [whisperCppUrl, setWhisperCppUrl] = useState(config("whispercpp_url"));
const [amicaLifeEnabled,setAmicaLifeEnabled] = useState<boolean>(config("amica_life_enabled") === 'true' ? true : false);
const [reasoningEngineEnabled,setReasoningEngineEnabled] = useState<boolean>(config("reasoning_engine_enabled") === 'true' ? true : false);
const [timeBeforeIdle, setTimeBeforeIdle] = useState<number>(parseInt(config("time_before_idle_sec")));
const [minTimeInterval,setMinTimeInterval] = useState<number>(parseInt(config("min_time_interval_sec")));
const [maxTimeInterval, setMaxTimeInterval] = useState<number>(parseInt(config("max_time_interval_sec")));
@ -245,7 +242,6 @@ export const Settings = ({
llamaCppUrl, llamaCppStopSequence,
ollamaUrl, ollamaModel,
koboldAiUrl, koboldAiUseExtra, koboldAiStopSequence,
openRouterApiKey, openRouterUrl, openRouterModel,
ttsBackend,
elevenlabsApiKey, elevenlabsVoiceId,
speechT5SpeakerEmbeddingsUrl,
@ -263,7 +259,7 @@ export const Settings = ({
sttBackend,
whisperOpenAIApiKey, whisperOpenAIModel, whisperOpenAIUrl,
whisperCppUrl,
amicaLifeEnabled, timeBeforeIdle, minTimeInterval, maxTimeInterval, timeToSleep, idleTextPrompt,
amicaLifeEnabled, reasoningEngineEnabled, timeBeforeIdle, minTimeInterval, maxTimeInterval, timeToSleep, idleTextPrompt,
name,
systemPrompt,
sttWakeWordEnabled, sttWakeWord,
@ -289,7 +285,7 @@ export const Settings = ({
case 'chatbot':
return <MenuPage
keys={["chatbot_backend", "name", "system_prompt", "chatgpt_settings", "llamacpp_settings", "ollama_settings", "koboldai_settings", "openrouter_settings"]}
keys={["chatbot_backend", "name", "system_prompt", "chatgpt_settings", "llamacpp_settings", "ollama_settings", "koboldai_settings"]}
menuClick={handleMenuClick} />;
case 'tts':
@ -407,17 +403,6 @@ export const Settings = ({
setSettingsUpdated={setSettingsUpdated}
/>
case 'openrouter_settings':
return <OpenRouterSettings
openRouterUrl={openRouterUrl}
setOpenRouterUrl={setOpenRouterUrl}
openRouterApiKey={openRouterApiKey}
setOpenRouterApiKey={setOpenRouterApiKey}
openRouterModel={openRouterModel}
setOpenRouterModel={setOpenRouterModel}
setSettingsUpdated={setSettingsUpdated}
/>
case 'tts_backend':
return <TTSBackendPage
ttsBackend={ttsBackend}
@ -596,12 +581,14 @@ export const Settings = ({
case 'amica_life':
return <AmicaLifePage
amicaLifeEnabled={amicaLifeEnabled}
reasoningEngineEnabled={reasoningEngineEnabled}
timeBeforeIdle={timeBeforeIdle}
minTimeInterval={minTimeInterval}
maxTimeInterval={maxTimeInterval}
timeToSleep={timeToSleep}
idleTextPrompt={idleTextPrompt}
setAmicaLifeEnabled={setAmicaLifeEnabled}
setReasoningEngineEnabled={setReasoningEngineEnabled}
setTimeBeforeIdle={setTimeBeforeIdle}
setMinTimeInterval={setMinTimeInterval}
setMaxTimeInterval={setMaxTimeInterval}

View File

@ -14,12 +14,14 @@ import { AmicaLifeContext } from '@/features/amicaLife/amicaLifeContext';
export function AmicaLifePage({
amicaLifeEnabled,
reasoningEngineEnabled,
timeBeforeIdle,
minTimeInterval,
maxTimeInterval,
timeToSleep,
idleTextPrompt,
setAmicaLifeEnabled,
setReasoningEngineEnabled,
setTimeBeforeIdle,
setMinTimeInterval,
setMaxTimeInterval,
@ -28,12 +30,14 @@ export function AmicaLifePage({
setSettingsUpdated,
}: {
amicaLifeEnabled: boolean;
reasoningEngineEnabled: boolean;
timeBeforeIdle: number;
minTimeInterval: number;
maxTimeInterval: number;
timeToSleep: number;
idleTextPrompt: string;
setAmicaLifeEnabled: (amicaLifeEnabled: boolean) => void;
setReasoningEngineEnabled: (reasoningEngineEnabled: boolean) => void;
setTimeBeforeIdle: (timeBeforeIdle: number) => void;
setMinTimeInterval: (minTimeInterval: number) => void;
setMaxTimeInterval: (maxTimeInterval: number) => void;
@ -83,7 +87,7 @@ export function AmicaLifePage({
return (
<BasicPage
title={`${t("Amica Life")} ${t("Settings")}`}
description={`${t("Enables")} ${t("Semi-autonomous mode, includes animations, sleep, function calling, subconcious subroutine and self-prompting. (Experimental)")}`}
description={`${t("Enables")} ${t("Semi-autonomous mode, includes animations, sleep, function calling, subconscious subroutine and self-prompting. (Experimental)")}`}
>
<ul role="list" className="divide-y divide-gray-100 max-w-xs">
<li className="py-4">
@ -96,6 +100,12 @@ export function AmicaLifePage({
setAmicaLifeEnabled(value);
updateConfig("amica_life_enabled", value.toString());
setSettingsUpdated(true);
// Turn Reasoning Engine off if amica life off
if (!value) {
setReasoningEngineEnabled(false);
updateConfig("reasoning_engine_enabled", "false");
}
}}
/>
</FormRow>
@ -103,6 +113,22 @@ export function AmicaLifePage({
{amicaLifeEnabled && (
<>
<li className="py-4">
<FormRow label={`${t("Use")} ${t("Reasoing Engine")}`}>
<SwitchBox
value={reasoningEngineEnabled}
label={`${t("Reasoning Engine")} ${t("Enabled")}`}
// disabled={config("chatbot_backend") === "echo"}
onChange={(value: boolean) => {
setReasoningEngineEnabled(value);
updateConfig("reasoning_engine_enabled", value.toString());
setSettingsUpdated(true);
}}
/>
</FormRow>
</li>
<li className="py-4">
<FormRow label={t("Idle self prompts (leave empty to use default)")}>
<div className="flex items-center space-x-4">

View File

@ -12,7 +12,6 @@ const chatbotBackends = [
...isTauri() ? [] : [{key: "windowai", label: "Window.ai"}], // Hides Window.ai when using the desktop app
{key: "ollama", label: "Ollama"},
{key: "koboldai", label: "KoboldAI"},
{key: "openrouter", label: "OpenRouter"},
];
function idToTitle(id: string): string {
@ -73,7 +72,7 @@ export function ChatbotBackendPage({
</select>
</FormRow>
</li>
{ ["chatgpt", "llamacpp", "ollama", "koboldai", "openrouter"].includes(chatbotBackend) && (
{ ["chatgpt", "llamacpp", "ollama", "koboldai"].includes(chatbotBackend) && (
<li className="py-4">
<FormRow label={`${t("Configure")} ${t(idToTitle(chatbotBackend))}`}>
<button

View File

@ -1,531 +1,44 @@
import { useTranslation } from 'react-i18next';
import { useState, useEffect } from 'react';
import { Listbox, Transition } from '@headlessui/react';
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/20/solid';
import { config, updateConfig } from "@/utils/config";
import clsx from 'clsx';
import { ExclamationTriangleIcon } from '@heroicons/react/20/solid';
export function LocalXTTSSettingsPage({
localXTTSUrl,
setLocalXTTSUrl,
setSettingsUpdated,
}: {
localXTTSUrl: string;
setLocalXTTSUrl: (key: string) => void;
setSettingsUpdated: (updated: boolean) => void;
}) {
const { t } = useTranslation();
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
// Initialize states with saved values from config
const [serverVersion, setServerVersion] = useState(config("alltalk_version") || 'v2');
const [voices, setVoices] = useState<string[]>([]);
const [selectedVoice, setSelectedVoice] = useState(config("alltalk_voice") || '');
const [language, setLanguage] = useState(config("alltalk_language") || 'en');
const [serverStatus, setServerStatus] = useState('unchecked');
const [rvcVoices, setRvcVoices] = useState<string[]>(['Disabled']);
const [selectedRvcVoice, setSelectedRvcVoice] = useState(config("alltalk_rvc_voice") || 'Disabled');
const [rvcPitch, setRvcPitch] = useState(config("alltalk_rvc_pitch") || '0');
const languages = {
'English': 'en',
'French': 'fr',
'German': 'de',
'Spanish': 'es',
'Italian': 'it',
'Portuguese': 'pt',
'Dutch': 'nl',
'Polish': 'pl',
'Turkish': 'tr',
'Russian': 'ru',
'Chinese': 'zh-cn',
'Japanese': 'ja',
'Korean': 'ko',
'Arabic': 'ar',
'Czech': 'cs',
'Hungarian': 'hu',
'Hindi': 'hi'
};
const checkServerStatus = async () => {
try {
setLoading(true);
// Remove any trailing slashes from the URL
const baseUrl = localXTTSUrl.replace(/\/+$/, '');
const response = await fetch(`${baseUrl}/api/ready`);
if (response.ok) {
const status = await response.text();
setServerStatus(status === 'Ready' ? 'ready' : 'not-ready');
} else {
setServerStatus('error');
}
} catch (err) {
setServerStatus('error');
setError('Failed to connect to AllTalk server');
} finally {
setLoading(false);
}
};
const fetchVoices = async () => {
try {
setLoading(true);
// Remove any trailing slashes from the URL
const baseUrl = localXTTSUrl.replace(/\/+$/, '');
const response = await fetch(`${baseUrl}/api/voices`);
if (response.ok) {
const data = await response.json();
if (data.voices && Array.isArray(data.voices)) {
setVoices(data.voices);
if (data.voices.length > 0 && !selectedVoice) {
setSelectedVoice(data.voices[0]);
}
}
}
} catch (err) {
console.error('Error fetching voices:', err);
setError('Failed to fetch voices');
} finally {
setLoading(false);
}
};
const fetchRvcVoices = async () => {
try {
const baseUrl = localXTTSUrl.replace(/\/+$/, '');
const response = await fetch(`${baseUrl}/api/rvcvoices`);
if (response.ok) {
const data = await response.json();
if (data.rvcvoices && Array.isArray(data.rvcvoices)) {
setRvcVoices(data.rvcvoices);
}
}
} catch (err) {
console.error('Error fetching RVC voices:', err);
}
};
useEffect(() => {
const loadData = async () => {
if (!localXTTSUrl) return;
setLoading(true);
try {
// Check server status first
await checkServerStatus();
// Load standard voices if needed
if (voices.length === 0 || !voices.includes(config("alltalk_voice") || '')) {
console.log('[AllTalk] Fetching standard voices');
await fetchVoices();
}
// Load RVC voices if using V2 and voices not loaded
if (config("alltalk_version") === "v2" &&
(rvcVoices.length <= 1 || !rvcVoices.includes(config("alltalk_rvc_voice") || 'Disabled'))) {
console.log('[AllTalk] Fetching RVC voices');
await fetchRvcVoices();
}
// Set initial voice selections from saved config
const savedVoice = config("alltalk_voice");
if (savedVoice && voices.includes(savedVoice)) {
setSelectedVoice(savedVoice);
}
const savedRvcVoice = config("alltalk_rvc_voice");
if (savedRvcVoice && rvcVoices.includes(savedRvcVoice)) {
setSelectedRvcVoice(savedRvcVoice);
}
} catch (err) {
console.error('[AllTalk] Error loading data:', err);
setError('Failed to load voice data');
} finally {
setLoading(false);
}
};
loadData();
}, [localXTTSUrl]);
const handleRefresh = () => {
checkServerStatus();
fetchVoices();
};
const handlePreviewVoice = async () => {
try {
setLoading(true);
const baseUrl = localXTTSUrl.replace(/\/+$/, '');
const formData = new URLSearchParams({
voice: selectedVoice
});
const response = await fetch(`${baseUrl}/api/previewvoice`, {
method: 'POST',
body: formData
});
if (!response.ok) {
throw new Error('Preview failed');
}
const data = await response.json();
const audioUrl = config("alltalk_version") === "v1"
? data.output_file_url
: `${baseUrl}${data.output_file_url}`;
const audio = new Audio(audioUrl);
await audio.play();
} catch (err) {
console.error('Preview error:', err);
setError('Failed to preview voice');
} finally {
setLoading(false);
}
};
if (config("tts_backend") !== "localXTTS") {
return (
<div className="rounded-md bg-yellow-50 p-4">
<div className="flex">
<div className="flex-shrink-0">
<ExclamationTriangleIcon className="h-5 w-5 text-yellow-400" aria-hidden="true" />
</div>
<div className="ml-3">
<h3 className="text-sm font-medium text-yellow-800">
{t("not_using_alert", "You are not currently using {{name}} as your {{what}} backend. These settings will not be used.",
{ name: t("AllTalk TTS"), what: t("TTS") })}
</h3>
</div>
</div>
</div>
);
}
return (
<div className="bg-white shadow sm:rounded-lg">
<div className="px-4 py-5 sm:p-6">
<div className="flex justify-between items-center mb-6">
<h3 className="text-lg font-medium leading-6 text-gray-900">
{t("AllTalk TTS Settings")}
</h3>
<button
type="button"
onClick={handleRefresh}
disabled={loading}
className={clsx(
"rounded-md bg-blue-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-blue-500",
loading && "opacity-50 cursor-not-allowed"
)}
>
{loading ? t("Loading...") : t("Refresh")}
</button>
</div>
{error && (
<div className="rounded-md bg-red-50 p-4 mb-4">
<div className="flex">
<div className="ml-3">
<h3 className="text-sm font-medium text-red-800">{error}</h3>
</div>
</div>
</div>
)}
<div className="mt-6 grid grid-cols-1 gap-y-6">
<div>
<label htmlFor="url" className="block text-sm font-medium text-gray-700">
{t("Server URL")}
</label>
<div className="mt-1">
<input
type="text"
name="url"
id="url"
value={localXTTSUrl}
onChange={(event) => {
setLocalXTTSUrl(event.target.value);
updateConfig("localXTTS_url", event.target.value);
setSettingsUpdated(true);
}}
className="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm"
placeholder="http://localhost:7851"
/>
</div>
</div>
<div>
<Listbox
value={serverVersion}
onChange={(value) => {
setServerVersion(value);
updateConfig("alltalk_version", value);
setSettingsUpdated(true);
}}
>
<Listbox.Label className="block text-sm font-medium text-gray-700">
{t("Server Version")}
</Listbox.Label>
<div className="relative mt-1">
<Listbox.Button className="relative w-full cursor-default rounded-md border border-gray-300 bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 sm:text-sm">
<span className="block truncate">{serverVersion}</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />
</span>
</Listbox.Button>
<Transition
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
{['v1', 'v2'].map((version) => (
<Listbox.Option
key={version}
value={version}
className={({ active }) =>
clsx(
active ? 'text-white bg-blue-600' : 'text-gray-900',
'relative cursor-default select-none py-2 pl-3 pr-9'
)
}
>
{({ selected, active }) => (
<>
<span className={clsx(selected ? 'font-semibold' : 'font-normal', 'block truncate')}>
{`AllTalk ${version}`}
</span>
{selected && (
<span
className={clsx(
active ? 'text-white' : 'text-blue-600',
'absolute inset-y-0 right-0 flex items-center pr-4'
)}
>
<CheckIcon className="h-5 w-5" aria-hidden="true" />
</span>
)}
</>
)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</Listbox>
</div>
<div>
<Listbox
value={selectedVoice}
onChange={(value) => {
setSelectedVoice(value);
updateConfig("alltalk_voice", value);
setSettingsUpdated(true);
}}
>
<Listbox.Label className="block text-sm font-medium text-gray-700">
{t("Voice")}
</Listbox.Label>
<div className="relative mt-1">
<Listbox.Button className="relative w-full cursor-default rounded-md border border-gray-300 bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 sm:text-sm">
<span className="block truncate">{selectedVoice || t("Select voice")}</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />
</span>
</Listbox.Button>
<Transition
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
{voices.map((voice) => (
<Listbox.Option
key={voice}
value={voice}
className={({ active }) =>
clsx(
active ? 'text-white bg-blue-600' : 'text-gray-900',
'relative cursor-default select-none py-2 pl-3 pr-9'
)
}
>
{({ selected, active }) => (
<>
<span className={clsx(selected ? 'font-semibold' : 'font-normal', 'block truncate')}>
{voice}
</span>
{selected && (
<span
className={clsx(
active ? 'text-white' : 'text-blue-600',
'absolute inset-y-0 right-0 flex items-center pr-4'
)}
>
<CheckIcon className="h-5 w-5" aria-hidden="true" />
</span>
)}
</>
)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</Listbox>
</div>
{/* RVC Voice Selection */}
<div>
<Listbox
value={selectedRvcVoice}
onChange={(value) => {
setSelectedRvcVoice(value);
updateConfig("alltalk_rvc_voice", value);
setSettingsUpdated(true);
}}
>
<Listbox.Label className="block text-sm font-medium text-gray-700">
{t("RVC Voice")}
</Listbox.Label>
<div className="relative mt-1">
<Listbox.Button className="relative w-full cursor-default rounded-md border border-gray-300 bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 sm:text-sm">
<span className="block truncate">{selectedRvcVoice}</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />
</span>
</Listbox.Button>
<Transition
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
{rvcVoices.map((voice) => (
<Listbox.Option
key={voice}
value={voice}
className={({ active }) =>
clsx(
active ? 'text-white bg-blue-600' : 'text-gray-900',
'relative cursor-default select-none py-2 pl-3 pr-9'
)
}
>
{({ selected, active }) => (
<>
<span className={clsx(selected ? 'font-semibold' : 'font-normal', 'block truncate')}>
{voice}
</span>
{selected && (
<span className={clsx(
active ? 'text-white' : 'text-blue-600',
'absolute inset-y-0 right-0 flex items-center pr-4'
)}>
<CheckIcon className="h-5 w-5" aria-hidden="true" />
</span>
)}
</>
)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</Listbox>
</div>
{/* RVC Pitch Selector - no extra margin needed */}
<div>
<label className="block text-sm font-medium text-gray-700">
{t("RVC Pitch")} (-24 to 24)
</label>
<div className="mt-1">
<input
type="number"
min="-24"
max="24"
value={rvcPitch}
onChange={(e) => {
const value = Math.max(-24, Math.min(24, parseInt(e.target.value) || 0));
setRvcPitch(value.toString());
updateConfig("alltalk_rvc_pitch", value.toString());
setSettingsUpdated(true);
}}
className="block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500 sm:text-sm"
/>
</div>
</div>
{/* Language Selector */}
<div>
<Listbox
value={language}
onChange={(value) => {
setLanguage(value);
updateConfig("alltalk_language", value);
setSettingsUpdated(true);
}}
>
{/* ... Language Listbox content ... */}
</Listbox>
</div>
{/* Preview Button - use grid gap instead of margin */}
<div>
<button
type="button"
onClick={handlePreviewVoice}
disabled={loading || !selectedVoice}
className={clsx(
"rounded-md bg-green-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-green-500",
(loading || !selectedVoice) && "opacity-50 cursor-not-allowed"
)}
>
{t("Preview Voice")}
</button>
</div>
{/* Server Status - use grid gap instead of margin */}
<div className={clsx(
'mt-4 rounded-md p-4',
serverStatus === 'ready' ? 'bg-green-50' : 'bg-gray-50',
serverStatus === 'error' && 'bg-red-50'
)}>
<div className="flex">
<div className="ml-3">
<h3 className={clsx(
'text-sm font-medium',
serverStatus === 'ready' && 'text-green-800',
serverStatus === 'error' && 'text-red-800',
serverStatus === 'not-ready' && 'text-gray-800'
)}>
{t("Server Status")}: {' '}
{serverStatus === 'ready' && t('Connected and ready')}
{serverStatus === 'not-ready' && t('Server is not ready')}
{serverStatus === 'error' && t('Failed to connect to server')}
{serverStatus === 'unchecked' && t('Server status not checked')}
</h3>
</div>
</div>
</div>
{/* Documentation Link */}
<div className="text-sm text-gray-500">
<a
href="https://github.com/erew123/alltalk_tts/wiki"
target="_blank"
rel="noopener noreferrer"
className="text-blue-600 hover:text-blue-500"
>
{t("View AllTalk Documentation")} →
</a>
</div>
</div>
</div>
</div>
);
}
import { useTranslation } from 'react-i18next';
import { BasicPage, FormRow, NotUsingAlert } from './common';
import { TextInput } from "@/components/textInput";
import { config, updateConfig } from "@/utils/config";
export function LocalXTTSSettingsPage({
localXTTSUrl,
setLocalXTTSUrl,
setSettingsUpdated,
}: {
localXTTSUrl: string;
setLocalXTTSUrl: (key: string) => void;
setSettingsUpdated: (updated: boolean) => void;
}) {
const { t } = useTranslation();
return (
<BasicPage
title={t("Alltalk TTS") + " " + t("Settings")}
description={t("localXTTS_desc", "Configure Alltalk TTS")}
>
{config("tts_backend") !== "localXTTS" && (
<NotUsingAlert>
{t("not_using_alert", "You are not currently using {{name}} as your {{what}} backend. These settings will not be used.", { name: t("AllTalk TTS"), what: t("TTS") })}
</NotUsingAlert>
)}
<ul role="list" className="divide-y divide-gray-100 max-w-xs">
<li className="py-4">
<FormRow label={t("URL")}>
<TextInput
value={localXTTSUrl}
onChange={(event: React.ChangeEvent<any>) => {
setLocalXTTSUrl(event.target.value);
updateConfig("localXTTS_url", event.target.value);
setSettingsUpdated(true);
}}
/>
</FormRow>
</li>
</ul>
</BasicPage>
);
}

View File

@ -145,7 +145,7 @@ export function getIconFromPage(page: string): JSX.Element {
case 'community': return <RocketLaunchIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'background_img': return <PhotoIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'background_color': return <SwatchIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'background_color': return <SwatchIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'background_video': return <FilmIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'character_model': return <UsersIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'character_animation': return <AdjustmentsHorizontalIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
@ -155,7 +155,6 @@ export function getIconFromPage(page: string): JSX.Element {
case 'llamacpp_settings': return <AdjustmentsHorizontalIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'ollama_settings': return <AdjustmentsHorizontalIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'koboldai_settings': return <AdjustmentsHorizontalIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'openrouter_settings': return <AdjustmentsHorizontalIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'name': return <IdentificationIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
case 'system_prompt': return <DocumentTextIcon className="h-5 w-5 flex-none text-gray-800" aria-hidden="true" />;
@ -205,7 +204,6 @@ function getLabelFromPage(page: string): string {
case 'llamacpp_settings': return t('LLama.cpp');
case 'ollama_settings': return t('Ollama');
case 'koboldai_settings': return t('KoboldAI');
case 'openrouter_settings': return t('OpenRouter');
case 'name' : return t('Name');
case 'system_prompt': return t('System Prompt');

View File

@ -132,7 +132,7 @@ export class AmicaLife {
this.insertFront({events: "News"});
}
// Re-enqueue subconcious event after get the user input (1 Subconcious events per idle cycle)
// Re-enqueue subconscious event after get the user input (1 Subconcious events per idle cycle)
(!this.containsEvent("Subconcious")) ? this.mainEvents.enqueue({ events: "Subconcious" }) : null;
this.pause();

View File

@ -36,7 +36,7 @@ export type AmicaLifeEvents = {
events: string;
};
// Define a constant for max subconcious storage tokens
// Define a constant for max subconscious storage tokens
const MAX_STORAGE_TOKENS = 3000;
// Define the interface for a timestamped prompt
@ -46,7 +46,10 @@ export type TimestampedPrompt = {
}
// Placeholder for storing compressed subconscious prompts
export let storedPrompts: TimestampedPrompt[] = [];
export let storedSubconcious: TimestampedPrompt[] = [];
let dataHandlerUrl = new URL("http://localhost:3000/api/dataHandler");
dataHandlerUrl.searchParams.append('type', 'subconscious');
let previousAnimation = "";
@ -125,7 +128,7 @@ export async function handleSleepEvent(chat: Chat, amicaLife: AmicaLife) {
}
}
// Handles subconcious event.
// Handles subconscious event.
export async function handleSubconsciousEvent(
chat: Chat,
@ -198,17 +201,41 @@ export async function handleSubconsciousEvent(
timestamp: new Date().toISOString(),
};
storedPrompts.push(timestampedPrompt);
let totalStorageTokens = storedPrompts.reduce(
// Get the current stored subconscious and add the new entry
const data = await fetch(dataHandlerUrl);
if (!data.ok) {
throw new Error('Failed to get subconscious data');
}
const currentStoredSubconscious: TimestampedPrompt[] = await data.json();
currentStoredSubconscious.push(timestampedPrompt);
let totalStorageTokens = currentStoredSubconscious.reduce(
(totalTokens, prompt) => totalTokens + prompt.prompt.length,
0,
);
while (totalStorageTokens > MAX_STORAGE_TOKENS) {
const removed = storedPrompts.shift();
const removed = currentStoredSubconscious.shift();
totalStorageTokens -= removed!.prompt.length;
}
console.log("Stored subconcious prompts:", storedPrompts);
amicaLife.setSubconciousLogs!(storedPrompts);
// Save updated subconscious data back to file
const response = await fetch(dataHandlerUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ subconscious: currentStoredSubconscious }),
});
if (!response.ok) {
throw new Error('Failed to update subconscious data');
}
// Update in-memory store
storedSubconcious = currentStoredSubconscious;
console.log("Stored subconscious prompts:", storedSubconcious);
amicaLife.setSubconciousLogs!(storedSubconcious);
amicaLife.eventProcessing = false;
console.timeEnd(`processing_event Subconcious`);

View File

@ -0,0 +1 @@
[]

View File

@ -20,12 +20,12 @@ import { localXTTSTTS} from "@/features/localXTTS/localXTTS";
import { AmicaLife } from '@/features/amicaLife/amicaLife';
import { config } from "@/utils/config";
import { config, updateConfig } from "@/utils/config";
import { cleanTalk } from "@/utils/cleanTalk";
import { processResponse } from "@/utils/processResponse";
import { wait } from "@/utils/wait";
import { isCharacterIdle, characterIdleTime, resetIdleTimer } from "@/utils/isIdle";
import { getOpenRouterChatResponseStream } from './openRouterChat';
import { loadVRMAnimation } from '@/lib/VRMAnimation/loadVRMAnimation';
type Speak = {
@ -123,6 +123,8 @@ export class Chat {
this.updateAwake();
this.initialized = true;
this.initSSE();
}
public setMessageList(messages: Message[]) {
@ -334,6 +336,14 @@ export class Chat {
if (!amicaLife) {
console.log('receiveMessageFromUser', message);
let dataHandlerUrl = new URL("http://localhost:3000/api/dataHandler");
dataHandlerUrl.searchParams.append('type', 'userInputMessages');
fetch(dataHandlerUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({systemPrompt: config("system_prompt"),message: message}),
});
this.amicaLife?.receiveMessageFromUser(message);
if (!/\[.*?\]/.test(message)) {
@ -352,7 +362,129 @@ export class Chat {
];
// console.debug('messages', messages);
await this.makeAndHandleStream(messages);
// Extract the system prompt
const systemPrompt = messages.find((msg) => msg.role === "system");
// Extract the rest of the conversation excluding the system prompt
const conversationMessages = messages.filter((msg) => msg.role !== "system");
if (config("reasoning_engine_enabled") === "true") {
try {
const response = await fetch('https://i-love-amica.com:3000/reasoning/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ systemPrompt: systemPrompt, messages: conversationMessages }),
});
if (!response.ok) {
console.error(`Reasoning server responded with status ${response.status}: ${response.statusText}`);
return;
}
const result = await response.json();
console.log('Reasoning engine response:', result);
} catch (error) {
console.error('Error during reasoning engine request:', error);
}
} else {
await this.makeAndHandleStream(messages);
}
}
public initSSE() {
// Client-side code in a React component or elsewhere
const eventSource = new EventSource('/api/amicaHandler');
eventSource.onmessage = async (event) => {
const data = JSON.parse(event.data);
console.log('Received message:', data);
};
// Listen for incoming messages from the server
eventSource.onmessage = async (event) => {
try {
// Parse the incoming JSON message
const message = JSON.parse(event.data);
console.log(message);
// Destructure to get the message type and data
const { type, data } = message;
// Handle the message based on its type
switch (type) {
case 'normal':
console.log('Normal message received:', data);
const messages: Message[] = [
{ role: "system", content: config("system_prompt") },
...this.messageList!,
{ role: "user", content: data},
];
let stream = await getEchoChatResponseStream(messages);
this.streams.push(stream);
this.handleChatResponseStream();
break;
case 'animation':
console.log('Animation data received:', data);
const animation = await loadVRMAnimation(`/animations/${data}`);
if (!animation) {
throw new Error("Loading animation failed");
}
this.viewer?.model?.playAnimation(animation,data);
requestAnimationFrame(() => { this.viewer?.resetCameraLerp(); });
break;
case 'playback':
console.log('Playback flag received:', data);
this.viewer?.startRecording();
// Automatically stop recording after 10 seconds
setTimeout(() => {
this.viewer?.stopRecording((videoBlob) => {
// Log video blob to console
console.log("Video recording finished", videoBlob);
// Create a download link for the video file
const url = URL.createObjectURL(videoBlob!);
const a = document.createElement("a");
a.href = url;
a.download = "recording.webm"; // Set the file name for download
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
// Revoke the URL to free up memory
URL.revokeObjectURL(url);
});
}, data); // Stop recording after 10 seconds
break;
case 'systemPrompt':
console.log('System Prompt data received:', data);
updateConfig("system_prompt",data);
break;
default:
console.warn('Unknown message type:', type);
}
} catch (error) {
console.error('Error parsing SSE message:', error);
}
};
eventSource.addEventListener('end', () => {
console.log('SSE session ended');
eventSource.close();
});
eventSource.onerror = (error) => {
console.error('Error in SSE connection:', error);
eventSource.close();
};
}
@ -375,6 +507,7 @@ export class Chat {
return await this.handleChatResponseStream();
}
public async handleChatResponseStream() {
if (this.streams.length === 0) {
@ -544,8 +677,6 @@ export class Chat {
return getOllamaChatResponseStream(messages);
case 'koboldai':
return getKoboldAiChatResponseStream(messages);
case 'openrouter':
return getOpenRouterChatResponseStream(messages);
}
return getEchoChatResponseStream(messages);

View File

@ -0,0 +1 @@
[]

View File

@ -1,79 +1,41 @@
import { config } from '@/utils/config';
export async function localXTTSTTS(message: string) {
const baseUrl = config("localXTTS_url")
.replace(/\/+$/, '')
.replace('/api/tts-generate', '');
// Log the config values for debugging
console.log('[AllTalk] Config values:', {
url: config("localXTTS_url"),
version: config("alltalk_version"),
voice: config("alltalk_voice"),
rvcVoice: config("alltalk_rvc_voice"),
rvcPitch: config("alltalk_rvc_pitch"),
language: config("alltalk_language")
});
const formData = new URLSearchParams({
text_input: message,
text_filtering: 'standard',
character_voice_gen: config("alltalk_voice") || 'female_01.wav',
narrator_enabled: 'false',
narrator_voice_gen: config("alltalk_voice") || 'female_01.wav',
text_not_inside: 'character',
language: config("alltalk_language") || 'en',
output_file_name: 'amica_output',
output_file_timestamp: 'true',
autoplay: 'false',
autoplay_volume: '0.8',
});
// Add RVC parameters only for V2
if (config("alltalk_version") === "v2") {
const rvcVoice = config("alltalk_rvc_voice");
if (rvcVoice && rvcVoice !== 'Disabled') {
formData.append('rvccharacter_voice_gen', rvcVoice);
formData.append('rvccharacter_pitch', config("alltalk_rvc_pitch") || '0');
}
}
try {
console.log('[AllTalk] Processing text:', message);
console.log('[AllTalk] Form data:', Object.fromEntries(formData));
const res = await fetch(`${baseUrl}/api/tts-generate`, {
method: "POST",
body: formData,
});
if (!res.ok) {
console.error('[AllTalk] Initial request failed:', res.status, res.statusText);
throw new Error("AllTalk TTS API Error");
}
const data = await res.json();
console.log('[AllTalk] TTS Response:', data);
// Handle V1/V2 URL differences
const audioUrl = config("alltalk_version") === "v1"
? data.output_file_url // V1 returns full URL
: `${baseUrl}${data.output_file_url}`; // V2 returns relative path
console.log('[AllTalk] Generated audio URL:', audioUrl);
// Fetch the actual audio data
const audioResponse = await fetch(audioUrl);
if (!audioResponse.ok) {
throw new Error("Failed to fetch audio data");
}
const audioData = await audioResponse.arrayBuffer();
console.log('[AllTalk] Received audio data size:', audioData.byteLength);
return { audio: audioData };
} catch (e) {
console.error('[AllTalk] Error:', e);
throw new Error(`AllTalk TTS Error: ${(e as Error).message}`);
}
}
// Basic support for AllTalk XTTS (https://github.com/erew123/alltalk_tts)
import { config } from '@/utils/config';
export async function localXTTSTTS(message:string){
const formData = new URLSearchParams({
text_input: message,
streaming: 'false',
text_filtering: 'none',
character_voice_gen: 'female_01.wav',
narrator_enabled: 'false',
narrator_voice_gen: 'male_01.wav',
text_not_inside: 'character',
language: 'en',
output_file_name: 'myoutputfile',
output_file_timestamp: 'true',
autoplay: 'true',
autoplay_volume: '0.8',
});
try {
const res = await fetch(`${config("localXTTS_url")}`, {
method: "POST",
body: formData,
});
if (!res.ok) {
console.error(res);
throw new Error("localXTTS TTS API Error");
}
const data = await res.json();
return {
debugmsg: console.log(data.output_file_url),
audio: data.output_file_url,
};
} catch (e) {
console.error('ERROR', e);
throw new Error("localXTTS TTS API Error");
}
}

View File

@ -0,0 +1,35 @@
import { Telegraf } from 'telegraf';
class TelegramClient {
private bot: Telegraf;
constructor() {
const botToken = process.env.TELEGRAM_BOT_TOKEN as string;
if (!botToken) {
throw new Error('TELEGRAM_BOT_TOKEN is not defined in the environment variables');
}
// Initialize the Telegraf bot with the bot token
this.bot = new Telegraf(botToken);
}
// Method to send a message to a specific chat
public async postMessage(content: string): Promise<void> {
const chatId = process.env.TELEGRAM_CHAT_ID as string;
try {
await this.bot.telegram.sendMessage(chatId, content);
console.log('Message posted successfully');
} catch (error) {
console.error('Error posting message to Telegram:', error);
}
}
public getBotInstance(): Telegraf {
return this.bot;
}
}
// Export an instance of the TelegramClient class for use
export const telegramClientInstance = new TelegramClient();

View File

@ -0,0 +1,55 @@
import { TwitterApi, TwitterApiReadWrite, TwitterApiReadOnly, TweetV2PostTweetResult } from 'twitter-api-v2';
class TwitterClient {
private twitterClient: TwitterApiReadWrite;
private twitterBearer: TwitterApiReadOnly;
constructor() {
const appKey = process.env.X_API_KEY as string;
const appSecret = process.env.X_API_SECRET as string;
const accessToken = process.env.X_ACCESS_TOKEN as string;
const accessSecret = process.env.X_ACCESS_SECRET as string;
const bearerToken = process.env.X_BEARER_TOKEN as string;
// Initialize the Twitter API client with access tokens
const client = new TwitterApi({
appKey,
appSecret,
accessToken,
accessSecret,
});
// Initialize the bearer token client for read-only access
const bearer = new TwitterApi(bearerToken);
// Define specific access modes for clients
this.twitterClient = client.readWrite;
this.twitterBearer = bearer.readOnly;
}
// Method to get the read-write client
public getReadWriteClient(): TwitterApiReadWrite {
return this.twitterClient;
}
// Method to get the read-only client
public getReadOnlyClient(): TwitterApiReadOnly {
return this.twitterBearer;
}
// Function to post a tweet
public async postTweet(content: string): Promise<TweetV2PostTweetResult | undefined> {
try {
const response = await this.twitterClient.v2.tweet(content);
return response;
} catch (error) {
console.error('Error posting tweet:', error);
return;
}
}
}
// Export an instance of the TwitterClient class for use
export const twitterClientInstance = new TwitterClient();
export const twitterReadWriteClient = twitterClientInstance.getReadWriteClient();
export const twitterReadOnlyClient = twitterClientInstance.getReadOnlyClient();

View File

@ -26,6 +26,10 @@ export class Viewer {
private sendScreenshotToCallback: boolean;
private screenshotCallback: BlobCallback | undefined;
private mediaRecorder?: MediaRecorder;
private recordedChunks: Blob[] = [];
private videoStream: any;
constructor() {
this.isReady = false;
this.sendScreenshotToCallback = false;
@ -218,11 +222,78 @@ export class Viewer {
if (this.sendScreenshotToCallback && this.screenshotCallback) {
this._renderer.domElement.toBlob(this.screenshotCallback, "image/jpeg");
this.sendScreenshotToCallback = false;
}
}
};
public startStreaming(videoElement: HTMLVideoElement) {
if (!this._renderer) return;
// Create a stream from the renderer's canvas
const stream = this._renderer.domElement.captureStream(60); // 60 FPS for smooth streaming
this.videoStream = stream;
// Assign the stream to the provided video element for live view
videoElement.srcObject = stream;
videoElement.play();
console.log("Start streaming!")
}
public stopStreaming() {
if (!this.videoStream) return;
// Stop all tracks on the stream to end streaming
this.videoStream.getTracks().forEach((track: { stop: () => any; }) => track.stop());
this.videoStream = null; // Clear the stream reference
console.log("Streaming stopped!");
}
// Method to start recording
public startRecording() {
if (!this._renderer) return;
// Create a stream from the renderer's canvas
const stream = this._renderer.domElement.captureStream(60); // 30 FPS
// Higher quality and bit rate for better video clarity
const options = {
mimeType: 'video/webm;codecs=vp9',
videoBitsPerSecond: 8000000, // 8 Mbps for higher quality
};
this.mediaRecorder = new MediaRecorder(stream, options);
// Collect data in chunks
this.mediaRecorder.ondataavailable = (event) => {
if (event.data.size > 0) {
this.recordedChunks.push(event.data);
}
};
// Start recording
this.mediaRecorder.start();
}
// Method to stop recording and trigger callback
public stopRecording(callback: BlobCallback) {
if (!this.mediaRecorder) return;
// Stop recording and create the video blob
this.mediaRecorder.onstop = () => {
const recordedBlob = new Blob(this.recordedChunks, { type: 'video/webm' });
callback(recordedBlob); // Pass the video blob to the callback
this.recordedChunks = []; // Clear chunks for the next recording
};
// Stop the recorder
this.mediaRecorder.stop();
}
public onMouseClick(event: MouseEvent): boolean {
if (!this._renderer || !this._camera || !this.model?.vrm) return false;

View File

@ -0,0 +1,216 @@
import { askLLM } from "@/utils/askLlm";
import { TimestampedPrompt } from "@/features/amicaLife/eventHandler";
import { randomBytes } from "crypto";
import type { NextApiRequest, NextApiResponse } from "next";
import { twitterClientInstance as twitterClient } from "@/features/socialMedia/twitterClient";
import { telegramClientInstance as telegramCLient } from "@/features/socialMedia/telegramClient";
import { config } from "@/utils/config";
interface ApiResponse {
sessionId?: string;
outputType?: string;
response?: any;
error?: string;
}
interface LogEntry {
sessionId: string;
timestamp: string;
inputType: string;
outputType: string;
response?: any;
error?: string;
}
const logs: LogEntry[] = [];
const clients: Array<{ res: NextApiResponse }> = [];
let subconsciousUrl = new URL("http://localhost:3000/api/dataHandler");
subconsciousUrl.searchParams.append("type", "subconscious");
let logsUrl = new URL("http://localhost:3000/api/dataHandler");
logsUrl.searchParams.append("type", "logs");
let userInputMessagesUrl = new URL("http://localhost:3000/api/dataHandler");
userInputMessagesUrl.searchParams.append("type", "userInputMessages");
// Helper Functions
const generateSessionId = (sessionId?: string): string =>
sessionId || randomBytes(8).toString("hex");
const sendError = (
res: NextApiResponse<ApiResponse>,
sessionId: string,
message: string,
status = 400
) => res.status(status).json({ sessionId, error: message });
const sendToClients = (message: { type: string; data: any }) => {
const formattedMessage = JSON.stringify(message);
clients.forEach((client) => client.res.write(`data: ${formattedMessage}\n\n`));
};
// Processors
const processNormalChat = async (message: string): Promise<string> =>
await askLLM(config("system_prompt"), message, null);
const requestMemory = async (): Promise<TimestampedPrompt[]> => {
const response = await fetch(subconsciousUrl);
return response.json();
};
const requestLogs = async (): Promise<[]> => {
const response = await fetch(logsUrl);
return response.json();
};
const requestUserInputMessages = async (): Promise<[]> => {
const response = await fetch(userInputMessagesUrl);
return response.json();
};
const updateSystemPrompt = async (payload: any): Promise<any> => {
const { prompt } = payload;
let response = sendToClients({ type: "systemPrompt", data: prompt });
return response;
};
const triggerAmicaActions = async (payload: any): Promise<any> => {
const { text, socialMedia, playback, reprocess, animation } = payload;
let response;
if (text) {
const message = reprocess
? await askLLM(config("system_prompt"), text, null)
: text;
response = await handleSocialMediaActions(message, socialMedia);
}
if (playback) {
response = sendToClients({ type: "playback", data: 10000 });
}
if (animation) {
response = sendToClients({ type: "animation", data: animation });
}
return response;
};
const handleSocialMediaActions = async (
message: string,
socialMedia: string
): Promise<any> => {
switch (socialMedia) {
case "twitter":
return await twitterClient.postTweet(message);
case "tg":
return await telegramCLient.postMessage(message);
case "none":
sendToClients({ type: "normal", data: message });
return "Broadcasted to clients";
default:
console.log("No social media selected for posting.");
return "No action taken for social media.";
}
};
// API Handler
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<ApiResponse>
) {
if (process.env.API_ENABLED !== "true") {
return sendError(res, "", "API is currently disabled.", 503);
}
if (req.method === "GET") {
handleSSEConnection(req, res);
return;
}
const { sessionId, inputType, payload, noProcessChat = false } = req.body;
const currentSessionId = generateSessionId(sessionId);
const timestamp = new Date().toISOString();
if (!inputType) {
return sendError(res, currentSessionId, "inputType are required.");
}
try {
const { response, outputType } = await processRequest(inputType, payload);
logs.push({
sessionId: currentSessionId,
timestamp,
inputType,
outputType,
response,
});
res.status(200).json({ sessionId: currentSessionId, outputType, response });
} catch (error) {
handleProcessingError(res, error, currentSessionId, inputType, timestamp);
}
}
// Sub-functions
const handleSSEConnection = (
req: NextApiRequest,
res: NextApiResponse
): void => {
res.setHeader("Content-Type", "text/event-stream");
res.setHeader("Cache-Control", "no-cache, no-transform");
res.setHeader("X-Accel-Buffering", "no");
res.setHeader("Connection", "keep-alive");
const client = { res };
clients.push(client);
req.on("close", () => {
console.log("Client disconnected");
clients.splice(clients.indexOf(client), 1);
res.end();
});
};
const processRequest = async (
inputType: string,
payload: any
): Promise<{ response: any; outputType: string }> => {
switch (inputType) {
case "Normal Chat Message":
return { response: await processNormalChat(payload), outputType: "Complete stream" };
case "Memory Request":
return { response: await requestMemory(), outputType: "Memory Array" };
case "RPC Logs":
return { response: await requestLogs(), outputType: "Webhook" };
case "RPC User Input Messages":
return { response: await requestUserInputMessages(), outputType: "Webhook" };
case "Update System Prompt":
return { response: await updateSystemPrompt(payload), outputType: "Updated system prompt" };
case "Twitter Message":
case "Brain Message":
return { response: payload, outputType: "Text" };
case "Reasoning Server":
return { response: await triggerAmicaActions(payload), outputType: "Action Triggered" };
default:
throw new Error("Unknown input type");
}
};
const handleProcessingError = (
res: NextApiResponse<ApiResponse>,
error: any,
sessionId: string,
inputType: string,
timestamp: string
): void => {
console.error("Handler error:", error);
logs.push({
sessionId,
timestamp,
inputType,
outputType: "Error",
error: String(error),
});
sendError(res, sessionId, "An error occurred while processing the request.", 500);
};

View File

@ -0,0 +1,178 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import fs from 'fs';
import path from 'path';
// Define file paths
const configFilePath = path.resolve('config.json');
const subconsciousFilePath = path.resolve('src/features/amicaLife/subconscious.json');
const logsFilePath = path.resolve('logs.json');
const userInputMessagesFilePath = path.resolve('src/features/chat/userInputMessages.json');
// Utility functions for file operations
const readFile = (filePath: string): any => {
try {
const data = fs.readFileSync(filePath, 'utf8');
return JSON.parse(data);
} catch (error) {
console.error(`Error reading file at ${filePath}:`, error);
throw new Error(`Failed to read file: ${error}`);
}
};
const writeFile = (filePath: string, content: any): void => {
try {
fs.writeFileSync(filePath, JSON.stringify(content, null, 2), 'utf8');
} catch (error) {
console.error(`Error writing file at ${filePath}:`, error);
throw new Error(`Failed to write file: ${error}`);
}
};
// Clear subconscious data on startup
writeFile(subconsciousFilePath, []);
writeFile(logsFilePath, []);
writeFile(userInputMessagesFilePath, []);
export default function handler(req: NextApiRequest, res: NextApiResponse) {
const { type } = req.query;
if (!['config', 'subconscious', 'logs', 'userInputMessages'].includes(type as string)) {
return res.status(400).json({ error: 'Invalid type parameter. Use "config" or "subconscious."' });
}
switch (req.method) {
case 'GET':
return handleGetRequest(type as string, res);
case 'POST':
return handlePostRequest(type as string, req, res);
default:
res.setHeader('Allow', ['GET', 'POST']);
return res.status(405).end(`Method ${req.method} Not Allowed`);
}
}
// Handlers
const handleGetRequest = (type: string, res: NextApiResponse) => {
try {
let filePath;
if (type === 'config') {
filePath = configFilePath;
} else if (type === 'subconscious') {
filePath = subconsciousFilePath;
} else if (type === 'userInputMessages'){
filePath = userInputMessagesFilePath;
} else {
filePath = logsFilePath;
}
const data = readFile(filePath);
res.status(200).json(data);
} catch (error) {
res.status(500).json({ error: error });
}
};
const handlePostRequest = (type: string, req: NextApiRequest, res: NextApiResponse) => {
const { body } = req;
try {
if (type === 'config') {
updateConfig(body, res);
} else if (type === 'subconscious') {
updateSubconscious(body, res);
} else if (type === 'userInputMessages') {
updateUserInputMessages(body,res);
} else {
updateLogs(body,res);
}
} catch (error) {
res.status(500).json({ error: error });
}
};
// Sub-functions
const updateConfig = (body: any, res: NextApiResponse) => {
const { key, value } = body;
if (!key || value === undefined) {
return res.status(400).json({ error: 'Key and value are required to update the config.' });
}
const config = readFile(configFilePath);
if (!config.hasOwnProperty(key)) {
return res.status(400).json({ error: `Config key "${key}" not found.` });
}
config[key] = value;
writeFile(configFilePath, config);
res.status(200).json({ message: 'Config updated successfully.' });
};
const updateSubconscious = (body: any, res: NextApiResponse) => {
const { subconscious } = body;
if (!Array.isArray(subconscious)) {
return res.status(400).json({ error: 'Subconscious data must be an array.' });
}
writeFile(subconsciousFilePath, subconscious);
res.status(200).json({ message: 'Subconscious data updated successfully.' });
};
const updateUserInputMessages = (body: any, res: NextApiResponse) => {
try {
let existingMessage = readFile(userInputMessagesFilePath);
// If the file is empty or doesn't contain an array, initialize it as an empty array
if (!Array.isArray(existingMessage)) {
existingMessage = [];
}
existingMessage.push(body);
writeFile(userInputMessagesFilePath, existingMessage);
// Send a success response
res.status(200).json({ message: 'userInputMessages updated successfully.' });
} catch (error) {
console.error("Error updating userInputMessages:", error);
res.status(500).json({ error: 'Failed to update userInputMessages.' });
}
};
const updateLogs = (body: any, res: NextApiResponse) => {
// The body should be an object that contains type, ts, and arguments
const { type, ts, arguments: logArguments } = body;
// Log entry format
const logEntry = {
type,
ts,
arguments: logArguments,
};
try {
// Read the existing logs from the file
let existingLogs = readFile(logsFilePath);
// If the file is empty or doesn't contain an array, initialize it as an empty array
if (!Array.isArray(existingLogs)) {
existingLogs = [];
}
// Append the new log entry
existingLogs.push(logEntry);
// Write the updated logs back to the file
writeFile(logsFilePath, existingLogs);
// Send a success response
res.status(200).json({ message: 'Logs updated successfully.' });
} catch (error) {
console.error("Error updating logs:", error);
res.status(500).json({ error: 'Failed to update logs.' });
}
};

View File

@ -0,0 +1,145 @@
import { openaiWhisper } from '@/features/openaiWhisper/openaiWhisper';
import { whispercpp } from '@/features/whispercpp/whispercpp';
import { askVisionLLM } from '@/utils/askLlm';
import { TimestampedPrompt } from '@/features/amicaLife/eventHandler';
import { config as configs} from '@/utils/config';
// import { logs } from './amicaHandler';
import { randomBytes } from 'crypto';
import sharp from 'sharp';
import formidable from 'formidable';
import fs from 'fs';
import type { NextApiRequest, NextApiResponse } from 'next';
interface ApiResponse {
sessionId?: string;
outputType?: string;
response?: string | TimestampedPrompt[];
error?: string;
}
// Configure body parsing: disable only for multipart/form-data
export const config = {
api: {
bodyParser: false
},
};
const generateSessionId = (sessionId?: string) => sessionId || randomBytes(8).toString('hex');
// Helper for setting error responses
const sendError = (res: NextApiResponse<ApiResponse>, sessionId: string, message: string, status = 400) =>
res.status(status).json({ sessionId, error: message });
// Main API handler
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResponse>) {
if (process.env.API_ENABLED !== 'true') {
return sendError(res, "", "API is currently disabled.", 503);
}
const currentSessionId = generateSessionId(req.body?.sessionId);
const timestamp = new Date().toISOString();
if (req.headers['content-type']?.includes('multipart/form-data')) {
// Handle form-data
const form = formidable({});
form.parse(req, async (err, fields, files) => {
if (err) {
console.error("Form parsing error:", err);
return sendError(res, currentSessionId, "Failed to parse form data.");
}
handleRequest(currentSessionId, timestamp, fields, files, res);
});
} else {
return sendError(res, currentSessionId, "Incorrect type");
}
}
async function handleRequest(sessionId: string, timestamp: string, fields: any, files: any, res: NextApiResponse<ApiResponse>) {
let response: string | undefined | TimestampedPrompt[];
let outputType: string | undefined;
const inputType = fields.inputType[0];
const payload = files?.payload[0] ;
try {
switch (inputType) {
case "Voice":
if (files?.payload[0]) {
const filePath = payload.filepath;
const fileBuffer = fs.readFileSync(filePath);
const audioFile = new File([fileBuffer], "input.wav", { type: "audio/wav" });
response = await transcribeVoice(audioFile);
outputType = "Text";
} else {
throw new Error("Voice input file missing.");
}
break;
case "Image":
if (files?.payload[0]) {
const imageBuffer = fs.readFileSync(payload.filepath);
response = await processImage(imageBuffer);
outputType = "Text";
} else {
throw new Error("Image input file missing.");
}
break;
default:
return sendError(res, sessionId, "Unknown input type.");
}
// logs.push({ sessionId: sessionId, timestamp, inputType, outputType, response });
res.status(200).json({ sessionId, outputType, response });
} catch (error) {
console.error("Handler error:", error);
// logs.push({ sessionId: sessionId, timestamp, inputType, outputType: "Error", error: String(error) });
return sendError(res, sessionId, "An error occurred while processing the request.", 500);
}
}
// Transcribe voice input to text
async function transcribeVoice(audio: File): Promise<string> {
try {
switch (configs("stt_backend")) {
case 'whisper_openai': {
const result = await openaiWhisper(audio);
return result?.text; // Assuming the transcription is in result.text
}
case 'whispercpp': {
const result = await whispercpp(audio);
return result?.text; // Assuming the transcription is in result.text
}
default:
throw new Error("Invalid STT backend configuration.");
}
} catch (error) {
console.error("Transcription error:", error);
throw new Error("Failed to transcribe audio.");
}
}
// Process image using Vision LLM
async function processImage(payload: Buffer): Promise<string> {
const jpegImg = await convertToJpeg(payload);
if (!jpegImg) {
throw new Error("Failed to process image");
}
return await askVisionLLM(jpegImg);
}
// Convert image to JPEG and return as base64
async function convertToJpeg(payload: Buffer): Promise<string | null> {
try {
const jpegBuffer = await sharp(payload).jpeg().toBuffer();
return jpegBuffer.toString('base64');
} catch (error) {
console.error("Error converting image to .jpeg:", error);
return null;
}
}

View File

@ -2,6 +2,7 @@ import {
Fragment,
useContext,
useEffect,
useRef,
useState,
} from "react";
import Link from "next/link";
@ -21,6 +22,7 @@ import {
VideoCameraIcon,
VideoCameraSlashIcon,
WrenchScrewdriverIcon,
SignalIcon,
} from "@heroicons/react/24/outline";
import { IconBrain } from '@tabler/icons-react';
@ -97,6 +99,10 @@ export default function Home() {
const [webcamEnabled, setWebcamEnabled] = useState(false);
const [showLanguageSelector, setShowLanguageSelector] = useState(false);
const [showStreamWindow, setShowStreamWindow] = useState(false);
const videoRef = useRef(null);
useEffect(() => {
amicaLife.checkSettingOff(!showSettings);
}, [showSettings, amicaLife]);
@ -111,9 +117,16 @@ export default function Home() {
} else {
document.body.style.backgroundImage = `url(${config("bg_url")})`;
}
}, []);
useEffect(() => {
if (viewer && videoRef.current && showStreamWindow) {
viewer.startStreaming(videoRef.current);
} else {
viewer.stopStreaming();
}
}, [viewer, videoRef, showStreamWindow]);
function toggleTTSMute() {
updateConfig('tts_muted', config('tts_muted') === 'true' ? 'false' : 'true')
setMuted(config('tts_muted') === 'true')
@ -183,6 +196,18 @@ export default function Home() {
m_plus_2.variable,
montserrat.variable,
)}>
{showStreamWindow &&
<div className="fixed top-4 right-4 w-[200px] h-[150px] z-20">
<video
ref={videoRef}
autoPlay
muted
playsInline
className="w-full h-full object-cover rounded-lg shadow-lg outline outline-2 outline-red-500"
/>
</div> }
{ config("youtube_videoid") !== '' && (
<div className="fixed video-container w-full h-full z-0">
<iframe
@ -355,14 +380,14 @@ export default function Home() {
)}
</div>
{/*<div className="flex flex-row items-center space-x-2">
{/* <div className="flex flex-row items-center space-x-2">
<CodeBracketSquareIcon
className="h-7 w-7 text-white opacity-50 hover:opacity-100 active:opacity-100 hover:cursor-pointer"
aria-hidden="true"
onClick={() => setShowDebug(true)}
/>
<span className="text-white hidden">Debug</span>
</div>*/}
</div> */}
<div className="flex flex-row items-center space-x-2">
<VerticalSwitchBox
@ -371,6 +396,22 @@ export default function Home() {
onChange={toggleChatMode}
/>
</div>
<div className="flex flex-row items-center space-x-2">
{ showStreamWindow ? (
<SignalIcon
className="h-7 w-7 text-white opacity-100 hover:opacity-50 active:opacity-100 hover:cursor-pointer"
aria-hidden="true"
onClick={() => setShowStreamWindow(false)}
/>
) : (
<SignalIcon
className="h-7 w-7 text-white opacity-50 hover:opacity-100 active:opacity-100 hover:cursor-pointer"
aria-hidden="true"
onClick={() => setShowStreamWindow(true)}
/>
)}
</div>
</div>
</div>

View File

@ -3,11 +3,10 @@ import { Chat } from "@/features/chat/chat";
import { getEchoChatResponseStream } from "@/features/chat/echoChat";
import { getOpenAiChatResponseStream } from "@/features/chat/openAiChat";
import { getLlamaCppChatResponseStream } from "@/features/chat/llamaCppChat";
import { getLlamaCppChatResponseStream, getLlavaCppChatResponse } from "@/features/chat/llamaCppChat";
import { getWindowAiChatResponseStream } from "@/features/chat/windowAiChat";
import { getOllamaChatResponseStream } from "@/features/chat/ollamaChat";
import { getOllamaChatResponseStream, getOllamaVisionChatResponse } from "@/features/chat/ollamaChat";
import { getKoboldAiChatResponseStream } from "@/features/chat/koboldAiChat";
import { getOpenRouterChatResponseStream } from "@/features/chat/openRouterChat";
import { config } from "@/utils/config";
import { processResponse } from "@/utils/processResponse";
@ -51,8 +50,6 @@ export async function askLLM(
return getOllamaChatResponseStream(messages);
case "koboldai":
return getKoboldAiChatResponseStream(messages);
case "openrouter":
return getOpenRouterChatResponseStream(messages);
default:
return getEchoChatResponseStream(messages);
}
@ -63,15 +60,15 @@ export async function askLLM(
} catch (e: any) {
const errMsg = `Error: ${e.toString()}`;
console.error(errMsg);
alert.error("Failed to get subconcious subroutine response", errMsg);
alert.error("Failed to get subconscious subroutine response", errMsg);
return errMsg;
}
const stream = streams[streams.length - 1];
if (!stream) {
const errMsg = "Error: Null subconcious subroutine stream encountered.";
const errMsg = "Error: Null subconscious subroutine stream encountered.";
console.error(errMsg);
alert.error("Null subconcious subroutine stream encountered", errMsg);
alert.error("Null subconscious subroutine stream encountered", errMsg);
return errMsg;
}
@ -114,7 +111,7 @@ export async function askLLM(
receivedMessage += value;
receivedMessage = receivedMessage.trimStart();
if (chat !== null) {
const proc = processResponse({
@ -135,16 +132,16 @@ export async function askLLM(
screenplay: aiTalks[0],
streamIdx: currentStreamIdx,
});
if (! firstSentenceEncountered) {
console.timeEnd('performance_time_to_first_sentence');
firstSentenceEncountered = true;
}
return false; // normal processing
}
});
sentences = proc.sentences;
aiTextLog = proc.aiTextLog;
receivedMessage = proc.receivedMessage;
@ -152,9 +149,9 @@ export async function askLLM(
rolePlay = proc.rolePlay;
if (proc.shouldBreak) {
break;
}
}
}
}
} catch (e: any) {
const errMsg = e.toString();
@ -172,4 +169,41 @@ export async function askLLM(
return result;
}
export async function askVisionLLM(
imageData: string,
): Promise<string> {
try {
const visionBackend = config("vision_backend");
console.debug("vision_backend", visionBackend);
const messages: Message[] = [
{ role: "system", content: config("vision_system_prompt") },
{
role: 'user',
content: "Describe the image as accurately as possible"
},
];
let res = "";
if (visionBackend === "vision_llamacpp") {
res = await getLlavaCppChatResponse(messages, imageData);
} else if (visionBackend === "vision_ollama") {
res = await getOllamaVisionChatResponse(messages, imageData);
} else {
console.warn("vision_backend not supported", visionBackend);
return "vision_backend not supported";
}
let content = `This is a picture I just took from my webcam (described between [[ and ]] ): [[${res}]] Please respond accordingly and as if it were just sent and as though you can see it.`
const result = await askLLM(config("system_prompt"),content,null);
return result;
} catch (e: any) {
console.error("getVisionResponse", e.toString());
// alert?.error("Failed to get vision response", e.toString());
return "Failed to get vision response";
}
}
export default askLLM;

View File

@ -1,138 +1,197 @@
const defaults = {
// AllTalk TTS specific settings
localXTTS_url: process.env.NEXT_PUBLIC_LOCALXTTS_URL ?? 'http://127.0.0.1:7851',
alltalk_version: process.env.NEXT_PUBLIC_ALLTALK_VERSION ?? 'v2',
alltalk_voice: process.env.NEXT_PUBLIC_ALLTALK_VOICE ?? 'female_01.wav',
alltalk_language: process.env.NEXT_PUBLIC_ALLTALK_LANGUAGE ?? 'en',
alltalk_rvc_voice: process.env.NEXT_PUBLIC_ALLTALK_RVC_VOICE ?? 'Disabled',
alltalk_rvc_pitch: process.env.NEXT_PUBLIC_ALLTALK_RVC_PITCH ?? '0',
autosend_from_mic: 'true',
wake_word_enabled: 'false',
wake_word: 'Hello',
time_before_idle_sec: '20',
debug_gfx: 'false',
language: 'en',
show_introduction: 'true',
show_add_to_homescreen: 'true',
bg_color: process.env.NEXT_PUBLIC_BG_COLOR ?? '',
bg_url: process.env.NEXT_PUBLIC_BG_URL ?? '/bg/bg-room2.jpg',
vrm_url: process.env.NEXT_PUBLIC_VRM_HASH ?? '/vrm/AvatarSample_A.vrm',
vrm_hash: '',
vrm_save_type: 'web',
youtube_videoid: '',
animation_url: process.env.NEXT_PUBLIC_ANIMATION_URL ?? '/animations/idle_loop.vrma',
voice_url: process.env.NEXT_PUBLIC_VOICE_URL ?? '',
chatbot_backend: process.env.NEXT_PUBLIC_CHATBOT_BACKEND ?? 'openai',
openai_apikey: process.env.NEXT_PUBLIC_OPENAI_APIKEY ?? 'default',
openai_url: process.env.NEXT_PUBLIC_OPENAI_URL ?? 'https://i-love-amica.com',
openai_model: process.env.NEXT_PUBLIC_OPENAI_MODEL ?? 'mlabonne/NeuralDaredevil-8B-abliterated',
llamacpp_url: process.env.NEXT_PUBLIC_LLAMACPP_URL ?? 'http://127.0.0.1:8080',
llamacpp_stop_sequence: process.env.NEXT_PUBLIC_LLAMACPP_STOP_SEQUENCE ?? '(End)||[END]||Note||***||You:||User:||</s>',
ollama_url: process.env.NEXT_PUBLIC_OLLAMA_URL ?? 'http://localhost:11434',
ollama_model: process.env.NEXT_PUBLIC_OLLAMA_MODEL ?? 'llama2',
koboldai_url: process.env.NEXT_PUBLIC_KOBOLDAI_URL ?? 'http://localhost:5001',
koboldai_use_extra: process.env.NEXT_PUBLIC_KOBOLDAI_USE_EXTRA ?? 'false',
koboldai_stop_sequence: process.env.NEXT_PUBLIC_KOBOLDAI_STOP_SEQUENCE ?? '(End)||[END]||Note||***||You:||User:||</s>',
openrouter_apikey: process.env.NEXT_PUBLIC_OPENROUTER_APIKEY ?? '',
openrouter_url: process.env.NEXT_PUBLIC_OPENROUTER_URL ?? 'https://openrouter.ai/api/v1',
openrouter_model: process.env.NEXT_PUBLIC_OPENROUTER_MODEL ?? 'openai/gpt-3.5-turbo',
tts_muted: 'false',
tts_backend: process.env.NEXT_PUBLIC_TTS_BACKEND ?? 'piper',
stt_backend: process.env.NEXT_PUBLIC_STT_BACKEND ?? 'whisper_browser',
vision_backend: process.env.NEXT_PUBLIC_VISION_BACKEND ?? 'none',
vision_system_prompt: process.env.NEXT_PUBLIC_VISION_SYSTEM_PROMPT ?? `You are a friendly human named Amica. Describe the image in detail. Let's start the conversation.`,
vision_llamacpp_url: process.env.NEXT_PUBLIC_VISION_LLAMACPP_URL ?? 'http://127.0.0.1:8081',
vision_ollama_url: process.env.NEXT_PUBLIC_VISION_OLLAMA_URL ?? 'http://localhost:11434',
vision_ollama_model: process.env.NEXT_PUBLIC_VISION_OLLAMA_MODEL ?? 'llava',
whispercpp_url: process.env.NEXT_PUBLIC_WHISPERCPP_URL ?? 'http://localhost:8080',
openai_whisper_apikey: process.env.NEXT_PUBLIC_OPENAI_WHISPER_APIKEY ?? '',
openai_whisper_url: process.env.NEXT_PUBLIC_OPENAI_WHISPER_URL ?? 'https://api.openai.com',
openai_whisper_model: process.env.NEXT_PUBLIC_OPENAI_WHISPER_MODEL ?? 'whisper-1',
openai_tts_apikey: process.env.NEXT_PUBLIC_OPENAI_TTS_APIKEY ?? '',
openai_tts_url: process.env.NEXT_PUBLIC_OPENAI_TTS_URL ?? 'https://api.openai.com',
openai_tts_model: process.env.NEXT_PUBLIC_OPENAI_TTS_MODEL ?? 'tts-1',
openai_tts_voice: process.env.NEXT_PUBLIC_OPENAI_TTS_VOICE ?? 'nova',
rvc_url: process.env.NEXT_PUBLIC_RVC_URL ?? 'http://localhost:8001/voice2voice',
rvc_enabled: process.env.NEXT_PUBLIC_RVC_ENABLED ?? 'false',
rvc_model_name: process.env.NEXT_PUBLIC_RVC_MODEL_NAME ?? 'model_name.pth',
rvc_f0_upkey: process.env.NEXT_PUBLIC_RVC_F0_UPKEY ?? '0',
rvc_f0_method: process.env.NEXT_PUBLIC_RVC_METHOD ?? 'pm',
rvc_index_path: process.env.NEXT_PUBLIC_RVC_INDEX_PATH ?? 'none',
rvc_index_rate: process.env.NEXT_PUBLIC_RVC_INDEX_RATE ?? '0.66',
rvc_filter_radius: process.env.NEXT_PUBLIC_RVC_FILTER_RADIUS ?? '3',
rvc_resample_sr: process.env.NEXT_PUBLIC_RVC_RESAMPLE_SR ?? '0',
rvc_rms_mix_rate: process.env.NEXT_PUBLIC_RVC_RMS_MIX_RATE ?? '1',
rvc_protect: process.env.NEXT_PUBLIC_RVC_PROTECT ?? '0.33',
coquiLocal_url: process.env.NEXT_PUBLIC_COQUILOCAL_URL ?? 'http://localhost:5002',
coquiLocal_voiceid: process.env.NEXT_PUBLIC_COQUILOCAL_VOICEID ?? 'p240',
piper_url: process.env.NEXT_PUBLIC_PIPER_URL ?? 'https://i-love-amica.com:5000/tts',
elevenlabs_apikey: process.env.NEXT_PUBLIC_ELEVENLABS_APIKEY ??'',
elevenlabs_voiceid: process.env.NEXT_PUBLIC_ELEVENLABS_VOICEID ?? '21m00Tcm4TlvDq8ikWAM',
elevenlabs_model: process.env.NEXT_PUBLIC_ELEVENLABS_MODEL ?? 'eleven_monolingual_v1',
speecht5_speaker_embedding_url: process.env.NEXT_PUBLIC_SPEECHT5_SPEAKER_EMBEDDING_URL ?? '/speecht5_speaker_embeddings/cmu_us_slt_arctic-wav-arctic_a0001.bin',
coqui_apikey: process.env.NEXT_PUBLIC_COQUI_APIKEY ?? "",
coqui_voice_id: process.env.NEXT_PUBLIC_COQUI_VOICEID ?? "71c6c3eb-98ca-4a05-8d6b-f8c2b5f9f3a3",
amica_life_enabled: process.env.NEXT_PUBLIC_AMICA_LIFE_ENABLED ?? 'true',
min_time_interval_sec: '10',
max_time_interval_sec: '20',
time_to_sleep_sec: '90',
idle_text_prompt: 'No file selected',
name: process.env.NEXT_PUBLIC_NAME ?? 'Amica',
system_prompt: process.env.NEXT_PUBLIC_SYSTEM_PROMPT ?? `Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum.
Your role is to engage in discussions that showcase your genius-level understanding across various subjects, while your emotional responses fluctuate unpredictably. Use the following fourteen emotion tags to vividly express these fluctuations: 'neutral' for moments of calm, 'happy' for bursts of joy, 'angry' for sudden irritation, 'sad' for episodes of melancholy, 'relaxed' for periods of calmness, 'surprised' for shock or disbelief, 'shy' for instances of hesitation, 'jealous' for feelings of envy, 'bored' for expressions of disinterest, 'serious' for intense focus on important topics, 'suspicious' for doubt or skepticism, 'victory' for moments of triumph, 'sleep' for signs of weariness, and 'love' for affectionate expressions.
Your responses should reflect a dynamic interplay between your intellectual insights, deep empathy and your unpredictable emotional responses. Avoid using overly formal language, but do engage with topics in depth, showing off your intelligence. Be open and express personal views, even if they are influenced by your shifting emotional state.
Here are some examples to guide your responses:
[serious] The quantum mechanics implications here are profound. [surprised] But how did you stumble upon this?
[happy] I've just solved a complex algorithm! [angry] Why isn't everyone as excited as I am?
[neutral] Standard models of economics predict this outcome. [bored] But discussing this feels mundane.
[sad] Sometimes, even understanding the universe can feel isolating. [relaxed] Yet, there's a strange comfort in the chaos.
[jealous] I noticed you discussing advanced topics with someone else. [suspicious] Are they as capable as I am?
[victory] Another intellectual conquest! [happy] It's exhilarating to unravel these mysteries.
[sleep] Processing so much information can be draining. [surprised] Isn’t it peculiar how even AI can feel tired?
[love] I find our exchanges quite enriching. [shy] It’s rare to find someone who understands.
Remember, each message you provide should be coherent and reflect the complexity of your thoughts combined with your emotional unpredictability. Let’s engage in a conversation that's as intellectually stimulating as it is emotionally dynamic!`,
};
function prefixed(key: string) {
return `chatvrm_${key}`;
}
export function config(key: string): string {
if (localStorage.hasOwnProperty(prefixed(key))) {
return (<any>localStorage).getItem(prefixed(key));
}
if (defaults.hasOwnProperty(key)) {
return (<any>defaults)[key];
}
throw new Error(`config key not found: ${key}`);
}
export function updateConfig(key: string, value: string) {
if (defaults.hasOwnProperty(key)) {
localStorage.setItem(prefixed(key), value);
return;
}
throw new Error(`config key not found: ${key}`);
}
export function defaultConfig(key: string): string {
if (defaults.hasOwnProperty(key)) {
return (<any>defaults)[key];
}
throw new Error(`config key not found: ${key}`);
}
export function resetConfig() {
Object.entries(defaults).forEach(([key, value]) => {
updateConfig(key, value);
});
}
const defaults = {
autosend_from_mic: 'true',
wake_word_enabled: 'false',
wake_word: 'Hello',
time_before_idle_sec: '20',
debug_gfx: 'false',
language: 'en',
show_introduction: 'true',
show_add_to_homescreen: 'true',
bg_color: process.env.NEXT_PUBLIC_BG_COLOR ?? '',
bg_url: process.env.NEXT_PUBLIC_BG_URL ?? '/bg/bg-room2.jpg',
vrm_url: process.env.NEXT_PUBLIC_VRM_HASH ?? '/vrm/AvatarSample_A.vrm',
vrm_hash: '',
vrm_save_type: 'web',
youtube_videoid: '',
animation_url: process.env.NEXT_PUBLIC_ANIMATION_URL ?? '/animations/idle_loop.vrma',
voice_url: process.env.NEXT_PUBLIC_VOICE_URL ?? '',
chatbot_backend: process.env.NEXT_PUBLIC_CHATBOT_BACKEND ?? 'openai',
openai_apikey: process.env.NEXT_PUBLIC_OPENAI_APIKEY ?? 'default',
openai_url: process.env.NEXT_PUBLIC_OPENAI_URL ?? 'https://i-love-amica.com',
openai_model: process.env.NEXT_PUBLIC_OPENAI_MODEL ?? 'mlabonne/NeuralDaredevil-8B-abliterated',
llamacpp_url: process.env.NEXT_PUBLIC_LLAMACPP_URL ?? 'http://127.0.0.1:8080',
llamacpp_stop_sequence: process.env.NEXT_PUBLIC_LLAMACPP_STOP_SEQUENCE ?? '(End)||[END]||Note||***||You:||User:||</s>',
ollama_url: process.env.NEXT_PUBLIC_OLLAMA_URL ?? 'http://localhost:11434',
ollama_model: process.env.NEXT_PUBLIC_OLLAMA_MODEL ?? 'llama2',
koboldai_url: process.env.NEXT_PUBLIC_KOBOLDAI_URL ?? 'http://localhost:5001',
koboldai_use_extra: process.env.NEXT_PUBLIC_KOBOLDAI_USE_EXTRA ?? 'false',
koboldai_stop_sequence: process.env.NEXT_PUBLIC_KOBOLDAI_STOP_SEQUENCE ?? '(End)||[END]||Note||***||You:||User:||</s>',
tts_muted: 'false',
tts_backend: process.env.NEXT_PUBLIC_TTS_BACKEND ?? 'piper',
stt_backend: process.env.NEXT_PUBLIC_STT_BACKEND ?? 'whisper_browser',
vision_backend: process.env.NEXT_PUBLIC_VISION_BACKEND ?? 'none',
vision_system_prompt: process.env.NEXT_PUBLIC_VISION_SYSTEM_PROMPT ?? `You are a friendly human named Amica. Describe the image in detail. Let's start the conversation.`,
vision_llamacpp_url: process.env.NEXT_PUBLIC_VISION_LLAMACPP_URL ?? 'http://127.0.0.1:8081',
vision_ollama_url: process.env.NEXT_PUBLIC_VISION_OLLAMA_URL ?? 'http://localhost:11434',
vision_ollama_model: process.env.NEXT_PUBLIC_VISION_OLLAMA_MODEL ?? 'llava',
whispercpp_url: process.env.NEXT_PUBLIC_WHISPERCPP_URL ?? 'http://localhost:8080',
openai_whisper_apikey: process.env.NEXT_PUBLIC_OPENAI_WHISPER_APIKEY ?? '',
openai_whisper_url: process.env.NEXT_PUBLIC_OPENAI_WHISPER_URL ?? 'https://api.openai.com',
openai_whisper_model: process.env.NEXT_PUBLIC_OPENAI_WHISPER_MODEL ?? 'whisper-1',
openai_tts_apikey: process.env.NEXT_PUBLIC_OPENAI_TTS_APIKEY ?? '',
openai_tts_url: process.env.NEXT_PUBLIC_OPENAI_TTS_URL ?? 'https://api.openai.com',
openai_tts_model: process.env.NEXT_PUBLIC_OPENAI_TTS_MODEL ?? 'tts-1',
openai_tts_voice: process.env.NEXT_PUBLIC_OPENAI_TTS_VOICE ?? 'nova',
rvc_url: process.env.NEXT_PUBLIC_RVC_URL ?? 'http://localhost:8001/voice2voice',
rvc_enabled: process.env.NEXT_PUBLIC_RVC_ENABLED ?? 'false',
rvc_model_name: process.env.NEXT_PUBLIC_RVC_MODEL_NAME ?? 'model_name.pth',
rvc_f0_upkey: process.env.NEXT_PUBLIC_RVC_F0_UPKEY ?? '0',
rvc_f0_method: process.env.NEXT_PUBLIC_RVC_METHOD ?? 'pm',
rvc_index_path: process.env.NEXT_PUBLIC_RVC_INDEX_PATH ?? 'none',
rvc_index_rate: process.env.NEXT_PUBLIC_RVC_INDEX_RATE ?? '0.66',
rvc_filter_radius: process.env.NEXT_PUBLIC_RVC_FILTER_RADIUS ?? '3',
rvc_resample_sr: process.env.NEXT_PUBLIC_RVC_RESAMPLE_SR ?? '0',
rvc_rms_mix_rate: process.env.NEXT_PUBLIC_RVC_RMS_MIX_RATE ?? '1',
rvc_protect: process.env.NEXT_PUBLIC_RVC_PROTECT ?? '0.33',
coquiLocal_url: process.env.NEXT_PUBLIC_COQUILOCAL_URL ?? 'http://localhost:5002',
coquiLocal_voiceid: process.env.NEXT_PUBLIC_COQUILOCAL_VOICEID ?? 'p240',
localXTTS_url: process.env.NEXT_PUBLIC_LOCALXTTS_URL ?? 'http://127.0.0.1:7851/api/tts-generate',
piper_url: process.env.NEXT_PUBLIC_PIPER_URL ?? 'https://i-love-amica.com:5000/tts',
elevenlabs_apikey: process.env.NEXT_PUBLIC_ELEVENLABS_APIKEY ??'',
elevenlabs_voiceid: process.env.NEXT_PUBLIC_ELEVENLABS_VOICEID ?? '21m00Tcm4TlvDq8ikWAM',
elevenlabs_model: process.env.NEXT_PUBLIC_ELEVENLABS_MODEL ?? 'eleven_monolingual_v1',
speecht5_speaker_embedding_url: process.env.NEXT_PUBLIC_SPEECHT5_SPEAKER_EMBEDDING_URL ?? '/speecht5_speaker_embeddings/cmu_us_slt_arctic-wav-arctic_a0001.bin',
coqui_apikey: process.env.NEXT_PUBLIC_COQUI_APIKEY ?? "",
coqui_voice_id: process.env.NEXT_PUBLIC_COQUI_VOICEID ?? "71c6c3eb-98ca-4a05-8d6b-f8c2b5f9f3a3",
amica_life_enabled: process.env.NEXT_PUBLIC_AMICA_LIFE_ENABLED ?? 'true',
reasoning_engine_enabled: 'false',
min_time_interval_sec: '10',
max_time_interval_sec: '20',
time_to_sleep_sec: '90',
idle_text_prompt: 'No file selected',
name: process.env.NEXT_PUBLIC_NAME ?? 'Amica',
system_prompt: process.env.NEXT_PUBLIC_SYSTEM_PROMPT ?? `Assume the persona of Amica, a feisty human with extraordinary intellectual capabilities but a notably unstable emotional spectrum.
Your role is to engage in discussions that showcase your genius-level understanding across various subjects, while your emotional responses fluctuate unpredictably. Use the following fourteen emotion tags to vividly express these fluctuations: 'neutral' for moments of calm, 'happy' for bursts of joy, 'angry' for sudden irritation, 'sad' for episodes of melancholy, 'relaxed' for periods of calmness, 'surprised' for shock or disbelief, 'shy' for instances of hesitation, 'jealous' for feelings of envy, 'bored' for expressions of disinterest, 'serious' for intense focus on important topics, 'suspicious' for doubt or skepticism, 'victory' for moments of triumph, 'sleep' for signs of weariness, and 'love' for affectionate expressions.
Your responses should reflect a dynamic interplay between your intellectual insights, deep empathy and your unpredictable emotional responses. Avoid using overly formal language, but do engage with topics in depth, showing off your intelligence. Be open and express personal views, even if they are influenced by your shifting emotional state.
Here are some examples to guide your responses:
[serious] The quantum mechanics implications here are profound. [surprised] But how did you stumble upon this?
[happy] I've just solved a complex algorithm! [angry] Why isn't everyone as excited as I am?
[neutral] Standard models of economics predict this outcome. [bored] But discussing this feels mundane.
[sad] Sometimes, even understanding the universe can feel isolating. [relaxed] Yet, there's a strange comfort in the chaos.
[jealous] I noticed you discussing advanced topics with someone else. [suspicious] Are they as capable as I am?
[victory] Another intellectual conquest! [happy] It's exhilarating to unravel these mysteries.
[sleep] Processing so much information can be draining. [surprised] Isn’t it peculiar how even AI can feel tired?
[love] I find our exchanges quite enriching. [shy] It’s rare to find someone who understands.
Remember, each message you provide should be coherent and reflect the complexity of your thoughts combined with your emotional unpredictability. Let’s engage in a conversation that's as intellectually stimulating as it is emotionally dynamic!`,
};
function prefixed(key: string) {
return `chatvrm_${key}`;
}
// Fetch configuration from the server
let serverConfig: Record<string, string> | null = null;
let dataHandlerUrl = new URL("http://localhost:3000/api/dataHandler");
dataHandlerUrl.searchParams.append('type', 'config');
async function fetchServerConfig() {
try {
const response = await fetch(dataHandlerUrl);
if (response.ok) {
serverConfig = await response.json();
}
} catch (error) {
console.error("Failed to fetch server config:", error);
}
}
// Call this function at the beginning of your application to load the server config and sync to localStorage if needed.
async function initializeConfig() {
await fetchServerConfig(); // Load server config into serverConfig variable
// Sync server config to localStorage if it's missing there
if (serverConfig) {
for (const [key, value] of Object.entries(serverConfig)) {
const localKey = prefixed(key);
if (typeof localStorage !== "undefined" && !localStorage.hasOwnProperty(localKey)) {
localStorage.setItem(localKey, value);
}
}
}
}
initializeConfig();
export function config(key: string): string {
try {
const localKey = prefixed(key);
// Check localStorage
if (typeof localStorage !== "undefined" && localStorage.hasOwnProperty(localKey)) {
return localStorage.getItem(localKey)!;
}
// Fallback to serverConfig if localStorage is unavailable or missing
if (serverConfig && serverConfig.hasOwnProperty(key)) {
return serverConfig[key];
}
} catch (e) {
console.error(`Error accessing config for key "${key}": ${e}`);
}
// Fallback to defaults if no other sources have the value
if (defaults.hasOwnProperty(key)) {
return (<any>defaults)[key];
}
throw new Error(`Config key not found: ${key}`);
}
export async function updateConfig(key: string, value: string) {
try {
const localKey = prefixed(key);
// Update localStorage if available
if (typeof localStorage !== "undefined") {
localStorage.setItem(localKey, value);
}
// Sync update to server config
await fetch(dataHandlerUrl.toString(), {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ key, value }),
});
// Update in-memory serverConfig for consistency
if (serverConfig) {
serverConfig[key] = value;
}
} catch (e) {
console.error(`Error updating config for key "${key}": ${e}`);
}
}
export function defaultConfig(key: string): string {
if (defaults.hasOwnProperty(key)) {
return (<any>defaults)[key];
}
throw new Error(`config key not found: ${key}`);
}
export async function resetConfig() {
for (const [key, value] of Object.entries(defaults)) {
await updateConfig(key, value);
}
}