-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from sirji-ai/create-and-sync-assistant-actions
Create and sync assistant actions
- Loading branch information
Showing
46 changed files
with
1,558 additions
and
661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
sirji-messages==0.0.28 | ||
sirji-tools==0.0.14 | ||
openai==1.14.1 | ||
sirji-messages==0.0.29 | ||
sirji-tools==0.0.15 | ||
openai==1.35.7 | ||
anthropic==0.29.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from .researcher import ResearchAgent | ||
from .researcher import ResearchAgent, CleanupFactory | ||
from .llm.orchestrator import Orchestrator | ||
from .llm.generic import GenericAgent | ||
|
||
__all__ = [ | ||
'ResearchAgent', | ||
'Orchestrator', | ||
'GenericAgent' | ||
'GenericAgent', | ||
'CleanupFactory' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .researcher import ResearchAgent | ||
from .cleanup.factory import CleanupFactory | ||
|
||
__all__ = ['ResearchAgent'] | ||
__all__ = ['ResearchAgent', 'CleanupFactory'] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class CleanupBase(ABC): | ||
|
||
@abstractmethod | ||
def delete_assistant(self, assistant_id): | ||
""" | ||
Deletes the assistant. | ||
:param assistant_id: The assistant ID to be deleted. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def delete_vector_store(self, vector_store_id): | ||
""" | ||
Deletes the vector store. | ||
:param vector_store_id: The vector store ID to be deleted. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def delete_file(self, file_path): | ||
""" | ||
Deletes the file. | ||
:param file_path: The file path to be deleted. | ||
""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from .openai_cleanup import OpenAICleanup | ||
import os | ||
|
||
|
||
class CleanupFactory: | ||
@classmethod | ||
def get_instance(cls): | ||
|
||
provider_name = os.environ.get('SIRJI_MODEL_PROVIDER').lower() | ||
|
||
if provider_name == "openai": | ||
return OpenAICleanup() | ||
else: | ||
raise ValueError("Unsupported provider: {}".format(provider_name)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
from openai import OpenAI | ||
|
||
from sirji_tools.logger import create_logger | ||
|
||
from .base import CleanupBase | ||
|
||
class OpenAICleanup(CleanupBase): | ||
def __init__(self): | ||
self.logger = create_logger("researcher.log", "debug") | ||
api_key = os.environ.get("SIRJI_MODEL_PROVIDER_API_KEY") | ||
|
||
if api_key is None: | ||
raise ValueError( | ||
"OpenAI API key is not set as an environment variable") | ||
|
||
# Initialize OpenAI client | ||
client = OpenAI(api_key=api_key) | ||
|
||
self.logger.info("Completed initializing OpenAI client") | ||
self.client = client | ||
|
||
|
||
def delete_assistant(self, assistant_id): | ||
self.logger.info("Deleting assistant") | ||
try: | ||
response = self.client.beta.assistants.delete(assistant_id) | ||
print(response) | ||
self.logger.info(response) | ||
except Exception as e: | ||
print(e) | ||
self.logger.error(e) | ||
|
||
def delete_vector_store(self, vector_store_id): | ||
try: | ||
response = self.client.beta.vector_stores.delete( | ||
vector_store_id = vector_store_id | ||
) | ||
print(response) | ||
self.logger.info(response) | ||
except Exception as e: | ||
print(e) | ||
self.logger.error(e) | ||
|
||
def delete_file(self, file_path): | ||
try: | ||
response = self.client.files.delete(file_path) | ||
print(response) | ||
self.logger.info(response) | ||
except Exception as e: | ||
print(e) | ||
self.logger.error(e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
from .openai_assistant import OpenAIAssistantEmbeddings | ||
import os | ||
|
||
|
||
class EmbeddingsFactory: | ||
@classmethod | ||
def get_instance(cls, embeddings_type, init_payload): | ||
if embeddings_type == "openai_assistant": | ||
def get_instance(cls, init_payload): | ||
|
||
provider_name = os.environ.get('SIRJI_MODEL_PROVIDER').lower() | ||
|
||
if provider_name == "openai": | ||
return OpenAIAssistantEmbeddings(init_payload) | ||
else: | ||
raise ValueError("Unsupported embeddings_type.") |
Oops, something went wrong.