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

Migrate from LangChainJS to LangChain Python #90

Merged
merged 4 commits into from
May 1, 2023
Merged
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Features:
- [x] Bring your own Auth provider
- [x] Chatbots
- [x] Prompt templates
- [ ] API endpoints to chatbot
- [-] API endpoints to chatbot
- [ ] External datasources
- [ ] chatGPT plugins
- [ ] Chatbots themes
Expand All @@ -60,6 +60,14 @@ LangChain UI utilizes NextJS 13 `appDir`. Read more about it [here](https://next

## Getting started

### Langchain UI API

We have migrated all agent functionality from LangChain Typescript to LangChain Python. Thus you will need to run the (Langchain UI API)[https://github.com/homanp/langchain-ui] in order to interact with the chatbot. In the future when the TS package is on par with the Python package we will migrate to only using Javascript.

### Getting started

1. Setup the (Langchain UI API)[https://github.com/homanp/langchain-ui]

1. Clone the repo into a public GitHub repository (or fork https://github.com/homanp/langchain-ui/fork). If you plan to distribute the code, keep the source code public.

```sh
Expand Down
69 changes: 0 additions & 69 deletions app/api/v1/chatbots/[chatbotId]/route.js

This file was deleted.

4 changes: 3 additions & 1 deletion components/chat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { createChatbotMessage } from "@/lib/api";
import ChatInput from "./input";
import ChatOuput from "./output";

const API_URL = process.env.NEXT_PUBLIC_LANGCHAIN_UI_API_URL;

export default function Chat({ id, ...properties }) {
const [messages, setMessages] = useState([]);
const [newMessage, setNewMessage] = useState();
Expand All @@ -27,7 +29,7 @@ export default function Chat({ id, ...properties }) {
agent: "user",
});

await fetchEventSource(`/api/v1/chatbots/${id}`, {
await fetchEventSource(`${API_URL}chatbots/${id}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
3 changes: 2 additions & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ METAL_INDEX_ID=""
METAL_CLIENT_ID=""
NEXT_PUBLIC_AMAZON_S3_BUCKET_NAME=""
NEXT_PUBLIC_AMAZON_S3_SECRET_ACCESS_KEY=""
NEXT_PUBLIC_AMAZON_S3_ACCESS_KEY_ID=""
NEXT_PUBLIC_AMAZON_S3_ACCESS_KEY_ID=""
NEXT_PUBLIC_LANGCHAIN_UI_API_URL=""
8 changes: 4 additions & 4 deletions lib/api-docs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const cURL = `\`\`\`bash
# cURL request to chatbot API endpoint.
curl -X POST https://langchain-ui.vercel.app/api/v1/chatbot/{{id}}
curl -X POST https://dolphin-app-tmpol.ondigitalocean.app/api/v1/chatbot/{{id}}
-H "Content-Type: application/json"
-H "Authorization: Bearer {token}"
-d '{"message": "Hello!"}'
Expand All @@ -18,7 +18,7 @@ const requestOptions = {
};

const response = await fetch(
'https://langchain-ui.vercel.app/api/v1/chatbot/{{id}}',
'https://dolphin-app-tmpol.ondigitalocean.app/api/v1/chatbot/{{id}}',
requestOptions
);
const data = await response.json();
Expand All @@ -28,7 +28,7 @@ const python = `\`\`\`python
# Python request to chatbot API endpoint using the requests library.
import requests

url = 'https://langchain-ui.vercel.app/api/v1/chatbot/{{id}}'
url = 'https://dolphin-app-tmpol.ondigitalocean.app/api/v1/chatbot/{{id}}'
headers = {'Authorization': 'Bearer {token}'}
payload = {'messsage': 'Hello!'}

Expand All @@ -40,7 +40,7 @@ print(response.text)
const php = `\`\`\`php
# PHP request to chatbot API endpoint.
<?php
$url = "https://langchain-ui.vercel.app/api/v1/chatbot/{{id}}";
$url = "https://dolphin-app-tmpol.ondigitalocean.app/api/v1/chatbot/{{id}}";
$data = array(
"messate" => "Hello!"
);
Expand Down
78 changes: 0 additions & 78 deletions lib/chain.js

This file was deleted.

17 changes: 0 additions & 17 deletions lib/prompt-template.js

This file was deleted.