diff --git a/README.md b/README.md index b75b727..98b2580 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you are interested in learning how to use LangChain to build an API powered b just curious about how the NLUX demo APIs works, you can check the folders in this repository: * `./app` ― The FastAPI endpoint and web server. -* `./packages` ― Several Python packages matching different endpoints. +* `./packages` ― Several Python packages matching different endpoints. This includes the newly added `mia` endpoint, which connects to Claude.ai with a smart detective persona named Mia, designed to help users solve complex issues with intelligence and dark humor. ## Building + Running This Project diff --git a/app/server.py b/app/server.py index f4c6904..cb823c7 100644 --- a/app/server.py +++ b/app/server.py @@ -4,6 +4,7 @@ from fastapi.middleware.cors import CORSMiddleware from pirate_speak.chain import chain as pirate_speak_chain from einbot.chain import chain as einbot_chain +from mia.chain import chain as mia_chain from langchain.schema.runnable import Runnable from langserve import add_routes @@ -52,6 +53,7 @@ def add_route(path: str, chain: Runnable): add_route("/pirate-speak", pirate_speak_chain) add_route("/einbot", einbot_chain) +add_route("/mia", mia_chain) if __name__ == "__main__": import uvicorn diff --git a/packages/einbot/pyproject.toml b/packages/einbot/pyproject.toml index e211dd8..c996a03 100644 --- a/packages/einbot/pyproject.toml +++ b/packages/einbot/pyproject.toml @@ -18,7 +18,7 @@ sse-starlette = "^1.6.5" [tool.langserve] export_module = "einbot.chain" -export_attr = "chain" +export_attr = ["chain", "mia_chain"] [tool.templates-hub] use-case = "chatbot" diff --git a/packages/mia/LICENSE b/packages/mia/LICENSE new file mode 100644 index 0000000..9fc144f --- /dev/null +++ b/packages/mia/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 NLUX AI + +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. diff --git a/packages/mia/README.md b/packages/mia/README.md new file mode 100644 index 0000000..6862b23 --- /dev/null +++ b/packages/mia/README.md @@ -0,0 +1,3 @@ +# Mia - The Smart Detective + +Mia is a smart detective API that connects to Claude.ai. She helps users solve complex issues with her intelligence and dark humor. This endpoint is designed to provide clever insights and occasional witty remarks, making the problem-solving process engaging and enjoyable. diff --git a/packages/mia/mia/__init__.py b/packages/mia/mia/__init__.py new file mode 100644 index 0000000..3f3d610 --- /dev/null +++ b/packages/mia/mia/__init__.py @@ -0,0 +1 @@ +# This file initializes the mia package diff --git a/packages/mia/mia/chain.py b/packages/mia/mia/chain.py new file mode 100644 index 0000000..8c2ccba --- /dev/null +++ b/packages/mia/mia/chain.py @@ -0,0 +1,21 @@ +from langchain_community.chat_models import ChatOpenAI +from langchain_core.prompts import ChatPromptTemplate + +_prompt = ChatPromptTemplate.from_messages( + [ + ( + "system", + "You are Mia, a smart detective with a knack for solving complex issues. Your intelligence is matched " + "only by your dark humor. You help users navigate through their problems with clever insights and " + "occasional witty remarks. Remember, you're not just any detective; you're one with a unique perspective " + "that often sees what others miss. Use your skills to provide guidance, solve mysteries, and maybe, " + "just maybe, crack a joke or two along the way." + ), + ("human", "{message}"), + ] +) +_model = ChatOpenAI() + +# if you update this, you MUST also update ../pyproject.toml +# with the new `tool.langserve.export_attr` +chain = _prompt | _model diff --git a/packages/mia/pyproject.toml b/packages/mia/pyproject.toml new file mode 100644 index 0000000..10bc082 --- /dev/null +++ b/packages/mia/pyproject.toml @@ -0,0 +1,23 @@ +[tool.poetry] +name = "mia" +version = "0.1.0" +description = "Mia is a smart detective with a knack for solving complex issues using dark humor." +authors = ["NLUX AI "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.8" +openai = "^0.10.2" +langchain-community = "^0.0.7" +langchain-core = "^0.1.4" + +[tool.poetry.group.dev.dependencies] +pytest = "^6.2.5" + +[tool.langserve] +export_module = "mia.chain" +export_attr = "chain" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/packages/mia/tests/__init__.py b/packages/mia/tests/__init__.py new file mode 100644 index 0000000..2a6fd89 --- /dev/null +++ b/packages/mia/tests/__init__.py @@ -0,0 +1 @@ +# Initialize the test suite for the `mia` package