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

Add Mia endpoint connecting to Claude.ai #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions app/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/einbot/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 21 additions & 0 deletions packages/mia/LICENSE
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 3 additions & 0 deletions packages/mia/README.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions packages/mia/mia/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# This file initializes the mia package
21 changes: 21 additions & 0 deletions packages/mia/mia/chain.py
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions packages/mia/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
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"
1 change: 1 addition & 0 deletions packages/mia/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Initialize the test suite for the `mia` package