sapapj-langchain-proxy


Namesapapj-langchain-proxy JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryConnect langchain to SAP's AI proxy.
upload_time2023-09-11 14:46:36
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) [2023] [Gunter Albrecht] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords langchain sap proxy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SAP Langchain Proxy to work with AI models at SAP 
# OpenAI SAP BTP Proxy

The OpenAI SAP BTP Proxy is a Python library that provides a proxy to connect to OpenAI services through SAP Business Technology Platform (BTP) with OAuth2 authentication. It abstracts interactions with various OpenAI models for tasks such as generating completions, working with embeddings, and using chat-based language models.

## Features

- **Completions**: Interact with OpenAI models for text completions.
- **Embeddings**: Work with text embeddings using OpenAI models.
- **Chat Completions**: Utilize chat-based language models for conversational applications.

## Usage

To use the library, you need to provide the necessary configuration for OAuth2 authentication and OpenAI endpoints. Below is an example of how to set up and use the library:

```python
# Configure OAuth2 and OpenAI endpoints
oauth_config = {
    "openai_api_client_id": "YOUR_CLIENT_ID",
    "openai_api_client_secret": "YOUR_CLIENT_SECRET",
    "openai_api_tokenurl": "OPENAI_TOKEN_URL",
    "openai_api_url": "OPENAI_API_URL"
}
```
It's recommended, though to provide the parameters as environment variables

```
OPENAI_CLIENTID
OPENAI_CLIENTSECRET
OPENAI_APIURL
OPENAI_TOKENURL
```

## Example code
Use below examples for LLM or Chat models in langchain
```python
from saplangchainproxy.chat import SAPChatOpenAI
from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferMemory
chat = SAPChatOpenAI(model='gpt-4', temperature=0.0)
conversation = ConversationChain(
    llm=chat,
    memory=ConversationBufferMemory()
)
test_string = "Hello I'm an AI."
test_reply = conversation.run(f"Just answer with '{test_string}'. Nothing else.")
print(f"AI response is: {test_reply}")

from saplangchainproxy.llm import SAPAzureOpenAI
llm = SAPAzureOpenAI(temperature=0.0)
test_string = "Hello I'm an AI."
test_reply = llm(f"Just answer with '{test_string}'. Nothing else.")
print(f"AI response is: {test_reply}")
```
## License
This library is licensed under the MIT License. See the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sapapj-langchain-proxy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "langchain,sap,proxy",
    "author": "",
    "author_email": "Skye0402 <albrechg@yahoo.com>",
    "download_url": "https://files.pythonhosted.org/packages/a1/c7/345f777b8cbaa6c17ab6e482c20de2ac252f8c8a564f7bebeb7d0d072030/sapapj-langchain-proxy-0.0.2.tar.gz",
    "platform": null,
    "description": "# SAP Langchain Proxy to work with AI models at SAP \r\n# OpenAI SAP BTP Proxy\r\n\r\nThe OpenAI SAP BTP Proxy is a Python library that provides a proxy to connect to OpenAI services through SAP Business Technology Platform (BTP) with OAuth2 authentication. It abstracts interactions with various OpenAI models for tasks such as generating completions, working with embeddings, and using chat-based language models.\r\n\r\n## Features\r\n\r\n- **Completions**: Interact with OpenAI models for text completions.\r\n- **Embeddings**: Work with text embeddings using OpenAI models.\r\n- **Chat Completions**: Utilize chat-based language models for conversational applications.\r\n\r\n## Usage\r\n\r\nTo use the library, you need to provide the necessary configuration for OAuth2 authentication and OpenAI endpoints. Below is an example of how to set up and use the library:\r\n\r\n```python\r\n# Configure OAuth2 and OpenAI endpoints\r\noauth_config = {\r\n    \"openai_api_client_id\": \"YOUR_CLIENT_ID\",\r\n    \"openai_api_client_secret\": \"YOUR_CLIENT_SECRET\",\r\n    \"openai_api_tokenurl\": \"OPENAI_TOKEN_URL\",\r\n    \"openai_api_url\": \"OPENAI_API_URL\"\r\n}\r\n```\r\nIt's recommended, though to provide the parameters as environment variables\r\n\r\n```\r\nOPENAI_CLIENTID\r\nOPENAI_CLIENTSECRET\r\nOPENAI_APIURL\r\nOPENAI_TOKENURL\r\n```\r\n\r\n## Example code\r\nUse below examples for LLM or Chat models in langchain\r\n```python\r\nfrom saplangchainproxy.chat import SAPChatOpenAI\r\nfrom langchain.chains import ConversationChain\r\nfrom langchain.memory import ConversationBufferMemory\r\nchat = SAPChatOpenAI(model='gpt-4', temperature=0.0)\r\nconversation = ConversationChain(\r\n    llm=chat,\r\n    memory=ConversationBufferMemory()\r\n)\r\ntest_string = \"Hello I'm an AI.\"\r\ntest_reply = conversation.run(f\"Just answer with '{test_string}'. Nothing else.\")\r\nprint(f\"AI response is: {test_reply}\")\r\n\r\nfrom saplangchainproxy.llm import SAPAzureOpenAI\r\nllm = SAPAzureOpenAI(temperature=0.0)\r\ntest_string = \"Hello I'm an AI.\"\r\ntest_reply = llm(f\"Just answer with '{test_string}'. Nothing else.\")\r\nprint(f\"AI response is: {test_reply}\")\r\n```\r\n## License\r\nThis library is licensed under the MIT License. See the LICENSE file for details.\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) [2023] [Gunter Albrecht]  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Connect langchain to SAP's AI proxy.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/skye0402/saplangchain-proxy"
    },
    "split_keywords": [
        "langchain",
        "sap",
        "proxy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ab41ab4b72bfa20ee246592a46586e4e5df7a8540463768e24af76989edc5030",
                "md5": "fed5eaceff4219c0400e3600ee1cf7d1",
                "sha256": "31354901362227d9256224519895023d3552a6dd6959175f4647e0bc98a8ee77"
            },
            "downloads": -1,
            "filename": "sapapj_langchain_proxy-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fed5eaceff4219c0400e3600ee1cf7d1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 24301,
            "upload_time": "2023-09-11T14:46:34",
            "upload_time_iso_8601": "2023-09-11T14:46:34.401291Z",
            "url": "https://files.pythonhosted.org/packages/ab/41/ab4b72bfa20ee246592a46586e4e5df7a8540463768e24af76989edc5030/sapapj_langchain_proxy-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1c7345f777b8cbaa6c17ab6e482c20de2ac252f8c8a564f7bebeb7d0d072030",
                "md5": "ba21026f2c27878483e04d98e1eb6a00",
                "sha256": "647bef7c6075ddf509d9de15531775227b943d83441f8b86f9c7dd297610bb3f"
            },
            "downloads": -1,
            "filename": "sapapj-langchain-proxy-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ba21026f2c27878483e04d98e1eb6a00",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 19271,
            "upload_time": "2023-09-11T14:46:36",
            "upload_time_iso_8601": "2023-09-11T14:46:36.014917Z",
            "url": "https://files.pythonhosted.org/packages/a1/c7/345f777b8cbaa6c17ab6e482c20de2ac252f8c8a564f7bebeb7d0d072030/sapapj-langchain-proxy-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-11 14:46:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "skye0402",
    "github_project": "saplangchain-proxy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "sapapj-langchain-proxy"
}
        
Elapsed time: 0.17366s