Metadata-Version: 2.1
Name: promptengineers
Version: 1.1.9
Summary: A collection of utilities by Prompt Engineers
Home-page: https://github.com/promptengineers-ai/core
Author: Ryan Eggleston
Author-email: kre8mymedia@gmail.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
Requires-Dist: ujson
Provides-Extra: llms
Requires-Dist: langchain; extra == "llms"
Requires-Dist: openai; extra == "llms"
Provides-Extra: mongo
Requires-Dist: motor; extra == "mongo"
Requires-Dist: pymongo; extra == "mongo"
Requires-Dist: cryptography; extra == "mongo"
Provides-Extra: prompts
Requires-Dist: promptengineers[llms]; extra == "prompts"
Provides-Extra: storage
Requires-Dist: minio; extra == "storage"
Requires-Dist: python-multipart; extra == "storage"
Provides-Extra: retrieval
Requires-Dist: promptengineers[llms]; extra == "retrieval"
Requires-Dist: redis; extra == "retrieval"
Requires-Dist: pinecone-client; extra == "retrieval"
Requires-Dist: youtube-transcript-api; extra == "retrieval"
Requires-Dist: pypdf; extra == "retrieval"
Requires-Dist: numexpr; extra == "retrieval"
Requires-Dist: tiktoken; extra == "retrieval"
Requires-Dist: nest_asyncio; extra == "retrieval"
Requires-Dist: beautifulsoup4; extra == "retrieval"
Provides-Extra: tools
Requires-Dist: promptengineers[llms]; extra == "tools"
Provides-Extra: fastapi
Requires-Dist: fastapi; extra == "fastapi"
Requires-Dist: uvicorn; extra == "fastapi"
Requires-Dist: promptengineers[mongo]; extra == "fastapi"
Requires-Dist: promptengineers[storage]; extra == "fastapi"
Requires-Dist: promptengineers[retrieval]; extra == "fastapi"

# Prompt Engineers AI Open Source Package

### Build and Publish

```bash
## Build Package
bash scripts/build.sh

## Publish Package to PyPi
bash scripts/publish.sh
```


### Development

```bash
## In the application directory start your virtual env (this would be the workspace
## where your API server that you would like to install the model)
source .venv/bin/activate

## Then change directory to where your package is, make changes and run the following.
pip install .

## Switch back to the directory of your where your workspace is for you app server.
cd <path>/<app>/<server>
pip install -r requirements.txt

## Make sure your app server has the packages shown in setup.py and run your server...
```

## How to use...

### User Respository
A [User Repository](https://github.com/promptengineers-ai/llm-server/blob/master/server/repos/user.py) can be added to any application and then extended and then passed to llm-server to fetch user default project configurables via the 
environment variables or for multi-tenanted user application. This is allows for new variables when adding additional tools.

### Retrieval Augemented Generation (RAG) - HTTP Chat
```py
# Import necessary modules and classes
from promptengineers.core.config.test import TEST_USER_ID
from promptengineers.core.valdations import Validator
from promptengineers.retrieval.factories.provider VectorSearchProviderFactory
from promptengineers.retrieval.strategies import VectorstoreContext

from server.repos.user import UserRepo

INDEX_PROVIDER = 'pinecone'
INDEX_NAME = 'MyRetrievalIndex'
MODEL = 'gpt-4-turbo'
TEMPERATURE = 0.9,
MESSAGES = [
    {
        'role': 'system', 
        'content': 'You are a helpful document retrieval AI, use the context to answer the user queries.'
    },
    {
        'role': 'user', 
        'content': 'Can you summarize the context?'
    }
]

user_repo = UserRepo()

# Define a list of required API keys
required_keys = ['OPENAI_API_KEY', 'PINECONE_API_KEY', 'PINECONE_ENV', 'PINECONE_INDEX']

# Retrieve API tokens using the UserRepo class
tokens = user_repo.find_token(TEST_USER_ID, required_keys)

# Validate the retrieved API tokens against the required keys
Validator().validate_api_keys(tokens, required_keys)

# Choose the appropriate vector search provider strategy for Pinecone
vectorstore_strategy = VectorSearchProviderFactory.choose(
    provider=INDEX_PROVIDER,   # Specify the provider as 'pinecone'
    user_id=TEST_USER_ID,       # The user ID
    index_name=INDEX_NAME,  # The name of the index in Pinecone
    user_repo=user_repo   # An instance of UserRepo
)

# Create a vector store service context
vectostore_service = VectorstoreContext(vectorstore_strategy)

# Load the vectorstore using the service context
vectorstore = vectostore_service.load()

# Initialize a chat controller with a specific test user ID and user repository
chat_controller = ChatController(user_id=TEST_USER_ID, user_repo=user_repo)

# Conduct a chat using the langchain_http_vectorstore_chat method with specific parameters
result, cb = chat_controller.langchain_http_vectorstore_chat(
    messages=MESSAGES,
    model=MODEL,  # Specify the model to use (GPT-4 Turbo)
    temperature=TEMPERATURE,      # Set the temperature for response variability
    vectorstore=vectorstore,  # Use the previously loaded vectorstore
)
```
