Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/project crud (sprint 1) #1

Merged
merged 41 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
82b0ca8
modyfiy dependency for langchain, add conditions to waith for mongo, …
ksopyla Oct 22, 2023
4d7b1ba
Move toy_files to examples, add jupyter notebook add env templates
ksopyla Nov 4, 2023
2211167
Project2 Internal Server Error fixed in template.
sliwaszymon Nov 6, 2023
5f7d530
Transaction view
sliwaszymon Nov 8, 2023
c26f79d
Redirection from project to transaction view.
sliwaszymon Nov 9, 2023
cf5c7a5
Start of CRUD projects
sliwaszymon Nov 9, 2023
dc9b77e
add test to api/project
pgorecki Nov 9, 2023
e534c57
[PS-5] merge front
Bklzn Nov 10, 2023
6c68a87
add default pass to mongoexpress
ksopyla Nov 11, 2023
4ce7408
small changes, clear output
ksopyla Nov 11, 2023
b000ac7
installed python-multipart-0.0.6 to make forms run.
sliwaszymon Nov 13, 2023
5a3d7f0
deleting projects
sliwaszymon Nov 13, 2023
21532d1
api's things separated to other file (dunno if we'll need that)
sliwaszymon Nov 15, 2023
4ead19b
python-multipart added to poetry
sliwaszymon Nov 15, 2023
a1ff3a8
update poetry.lock
pgorecki Nov 15, 2023
f7c4e2c
testy api
sliwaszymon Nov 16, 2023
f357c77
Merge branch 'feature/project-crud' into ps-llm-recepies
ksopyla Nov 19, 2023
0eeeffb
temp fix for timeout
ksopyla Nov 19, 2023
6d9e88c
add openai lib example
ksopyla Nov 19, 2023
70c8857
add langchain openai
ksopyla Nov 19, 2023
95a6d94
fix poetry version in docker
ksopyla Nov 19, 2023
1123060
add group for exmaples dependencies
ksopyla Nov 19, 2023
f262b3c
add langchain openai
ksopyla Nov 19, 2023
a523460
Merge branch 'feature/project-crud' into ps-llm-recepies
ksopyla Nov 19, 2023
282477c
add base url
ksopyla Nov 19, 2023
2447e91
Merge branch 'feature/project-crud' into ps-llm-recepies
ksopyla Nov 19, 2023
c575ac0
Merge remote-tracking branch 'origin/feature/project-crud' into featu…
sliwaszymon Nov 19, 2023
245d299
edited project crud
sliwaszymon Nov 20, 2023
cebc214
hotfix precreated projects
sliwaszymon Nov 20, 2023
27f70b1
'TransactionContext' object has no attribute 'app' fix
sliwaszymon Nov 21, 2023
5eba0f1
api get project hotfix
sliwaszymon Nov 21, 2023
fe5789b
trying to make transaction-tags
sliwaszymon Nov 22, 2023
1c2f7fa
tests, and api project fix
sliwaszymon Nov 27, 2023
217041b
new use cases for saving transaction , saving "as is"
sliwaszymon Nov 27, 2023
dca4019
unpacking request and response error fix,
sliwaszymon Nov 27, 2023
328edfa
webui endpoint hotfix
sliwaszymon Nov 27, 2023
9f8a90e
Merge branch 'feature/project-crud' into ps-llm-recepies
ksopyla Nov 28, 2023
0695919
pre-merge fixes
sliwaszymon Dec 4, 2023
b4724b0
pre-merge fixes after 06.12.23 call
sliwaszymon Dec 7, 2023
4dcbc7b
files not pushed in commit before
sliwaszymon Dec 8, 2023
83d9736
last commit after call 08.12.2023
sliwaszymon Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ WORKDIR /src

