penguin.llm module

class penguin.llm.AssistantManager[source]

Bases: object

A class to manage OpenAI assistants, threads, and vector stores.

create_assistant(name, instructions, tools=None, model='gpt-4o')[source]

Create an assistant if it doesn’t already exist.

Args:

name (str): The name of the assistant. instructions (str): Instructions for the assistant. tools (Optional[List[dict]]): List of tools for the assistant. model (str): The model to use for the assistant.

Parameters:
  • name (str)

  • instructions (str)

  • tools (List[dict] | None)

  • model (str)

create_run(prompt)[source]

Create a new thread, add a message, and start a run.

Args:

prompt (str): The prompt to send to the assistant.

Returns:

str: The ID of the created run.

Parameters:

prompt (str)

Return type:

str

exists_assistant()[source]

Check if the assistant exists.

Returns:

bool: True if the assistant exists, False otherwise.

Return type:

bool

exists_client()[source]

Check if the OpenAI client exists.

Returns:

bool: True if the client exists, False otherwise.

Return type:

bool

select_best_config(graph, prompt)[source]

Select the best configuration based on the given graph and prompt.

Args:

graph (str): The graph to use for configuration selection. prompt (str): The prompt to send to the assistant.

Returns:

str: The selected configuration as a string.

Parameters:
  • graph (str)

  • prompt (str)

Return type:

str

upload_knowledge_files()[source]

Upload knowledge files to the vector store and update the assistant.