package seems to work
This commit is contained in:
@@ -1,50 +0,0 @@
|
|||||||
import os
|
|
||||||
import random
|
|
||||||
import time
|
|
||||||
|
|
||||||
"""
|
|
||||||
from algoliasearch.configs import SearchConfig
|
|
||||||
from algoliasearch.search_client import SearchClient
|
|
||||||
"""
|
|
||||||
|
|
||||||
class SearchIndexer():
|
|
||||||
def __init__(self, story_id):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def index_text(self, text):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def index_image(self, text):
|
|
||||||
pass
|
|
||||||
"""
|
|
||||||
class AlgoliaSearchIndexer(SearchIndexer):
|
|
||||||
def __init__(self, story_id):
|
|
||||||
self.index = None
|
|
||||||
self.story_id = story_id
|
|
||||||
|
|
||||||
self.search_enabled = os.getenv('ALGOLIA_APP_ID') and os.getenv('ALGOLIA_API_KEY')
|
|
||||||
if self.search_enabled:
|
|
||||||
config = SearchConfig(os.getenv('ALGOLIA_APP_ID'), os.getenv('ALGOLIA_API_KEY'))
|
|
||||||
self.algolia = SearchClient.create_with_config(config)
|
|
||||||
self.index = self.algolia.init_index('daily-llm-conversations')
|
|
||||||
|
|
||||||
def index_text(self, text):
|
|
||||||
if self.index:
|
|
||||||
res = self.index.save_object({
|
|
||||||
"objectID": hex(random.getrandbits(128))[2:],
|
|
||||||
"storyID": self.story_id,
|
|
||||||
"type": "text",
|
|
||||||
"text": text,
|
|
||||||
"createdAt": int(time.time())
|
|
||||||
}).wait()
|
|
||||||
|
|
||||||
def index_image(self, url):
|
|
||||||
if self.index:
|
|
||||||
self.index.save_object({
|
|
||||||
"objectID": hex(random.getrandbits(128))[2:],
|
|
||||||
"storyID": self.story_id,
|
|
||||||
"type": "image",
|
|
||||||
"image": url,
|
|
||||||
"createdAt": int(time.time())
|
|
||||||
}).wait()
|
|
||||||
"""
|
|
||||||
0
src/dailyai/async_processor/__init__.py
Normal file
0
src/dailyai/async_processor/__init__.py
Normal file
@@ -9,12 +9,11 @@ from threading import Event, Semaphore, Thread
|
|||||||
from typing import Iterator, Optional, Type, TypedDict
|
from typing import Iterator, Optional, Type, TypedDict
|
||||||
from typing_extensions import Unpack
|
from typing_extensions import Unpack
|
||||||
|
|
||||||
from services.ai_services import AIServiceConfig
|
from dailyai.services.ai_services import AIServiceConfig
|
||||||
from message_handler.message_handler import MessageHandler
|
from dailyai.message_handler.message_handler import MessageHandler
|
||||||
|
|
||||||
frame_idx = 0
|
frame_idx = 0
|
||||||
|
|
||||||
|
|
||||||
class AsyncProcessorState:
|
class AsyncProcessorState:
|
||||||
# Setting class variables, other synchronous activities
|
# Setting class variables, other synchronous activities
|
||||||
INIT = 0
|
INIT = 0
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: daily_ai
|
Name: dailyai
|
||||||
Version: 0.0.1
|
Version: 0.0.1
|
||||||
Summary: Orchestrator for AI bots with Daily
|
Summary: Orchestrator for AI bots with Daily
|
||||||
Requires-Dist: daily-python
|
Requires-Dist: daily-python
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
README.md
|
README.md
|
||||||
pyproject.toml
|
pyproject.toml
|
||||||
src/daily-ai/async_processor/async_processor.py
|
src/daily-ai/async_processor/async_processor.py
|
||||||
src/daily-ai/daily_ai.egg-info/PKG-INFO
|
src/daily-ai/dailyai.egg-info/PKG-INFO
|
||||||
src/daily-ai/daily_ai.egg-info/SOURCES.txt
|
src/daily-ai/dailyai.egg-info/SOURCES.txt
|
||||||
src/daily-ai/daily_ai.egg-info/dependency_links.txt
|
src/daily-ai/dailyai.egg-info/dependency_links.txt
|
||||||
src/daily-ai/daily_ai.egg-info/requires.txt
|
src/daily-ai/dailyai.egg-info/requires.txt
|
||||||
src/daily-ai/daily_ai.egg-info/top_level.txt
|
src/daily-ai/dailyai.egg-info/top_level.txt
|
||||||
src/daily-ai/message_handler/message_handler.py
|
src/daily-ai/message_handler/message_handler.py
|
||||||
src/daily-ai/services/ai_services.py
|
src/daily-ai/services/ai_services.py
|
||||||
src/daily-ai/services/azure_ai_services.py
|
src/daily-ai/services/azure_ai_services.py
|
||||||
0
src/dailyai/message_handler/__init__.py
Normal file
0
src/dailyai/message_handler/__init__.py
Normal file
@@ -5,8 +5,8 @@ from dataclasses import dataclass
|
|||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from storage.search import SearchIndexer
|
from dailyai.storage.search import SearchIndexer
|
||||||
from services.ai_services import AIServiceConfig
|
from dailyai.services.ai_services import AIServiceConfig
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -6,14 +6,14 @@ import wave
|
|||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
|
|
||||||
from daily_ai.async_processor import (
|
from dailyai.async_processor.async_processor import (
|
||||||
AsyncProcessor,
|
AsyncProcessor,
|
||||||
AsyncProcessorState,
|
AsyncProcessorState,
|
||||||
ConversationProcessorCollection,
|
ConversationProcessorCollection,
|
||||||
Response,
|
Response,
|
||||||
)
|
)
|
||||||
from daily_ai.services.ai_services import AIServiceConfig
|
from dailyai.services.ai_services import AIServiceConfig
|
||||||
from daily_ai.message_handler import MessageHandler
|
from dailyai.message_handler.message_handler import MessageHandler
|
||||||
|
|
||||||
from threading import Thread, Semaphore, Event, Timer
|
from threading import Thread, Semaphore, Event, Timer
|
||||||
|
|
||||||
0
src/dailyai/services/__init__.py
Normal file
0
src/dailyai/services/__init__.py
Normal file
@@ -6,7 +6,7 @@ import requests
|
|||||||
|
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
from daily_ai.services.ai_services import LLMService, TTSService, ImageGenService
|
from dailyai.services.ai_services import LLMService, TTSService, ImageGenService
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
# See .env.example for Azure configuration needed
|
# See .env.example for Azure configuration needed
|
||||||
@@ -4,7 +4,7 @@ import time
|
|||||||
|
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
from daily_ai.services.ai_services import TTSService
|
from ..services.ai_services import TTSService
|
||||||
|
|
||||||
|
|
||||||
class ElevenLabsTTSService(TTSService):
|
class ElevenLabsTTSService(TTSService):
|
||||||
0
src/dailyai/storage/__init__.py
Normal file
0
src/dailyai/storage/__init__.py
Normal file
9
src/dailyai/storage/search.py
Normal file
9
src/dailyai/storage/search.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class SearchIndexer():
|
||||||
|
def __init__(self, story_id):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def index_text(self, text):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def index_image(self, text):
|
||||||
|
pass
|
||||||
0
src/dailyai/tests/__init__.py
Normal file
0
src/dailyai/tests/__init__.py
Normal file
@@ -5,13 +5,17 @@ from queue import Queue, Empty
|
|||||||
from threading import Thread, Event
|
from threading import Thread, Event
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
|
||||||
from services.ai_services import LLMService, TTSService, ImageGenService
|
from dailyai.services.ai_services import (
|
||||||
from message_handler.message_handler import MessageHandler
|
|
||||||
from async_processor.async_processor import (
|
|
||||||
AsyncProcessor,
|
|
||||||
AIServiceConfig,
|
AIServiceConfig,
|
||||||
|
ImageGenService,
|
||||||
|
LLMService,
|
||||||
|
TTSService
|
||||||
|
)
|
||||||
|
from dailyai.message_handler.message_handler import MessageHandler
|
||||||
|
from dailyai.async_processor.async_processor import (
|
||||||
|
AsyncProcessor,
|
||||||
AsyncProcessorState,
|
AsyncProcessorState,
|
||||||
Response
|
Response,
|
||||||
)
|
)
|
||||||
|
|
||||||
class MockTTSService(TTSService):
|
class MockTTSService(TTSService):
|
||||||
@@ -3,9 +3,14 @@ import unittest
|
|||||||
|
|
||||||
from unittest.mock import MagicMock, call
|
from unittest.mock import MagicMock, call
|
||||||
|
|
||||||
from message_handler.message_handler import MessageHandler, IndexingMessageHandler
|
from dailyai.message_handler.message_handler import MessageHandler, IndexingMessageHandler
|
||||||
from services.ai_services import AIService, AIServiceConfig, TTSService, LLMService, ImageGenService
|
from dailyai.services.ai_services import (
|
||||||
from storage.search import SearchIndexer
|
AIServiceConfig,
|
||||||
|
TTSService,
|
||||||
|
LLMService,
|
||||||
|
ImageGenService,
|
||||||
|
)
|
||||||
|
from ..storage.search import SearchIndexer
|
||||||
|
|
||||||
|
|
||||||
class TestMessageHandler(unittest.TestCase):
|
class TestMessageHandler(unittest.TestCase):
|
||||||
Reference in New Issue
Block a user