# Install curl and Poetry in a single step, and clean up the apt cache to keep the image small
RUN apt-get update && apt-get install -y --no-install-recommends curl \
&& curl -sSL https://install.python-poetry.org | python3 - \
&& curl -sSL https://install.python-poetry.org | python3 - --version 1.7.1 \
&& ln -s /root/.local/bin/poetry /usr/local/bin/poetry \
&& apt-get purge -y --auto-remove curl \
&& rm -rf /var/lib/apt/lists/*


# Copy the Python dependency files into the image
COPY pyproject.toml poetry.lock ./

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ file with the following lines:
2. Build and run the docker image:

```bash
docker-docker-compose up --build
docker-compose up --build
```


Expand Down
23 changes: 19 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,24 @@ services:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: password
healthcheck:
test: ["CMD", "curl", "http://localhost:21017"]
interval: 15s
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
interval: 10s
timeout: 10s
retries: 5
start_period: 40s
mongoexperss:
image: mongo-express:latest
ports:
- "8081:8081"
environment:
ME_CONFIG_MONGODB_URL: "mongodb://root:password@mongodb:27017"
ME_CONFIG_OPTIONS_EDITORTHEME: "ambiance"
ME_CONFIG_BASICAUTH_USERNAME: "admin"
ME_CONFIG_BASICAUTH_PASSWORD: "pass"
depends_on:
mongodb:
condition: service_healthy

app:
build:
context: .
Expand All @@ -26,8 +40,9 @@ services:
BASE_URL: "http://promptsail.local"
STATIC_DIRECTORY: "/static"
MONGO_URL: "mongodb://root:password@mongodb:27017"
depends_on:
- mongodb
depends_on:
mongodb:
condition: service_healthy

networks:
internal-network:
Expand Down
2 changes: 2 additions & 0 deletions examples/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OPENAI_API_KEY=sk-xxx
OPENAI_ORG_ID=org-xxx
132 changes: 132 additions & 0 deletions examples/langchain_openai.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Prompt sail proxy for OpenAI with LangChain"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenAI api loaded=sk-...e9Uzy\n"
]
}
],
"source": [
"\n",
"import os\n",
"from dotenv import load_dotenv\n",
"load_dotenv()\n",
"\n",
"\n",
"openai_key = os.getenv(\"OPENAI_API_KEY\")\n",
"openai_org_id = os.getenv(\"OPENAI_ORG_ID\")\n",
"print(\n",
" f\"OpenAI api loaded={os.getenv('OPENAI_API_KEY')[0:3]}...{os.getenv('OPENAI_API_KEY')[-5:]}\"\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"At the application start we created two test projects with OpenAI API mappings. \n",
"There are visible on main dashboard http://promptsail.local/\n",
"\n",
"\n",
"* [project1](http://promptsail.local/ui/project/project1) -> https://api.openai.com/v1\n",
"* [project2](http://promptsail.local/ui/project/project2) -> https://api.openai.com/v1\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.prompts.chat import (\n",
" ChatPromptTemplate,\n",
" HumanMessagePromptTemplate,\n",
" SystemMessagePromptTemplate,\n",
")\n",
"from langchain.schema import HumanMessage, SystemMessage"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"api_base = \"http://project1.promptsail.local\"\n",
"chat = ChatOpenAI(\n",
" temperature=0,\n",
" openai_api_key=openai_key,\n",
" openai_organization=openai_org_id,\n",
" model=\"gpt-3.5-turbo\",\n",
" base_url=api_base,\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content='Bug: Out of Memory Error when Allocating CUDA Memory (GPU X)')"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\n",
"messages = [\n",
" SystemMessage(\n",
" content=\"You are a helpful assistant that help rewirte an jira ticket.\"\n",
" ),\n",
" HumanMessage(\n",
" content=\"Give meaningful title to this bug, RuntimeError: CUDA out of memory. Tried to allocate X MiB (GPU X; X GiB total capacity; X GiB already allocated; X MiB free; X cached)\"\n",
" ),\n",
"]\n",
"chat(messages)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "prompt-sail-hDSOLtZB-py3.10",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
163 changes: 163 additions & 0 deletions examples/openai_sdk.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/toy_langchain.py → examples/toy_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

llm = OpenAI(
model_name="text-davinci-003",
openai_api_base="http://project2.promptsail.local:8000",
openai_api_base="http://project2.promptsail.local",
)
output = llm("Explaining the meaning of life in one sentence")
print(output)
File renamed without changes.
Loading