-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/project crud (sprint 1) (#1)
* modyfiy dependency for langchain, add conditions to waith for mongo, add mongo-expers web client * Move toy_files to examples, add jupyter notebook add env templates * Project2 Internal Server Error fixed in template. The error was caused by a missing message field in the request and response in the object stored in the database. It is possible that this depends on the AI model used. * Transaction view * Redirection from project to transaction view. More specific data in other in transaction view * Start of CRUD projects * [PS-5] merge front * add default pass to mongoexpress * small changes, clear output * installed python-multipart-0.0.6 to make forms run. added simple form for project adding * deleting projects * api's things separated to other file (dunno if we'll need that) crud for projects via ui done * python-multipart added to poetry * update poetry.lock * testy api * temp fix for timeout * add openai lib example * add langchain openai * fix poetry version in docker * add group for exmaples dependencies * add langchain openai * add base url * edited project crud * hotfix precreated projects * 'TransactionContext' object has no attribute 'app' fix * api get project hotfix * trying to make transaction-tags * tests, and api project fix * new use cases for saving transaction , saving "as is" * unpacking request and response error fix, updated endpoints and what they returns, model_name changed to ai_model_name in ProjectAIProviderSchema, updated api tests * webui endpoint hotfix * pre-merge fixes * pre-merge fixes after 06.12.23 call * files not pushed in commit before * last commit after call 08.12.2023 --------- Co-authored-by: ksopyla <[email protected]> Co-authored-by: Przemysław Górecki <[email protected]> Co-authored-by: unknown <[email protected]>
- Loading branch information
1 parent
01182b1
commit d940ad2
Showing
61 changed files
with
5,607 additions
and
418 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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
OPENAI_API_KEY=sk-xxx | ||
OPENAI_ORG_ID=org-xxx |
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 |
---|---|---|
@@ -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 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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
File renamed without changes.
Oops, something went wrong.