-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #23 from PromptSail/dev
Update main
- Loading branch information
Showing
96 changed files
with
6,469 additions
and
3,434 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,41 @@ | ||
# Contributing to PromptSail | ||
|
||
We believe in open community-driven software, and thanks to everyone who contributed. 🙏❤️ | ||
|
||
|
||
|
||
## How Can I Contribute? | ||
|
||
### Reporting Bugs | ||
|
||
- **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/PromptSail/prompt_sail/issues). | ||
- If you cannot find an open issue addressing the problem, [open a new one](https://github.com/PromptSail/prompt_sail/issues/new). | ||
|
||
### Suggesting Enhancements and new features | ||
|
||
- Open a new issue with a clear view of what you have in mind, and add the label "idea". | ||
|
||
### Your First Code Contribution | ||
|
||
1. Go through t the [Prompt Sail documentation](https://promptsail.github.io/prompt_sail/docs/introduction/) | ||
2. Get acquainted with how the [repository is structured](https://promptsail.github.io/prompt_sail/docs/repository-structure/) | ||
3. Get acquainted with how the [documentaion is organized](https://promptsail.github.io/prompt_sail/docs/how-to-write-documentation/) | ||
|
||
|
||
The general forking procedure: | ||
|
||
- Fork the repo. | ||
- Create a new branch (`git checkout -b feature-name`). | ||
- Commit your changes (`git commit -am 'Add some feature'`). | ||
- Push to the branch (`git push origin feature-name`). | ||
- Open a new Pull Request with a description what and why you have changed | ||
|
||
### Contributors | ||
|
||
Thank you all 🙏 | ||
|
||
<a href="https://github.com/PromptSail/prompt_sail/graphs/contributors"> | ||
<img src="https://contrib.rocks/image?repo=PromptSail/prompt_sail" /> | ||
</a> | ||
|
||
|
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,34 +1,58 @@ | ||
|
||
|
||
<p align="center"> | ||
<p align="center"> | ||
<a href="https://promptsail.com/?utm_source=github&utm_medium=logo" target="_blank"> | ||
<img src="https://bucket.mlcdn.com/a/1777/1777896/images/c2ba3a2cf624d3343a98cbb35f1d02dd373d8000.png" alt="Prompt Sail" width="390" height="91"> | ||
<img src="docs/assets/images/Logo-teal_black.png" alt="Prompt Sail" width="390" height="91"> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
Open Source LLM prompt management and monitoring. | ||
LLM’s proxy for prompt and response governance, monitoring, and analysis. 📊🔍 | ||
</p> | ||
</p> | ||
|
||
## What is Prompt Sail? | ||
> ⚠️ **Prompt Sail is currently in Development**: Expect breaking changes and bugs! Feedback and contributions are welcome. Please see the [Contributing Guide](CONTRIBUTING.md) for more information. | ||
<p align="center"> | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
<img alt="GitHub License" src="https://img.shields.io/github/license/promptsail/prompt_sail"> | ||
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/promptsail/prompt_sail/docker-publish.yml?label=Build%20and%20Publish%20Docker"> | ||
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/y/promptsail/prompt_sail"/> | ||
<img alt="Github Last Commit" src="https://img.shields.io/github/last-commit/promptsail/prompt_sail"/> | ||
<img alt="Github Contributors" src="https://img.shields.io/github/contributors/promptsail/prompt_sail"/> | ||
<img alt="GitHub closed issues" src="https://img.shields.io/github/issues-closed/promptsail/prompt_sail"/> | ||
|
||
</p> | ||
|
||
|
||
## What is Prompt Sail? | ||
|
||
Prompt Sail is a proxy for Large Language Models (LLMs) API's such as OpenAI GPT models, Azure OpenAI, Anthropic Clude etc. that allows you to record prompts and responses, analyze costs, generation speed, compare and track trends and changes across various models and projects over time. | ||
|
||
Prompt Sail is a proxy for Large Language Models (LLMs) such as GPT-3, ChatGPT, DialoGPT, etc. | ||
that allows you to record prompts and responses, analyze the output, compare the outcome over time, | ||
track trends and changes across various models and their versions. | ||
To learn more about Prompt Sail’s features and capabilities, see | ||
|
||
To learn more about Prompt Sail’s features and capabilities, see our [product page](https://promptsail.com/). | ||
* [Documentation](https://promptsail.github.io/prompt_sail/) 📖 | ||
* [Examples](https://github.com/PromptSail/prompt_sail/tree/main/examples) 💻 | ||
* [OpenAI SDK -> OpenAI API](/examples/openai_sdk_openai.ipynb) | ||
* [Langchain SDK -> OpenAI API](/examples/langchain_openai.ipynb) | ||
* [OpenAI SDK -> Azure OpenAI](/examples/openai_sdk_azure_openai.ipynb) | ||
* [Langchain SDK -> Azure OpenAI](/examples/langchain_azure_openai.ipynb) | ||
* [Langchain SDK -> Azure OpenAI Ada embeddings](/examples/langchain_azure_oai_embeddings.ipynb) | ||
|
||
## Getting started | ||
<!-- * [API Reference](https://promptsail.github.io/prompt_sail/api/). --> | ||
|
||
## Getting started 🚀 | ||
|
||
The simplest way to try Prompt Sail is to create a project on https://try.promptsail.com and integrate it with | ||
your code. | ||
|
||
If you prefer to install and manage Prompt Sail yourself, you can download a docker image and run it locally. | ||
If you prefer to install and manage Prompt Sail yourself, you can build or download a docker image and run it locally. | ||
|
||
## Run Prompt Sail locally | ||
## Run Prompt Sail locally via Docker Compose 🐳 | ||
|
||
To try out Start Prompt on your own machine, we recommend using docker-compose. Docker images are available from ... | ||
|
||
### Requirements | ||
### Requirements 📋 | ||
|
||
* installed docker and docker-compose on your machine [Windows](https://docs.docker.com/docker-for-windows/install/) | [Mac](https://docs.docker.com/docker-for-mac/install/) | [Linux](https://docs.docker.com/engine/install/ubuntu/) | ||
* git clone repository and navigate to main directory | ||
|
@@ -39,112 +63,96 @@ cd prompt_sail | |
|
||
|
||
|
||
### Linux machine | ||
|
||
1. Since Prompt Sail relies on subdomains, first you should update your `/ect/hosts` file with the following lines: | ||
|
||
```bash | ||
127.0.1.1 project1.promptsail.local | ||
127.0.1.1 project2.promptsail.local | ||
127.0.1.1 promptsail.local | ||
``` | ||
### Build docker images 🏗️ | ||
|
||
3. Build and run the docker image: | ||
Build and run the docker image: | ||
|
||
```bash | ||
docker-docker-compose up --build | ||
``` | ||
|
||
If you want to run the code locally: | ||
|
||
Create `.env` file in the root project directory with the following content: | ||
|
||
``` | ||
OPENAI_API_KEY="[your-openai-api-key]" | ||
MONGO_URL="mongodb://root:password@localhost:27017" | ||
BASE_URL="http://promptsail.local:8000" | ||
``` | ||
|
||
Make sure you have Poetry installed, then: | ||
```bash | ||
poetry install | ||
poetry shell | ||
``` | ||
|
||
Make sure you have `make` installed, then: | ||
|
||
```bash | ||
make run # to start docker-compose | ||
``` | ||
|
||
```bash | ||
cd src | ||
python main.py # to run the code | ||
``` | ||
|
||
### Windows 11 machine | ||
|
||
1. Since Prompt Sail relies on subdomains, first you should update your system `host` | ||
``` | ||
notepad C:\Windows\System32\Drivers\etc\hosts | ||
``` | ||
file with the following lines: | ||
|
||
|
||
```bash | ||
127.0.1.1 project1.promptsail.local | ||
127.0.1.1 project2.promptsail.local | ||
127.0.1.1 promptsail.local | ||
``` | ||
### Create a project 📝 | ||
|
||
Navigate to http://localhost:80 and add you AI provider of choice. | ||
|
||
2. Build and run the docker image: | ||
|
||
```bash | ||
docker-compose up --build | ||
``` | ||
### Modify your code to use Prompt Sail proxy 👨💻 | ||
|
||
To use Prompt Sail with `openai` Python library, you need to set `OPENAI_API_BASE` environment variable, or | ||
modify `openai.api_base` parameter to point to your Prompt Sail project. | ||
|
||
```python | ||
from openai import OpenAI | ||
import os | ||
from dotenv import load_dotenv | ||
from pprint import pprint | ||
|
||
load_dotenv() | ||
|
||
### Create a project | ||
openai_key = os.getenv("OPENAI_API_KEY") | ||
openai_org_id = os.getenv("OPENAI_ORG_ID") | ||
|
||
Navigate to http://promptsail.local, feel free to browse projects. | ||
Creating a new project via UI is not yet implemented, stay tuned for new commits. | ||
api_base = "http://localhost:8000/project1/openai/" | ||
|
||
### Modify your code to use Prompt Sail proxy | ||
ps_client = OpenAI( | ||
base_url=api_base, | ||
api_key=openai_key, | ||
) | ||
|
||
To use Prompt Sail with `openai` Python library, you need to set `OPENAI_API_BASE` environment variable, or | ||
modify `openai.api_base` parameter to point to your Prompt Sail project. | ||
```python | ||
import openai | ||
openai.api_base = "http://[your-project-id].promptsail.local:8000" | ||
openai.ChatCompletion.create( | ||
response = ps_client.chat.completions.create( | ||
model="gpt-3.5-turbo", | ||
messages=[{"role": "user", "content": "Explaining the meaning of life in one sentence."}], | ||
messages=[ | ||
{ | ||
"role": "system", | ||
"content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair.", | ||
}, | ||
{ | ||
"role": "user", | ||
"content": "Compose a poem that explains the concept of recursion in programming.", | ||
}, | ||
], | ||
) | ||
|
||
pprint(response.choices[0].message) | ||
``` | ||
|
||
Using Prompt Sail with `langchain` is similar: | ||
```python | ||
from langchain.llms import OpenAI | ||
llm = OpenAI( | ||
model_name="text-davinci-003", | ||
openai_api_base="http://[your-project-id].promptsail.local:8000", | ||
from langchain.chat_models import ChatOpenAI | ||
from langchain.prompts.chat import ( | ||
ChatPromptTemplate, | ||
HumanMessagePromptTemplate, | ||
SystemMessagePromptTemplate, | ||
) | ||
llm("Explaining the meaning of life in one sentence.") | ||
from langchain.schema import HumanMessage, SystemMessage | ||
|
||
haiku_prompt = [ | ||
SystemMessage( | ||
content="You are a poetic assistant, skilled in explaining complex programming concepts with creative flair.", | ||
), | ||
HumanMessage( | ||
content="Compose a haiku that explains the concept of recursion in programming.", | ||
), | ||
] | ||
chat = ChatOpenAI( | ||
temperature=0.9, | ||
openai_api_key=openai_key, | ||
openai_organization=openai_org_id, | ||
model="gpt-3.5-turbo-1106", | ||
) | ||
|
||
chat(haiku_prompt) | ||
``` | ||
|
||
### Analyzing the prompts and responses | ||
## Contact 📞 | ||
|
||
After running your LLM code, navigate back to your project page and see the prompt and response recorded. | ||
- Bugs & requests: file a GitHub ticket 🐞 | ||
- For business inquiries: email [email protected]. 📧 | ||
- Our website: [https://promptsail.com](https://promptsail.com) 🌐 | ||
|
||
## Testing | ||
|
||
To run tests, simpy run `make test`. | ||
## License 📜 | ||
|
||
## Building the docker image | ||
Prompt Sail is free and open source, under the [MIT license](LICENSE). | ||
|
||
```bash | ||
make build | ||
``` |
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
Oops, something went wrong.