llmtuner.llms.anyllm

Attributes

workspacemap_server_db

Classes

AnyLLMBase

Base class to handle interface to AnythingLLM

AnyLLMBuilder

Interface to create workspaces and embed documents in AnythingLLM

AnyLLMChatter

Interface to chat with a specific workspace.

AnyLLMDocuments

Class to manage documents in Anything LLM with vector database.

AnyLLMSpace

Class to interact with space/model in Anything LLM

Module Contents

class llmtuner.llms.anyllm.AnyLLMBase(config='')[source]

Bases: llmtuner.interface.Interface

Base class to handle interface to AnythingLLM

syncronize_store(updatestore=False)[source]

Check consistency between instance and store and update if required.

get_workspaces_list(synchronize=False)[source]

Get currently available workspace list from AnythingLLM and synchronize with local DB if ‘synchronize’=True

class llmtuner.llms.anyllm.AnyLLMBuilder(workspace_slug='')[source]

Bases: AnyLLMBase

Interface to create workspaces and embed documents in AnythingLLM

workspace = None[source]
vectordb[source]
docids = [][source]
get_available_documents(include_staged=True, include_embedded=True, include_workspace=True, filters={'indexed': {}, 'staged': {}, 'embedded': {}, 'added': {}}, common_only=False, docids_only=True)[source]

Get list of available documents indexed, staged, embedded in vector database, and, if workspace is set, added to the workspace, sorted by docid. You can provide a dictionary to filter for specific entries by providing column names and values for the tables.

add_document(url, metadata={})[source]

Manually add a document to the document index by providing the url and optionally additional metadata.

stage_documents(docids=[], update=True)[source]

Download documents locally and prepare for embedding

embed_documents(docids=[])[source]

Add a datafile to the vector database according to docid

move_documents_to_space(docids=[])[source]

Adding embedded documents to the selected space

list_documents_in_space()[source]

List documents added to the workspace

remove_documents_from_space(docids=[])[source]

Removing documents from the selected space (will still be in the database)

delete_documents(docids=[])[source]

Delete documents from the vector database

unstage_documents(docids=[])[source]

Deletes entries from local storage

unlist_documents(docids=[])[source]

Remove a document from the document index.

set_workspace(workspaceslug, create_new=False)[source]

Set the workspace slug and load workspace from server, or set up a new workspace if ‘create_new’ = True

class llmtuner.llms.anyllm.AnyLLMChatter(workspaceslug='', historylength=5)[source]

Bases: AnyLLMBase

Interface to chat with a specific workspace.

workspace = False[source]
chathistory = [][source]
historylength = 5[source]
set_workspace(workspaceslug)[source]
chat(prompt, return_metadata=False, display_only=False)[source]

Get a reply to a prompt from the workspace

_format_for_jupyter(response='')[source]

Make a nice output of the reply and references for a Jupyter notebook

class llmtuner.llms.anyllm.AnyLLMDocuments[source]

Bases: AnyLLMBase

Class to manage documents in Anything LLM with vector database.

_get_document(documentname)[source]

Getting info for one document.

upload_document(filepath='', content='', uploadname='', referenceid='', fileformat='')[source]

Uploads a file or text content from local storage and updates vectordatabase local table.

get_documents_list(synchronize=False)[source]

Get currently embedded document list from AnythingLLM and synchronize with local DB if ‘synchronize’=True

_delete_documents(docnames)[source]

Deleting documents from the vector database with the internal anythingllm name (docnames []).

remove_documents(docids)[source]

Removing documents from the vector database based on their docids

llmtuner.llms.anyllm.workspacemap_server_db[source]
class llmtuner.llms.anyllm.AnyLLMSpace(spaceslug='', config=None)[source]

Bases: AnyLLMBase

Class to interact with space/model in Anything LLM

slug = ''[source]
meta[source]
_get_metadata_from_server(updateobject=False, getfulldocs=False)[source]

Read metadata for workspace from AnythingLLM server, and update the metadata of this instance. Returns either list of docids or full information on included documents.

_set_metadata_on_server(metadata={})[source]
_get_metadata_from_database(updateobject=False)[source]
_set_metadata_to_database(metadata={})[source]

Set local database entry from object metadata

from_file(filepath, config, initialize_on_server=False)[source]
get_metadata(printit=False)[source]

Display the metadata of the current workspace. If ‘printit’, info will be displayed, not returned.

write(filepath)[source]

Write configuration of a workspace to a local yaml file

create_on_server()[source]

Create a new workspace from the local metadata

delete_from_server()[source]

Remove a workspace from the server

set_workspacename(slug)[source]

Set the name of the workspace and check existance of configuration

chat(prompt, provide_metadata=False)[source]

Use the workspace for chatting

move_documents(docids_add=[], docids_remove=[])[source]

Add documents to the workspace