added fireworks adapter (#118)
This commit is contained in:
@@ -18,6 +18,7 @@ from dailyai.services.openai_llm_context import OpenAILLMContext
|
|||||||
from dailyai.services.open_ai_services import OpenAILLMService
|
from dailyai.services.open_ai_services import OpenAILLMService
|
||||||
# from dailyai.services.deepgram_ai_services import DeepgramTTSService
|
# from dailyai.services.deepgram_ai_services import DeepgramTTSService
|
||||||
from dailyai.services.elevenlabs_ai_service import ElevenLabsTTSService
|
from dailyai.services.elevenlabs_ai_service import ElevenLabsTTSService
|
||||||
|
from dailyai.services.fireworks_ai_services import FireworksLLMService
|
||||||
from dailyai.pipeline.frames import (
|
from dailyai.pipeline.frames import (
|
||||||
Frame,
|
Frame,
|
||||||
LLMFunctionCallFrame,
|
LLMFunctionCallFrame,
|
||||||
@@ -249,8 +250,7 @@ class ChecklistProcessor(AIService):
|
|||||||
print(f"--> {pretty_json}\n")
|
print(f"--> {pretty_json}\n")
|
||||||
if frame.function_name not in self._functions:
|
if frame.function_name not in self._functions:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"The LLM tried to call a function named {frame.function_name}, which isn't in the list of known functions. Please check your prompt and/or self._functions."
|
f"Unknown function.")
|
||||||
)
|
|
||||||
fn = getattr(self, frame.function_name)
|
fn = getattr(self, frame.function_name)
|
||||||
result = fn(json.loads(frame.arguments))
|
result = fn(json.loads(frame.arguments))
|
||||||
|
|
||||||
@@ -306,9 +306,9 @@ async def main(room_url: str, token):
|
|||||||
|
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
llm = OpenAILLMService(
|
llm = FireworksLLMService(
|
||||||
api_key=os.getenv("OPENAI_API_KEY"),
|
api_key=os.getenv("FIREWORKS_API_KEY"),
|
||||||
model="gpt-4-1106-preview",
|
model="accounts/fireworks/models/firefunction-v1"
|
||||||
)
|
)
|
||||||
# tts = DeepgramTTSService(
|
# tts = DeepgramTTSService(
|
||||||
# aiohttp_session=session,
|
# aiohttp_session=session,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ fal = [ "fal-client~=0.2.0" ]
|
|||||||
local = [ "pyaudio~=0.2.0" ]
|
local = [ "pyaudio~=0.2.0" ]
|
||||||
moondream = [ "einops~=0.7.0", "timm~=0.9.0", "transformers~=4.39.0" ]
|
moondream = [ "einops~=0.7.0", "timm~=0.9.0", "transformers~=4.39.0" ]
|
||||||
openai = [ "openai~=1.14.0" ]
|
openai = [ "openai~=1.14.0" ]
|
||||||
|
fireworks = [ "openai~=1.14.0" ]
|
||||||
playht = [ "pyht~=0.0.26" ]
|
playht = [ "pyht~=0.0.26" ]
|
||||||
silero = [ "torch~=2.2.0", "torchaudio~=2.2.0" ]
|
silero = [ "torch~=2.2.0", "torchaudio~=2.2.0" ]
|
||||||
websocket = [ "websockets~=12.0" ]
|
websocket = [ "websockets~=12.0" ]
|
||||||
|
|||||||
18
src/dailyai/services/fireworks_ai_services.py
Normal file
18
src/dailyai/services/fireworks_ai_services.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from dailyai.services.openai_api_llm_service import BaseOpenAILLMService
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
from openai import AsyncOpenAI
|
||||||
|
except ModuleNotFoundError as e:
|
||||||
|
print(f"Exception: {e}")
|
||||||
|
print(
|
||||||
|
"In order to use Fireworks, you need to `pip install dailyai[fireworks]`. Also, set the `FIREWORKS_API_KEY` environment variable.")
|
||||||
|
raise Exception(f"Missing module: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
class FireworksLLMService(BaseOpenAILLMService):
|
||||||
|
def __init__(self, model="accounts/fireworks/models/firefunction-v1", *args, **kwargs):
|
||||||
|
kwargs["base_url"] = "https://api.fireworks.ai/inference/v1"
|
||||||
|
super().__init__(model, *args, **kwargs)
|
||||||
Reference in New Issue
Block a user