From 4850b4a9f3fec9a56776366d6700b54b53440523 Mon Sep 17 00:00:00 2001 From: Ben Xu Date: Tue, 18 Jun 2024 15:51:56 -0700 Subject: [PATCH] move llm config to profiles directory --- software/source/clients/base_device.py | 4 ++ software/source/server/async_interpreter.py | 2 +- software/source/server/async_server.py | 21 +++--- software/source/server/profiles/default.py | 6 +- software/source/server/profiles/fast.py | 73 ++++++++++++--------- software/source/server/profiles/local.py | 4 ++ 6 files changed, 66 insertions(+), 44 deletions(-) diff --git a/software/source/clients/base_device.py b/software/source/clients/base_device.py index 885753e..6d2cdfd 100644 --- a/software/source/clients/base_device.py +++ b/software/source/clients/base_device.py @@ -364,6 +364,10 @@ class Device: if type(chunk) == str: chunk = json.loads(chunk) + if chunk.get("type") == "config": + self.tts_service = chunk.get("tts_service") + continue + if self.tts_service == "elevenlabs": message = chunk else: diff --git a/software/source/server/async_interpreter.py b/software/source/server/async_interpreter.py index 39303d2..f8990bd 100644 --- a/software/source/server/async_interpreter.py +++ b/software/source/server/async_interpreter.py @@ -194,7 +194,7 @@ class AsyncInterpreter: self.tts.feed(text_iterator) - self.tts.play_async(on_audio_chunk=self.on_tts_chunk, muted=False) + self.tts.play_async(on_audio_chunk=self.on_tts_chunk, muted=True) while True: await asyncio.sleep(0.1) diff --git a/software/source/server/async_server.py b/software/source/server/async_server.py index 13fcecd..bf42e4b 100644 --- a/software/source/server/async_server.py +++ b/software/source/server/async_server.py @@ -1,10 +1,9 @@ -# make this obvious -from .profiles.default import interpreter as base_interpreter +# TODO: import from the profiles directory the interpreter directory -# from .profiles.fast import interpreter as base_interpreter -# from .profiles.local import interpreter as base_interpreter +from .profiles.fast import interpreter as base_interpreter -# TODO: remove files i.py, llm.py, conftest?, services +# from .profiles.local import interpreter as base_interpreter +# from .profiles.default import interpreter as base_interpreter import asyncio import traceback @@ -12,8 +11,6 @@ import json from fastapi import FastAPI, WebSocket from fastapi.responses import PlainTextResponse from uvicorn import Config, Server - -# from interpreter import interpreter as base_interpreter from .async_interpreter import AsyncInterpreter from fastapi.middleware.cors import CORSMiddleware from typing import List, Dict, Any @@ -24,8 +21,8 @@ os.environ["STT_RUNNER"] = "server" os.environ["TTS_RUNNER"] = "server" -async def main(server_host, server_port, tts_service): - base_interpreter.tts = tts_service +async def main(server_host, server_port): + # interpreter.tts set in the profiles directory!!!! interpreter = AsyncInterpreter(base_interpreter) app = FastAPI() @@ -52,6 +49,12 @@ async def main(server_host, server_port, tts_service): @app.websocket("/") async def websocket_endpoint(websocket: WebSocket): await websocket.accept() + + # Send the tts_service value to the client + await websocket.send_text( + json.dumps({"type": "config", "tts_service": interpreter.interpreter.tts}) + ) + try: async def receive_input(): diff --git a/software/source/server/profiles/default.py b/software/source/server/profiles/default.py index c756725..80eb94a 100644 --- a/software/source/server/profiles/default.py +++ b/software/source/server/profiles/default.py @@ -3,6 +3,9 @@ from interpreter import interpreter # This is an Open Interpreter compatible profile. # Visit https://01.openinterpreter.com/profile for all options. +# 01 suports OpenAI, ElevenLabs, and Coqui (Local) TTS providers +# {OpenAI: "openai", ElevenLabs: "elevenlabs", Coqui: "coqui"} +interpreter.tts = "openai" # Connect your 01 to a language model interpreter.llm.model = "gpt-4-turbo" @@ -10,9 +13,6 @@ interpreter.llm.context_window = 100000 interpreter.llm.max_tokens = 4096 # interpreter.llm.api_key = "" -# Give your 01 a voice -interpreter.tts = "openai" - # Tell your 01 where to find and save skills interpreter.computer.skills.path = "./skills" diff --git a/software/source/server/profiles/fast.py b/software/source/server/profiles/fast.py index dc1945a..1fe274b 100644 --- a/software/source/server/profiles/fast.py +++ b/software/source/server/profiles/fast.py @@ -1,31 +1,42 @@ -async def main(server_host, server_port, tts_service, asynchronous): - - if asynchronous: - - base_interpreter.system_message = ( - "You are a helpful assistant that can answer questions and help with tasks." - ) - - base_interpreter.computer.import_computer_api = False - - base_interpreter.llm.model = "groq/llama3-8b-8192" - - base_interpreter.llm.api_key = os.environ["GROQ_API_KEY"] - - base_interpreter.llm.supports_functions = False - - base_interpreter.auto_run = True - - base_interpreter.tts = tts_service - - interpreter = AsyncInterpreter(base_interpreter) - - else: - - configured_interpreter = configure_interpreter(base_interpreter) - - configured_interpreter.llm.supports_functions = True - - configured_interpreter.tts = tts_service - - interpreter = AsyncInterpreter(configured_interpreter) +from interpreter import interpreter + +# This is an Open Interpreter compatible profile. +# Visit https://01.openinterpreter.com/profile for all options. + +# 01 suports OpenAI, ElevenLabs, and Coqui (Local) TTS providers +# {OpenAI: "openai", ElevenLabs: "elevenlabs", Coqui: "coqui"} +interpreter.tts = "elevenlabs" + +# 01 Language Model Config. +interpreter.llm_service = "litellm" +interpreter.llm.model = "groq/llama3-8b-8192" +interpreter.llm.supports_vision = False +interpreter.llm.supports_functions = False +interpreter.llm.context_window = 2048 +interpreter.llm.max_tokens = 4096 +interpreter.llm.temperature = 0.8 + +# interpreter.llm.api_key = os.environ["GROQ_API_KEY"] + +interpreter.computer.import_computer_api = False + +interpreter.auto_run = True +interpreter.system_message = ( + "You are a helpful assistant that can answer questions and help with tasks." +) + +# TODO: include other options in comments in the profiles for tts +# direct people to the profiles directory to make changes to the interpreter profile +# this should be made explicit on the docs + +""" + llm_service: str = "litellm", + model: str = "gpt-4", + llm_supports_vision: bool = False, + llm_supports_functions: bool = False, + context_window: int = 2048, + max_tokens: int = 4096, + temperature: float = 0.8, + tts_service: str = "elevenlabs", + stt_service: str = "openai", +""" diff --git a/software/source/server/profiles/local.py b/software/source/server/profiles/local.py index cf0a2d8..de58f75 100644 --- a/software/source/server/profiles/local.py +++ b/software/source/server/profiles/local.py @@ -1,5 +1,9 @@ from interpreter import interpreter +# 01 suports OpenAI, ElevenLabs, and Coqui (Local) TTS providers +# {OpenAI: "openai", ElevenLabs: "elevenlabs", Coqui: "coqui"} +interpreter.tts = "coqui" + # Local setup interpreter.local_setup()