Skip to content

Commit

Permalink
Updating chat component to reference langchain endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
kengboonang committed Oct 19, 2024
1 parent b8b07e8 commit e99e299
Show file tree
Hide file tree
Showing 13 changed files with 11,475 additions and 9,057 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ frontend/.env
frontend/package-lock.json
backend/package-lock.json
venv
.venv
.env
android
.idea
Expand Down
Binary file modified backend/chroma_langchain_db/chroma.sqlite3
Binary file not shown.
Binary file modified backend/src/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified backend/src/chatbot/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified backend/src/chatbot/__pycache__/app.cpython-39.pyc
Binary file not shown.
Binary file modified backend/src/chatbot/__pycache__/chatgpt.cpython-39.pyc
Binary file not shown.
Binary file modified backend/src/chatbot/__pycache__/chroma_setup.cpython-39.pyc
Binary file not shown.
25 changes: 13 additions & 12 deletions backend/src/chatbot/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
chromadb
fastapi
# langchain
# langchain-chroma
langchain-core
langchain-community
# langchain-huggingface
langchain-openai
# langchain-text-splitters
# llama-index
# llama-index-embeddings-huggingface
# llama-index-embeddings-langchain
# llama-index-vector-stores-chroma
# llama-parse
langchain==0.3.3
langchain-chroma==0.1.4
langchain-core==0.3.10
langchain-community==0.3.2
langchain-huggingface
langchain-openai==0.2.2
langchain-text-splitters==0.3.0
llama-index==0.11.17
llama-index-embeddings-huggingface==0.3.1
llama-index-embeddings-langchain==0.2.1
llama-index-vector-stores-chroma==0.2.0
llama-parse==0.5.7
openai
pydantic
pytest
Expand Down
6 changes: 4 additions & 2 deletions frontend/iQMA-Skills-Builder/app/screens/Chatbot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,16 @@ const ChatbotScreen: React.FC<ChatbotScreenProps> = ({route, navigation}) => {
);
if (response) {
// Add the chatbot response to the chat
const botReply = {text: response.content, isUser: false};
// use response.content if using /generate
// use response.output if using /langchain
const botReply = {text: response.output, isUser: false};
const updatedMessages = [...newMessages, botReply];
setMessages(updatedMessages);
// Save the chat history

const queryPair = [
{role: 'user', content: message},
{role: 'assistant', content: response.content},
{role: 'assistant', content: response.output},
];

// chatInputFunctions.saveChatHistory(
Expand Down
32 changes: 30 additions & 2 deletions frontend/iQMA-Skills-Builder/components/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,43 @@ interface ChatInputProps {
handleSend: (message: string) => void;
}

// Getting response from chatbot -> to add examples and summarise
// Getting response from /generate-> to add examples and summarise
// export const getChatbotResponse = async (
// role: string,
// message: string,
// history?: Array<{role: string; content: string}>
// ) => {
// try {
// const response = await fetch(
// `${process.env.EXPO_PUBLIC_CHATBOT_URL}/generate`,
// {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// role: role,
// content: message,
// ...(history && {history}),
// }),
// }
// );
// const data = await response.json();
// return data;
// } catch (error) {
// console.error('Error while getting chatbot response:', error);
// }
// };

// Getting response from /langchain -> to add examples and summarise
export const getChatbotResponse = async (
role: string,
message: string,
history?: Array<{role: string; content: string}>
) => {
try {
const response = await fetch(
`${process.env.EXPO_PUBLIC_CHATBOT_URL}/generate`,
`${process.env.EXPO_PUBLIC_CHATBOT_URL}/langchain`,
{
method: 'POST',
headers: {
Expand Down
7 changes: 7 additions & 0 deletions frontend/iQMA-Skills-Builder/metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

/** @type {import('expo/metro-config').MetroConfig} */
const config = getDefaultConfig(__dirname);

module.exports = config;
20,450 changes: 11,414 additions & 9,036 deletions frontend/iQMA-Skills-Builder/package-lock.json

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions frontend/iQMA-Skills-Builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,31 @@
"dependencies": {
"@ant-design/icons": "^5.4.0",
"@expo/vector-icons": "^14.0.2",
"@gradio/client": "^1.4.0",
"@gradio/client": "^0.17.0",
"@react-native-async-storage/async-storage": "^1.24.0",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-firebase/app": "^21.0.0",
"@react-native-firebase/messaging": "^21.0.0",
"@react-native-firebase/app": "^17.4.2",
"@react-native-firebase/messaging": "^18.6.2",
"@react-native-picker/picker": "^2.7.7",
"@react-navigation/bottom-tabs": "^6.6.1",
"@react-navigation/drawer": "^6.7.2",
"@react-navigation/native": "^6.1.18",
"@react-navigation/stack": "^6.4.1",
"axios": "^1.7.2",
"expo": "~51.0.18",
"expo": "^51.0.38",
"expo-av": "^14.0.7",
"expo-constants": "~16.0.2",
"expo-dev-client": "~4.0.20",
"expo-font": "~12.0.7",
"expo-image": "~1.12.13",
"expo-linking": "~6.3.1",
"expo-router": "~3.5.17",
"expo-router": "^3.1.0",
"expo-secure-store": "~13.0.2",
"expo-splash-screen": "~0.27.5",
"expo-status-bar": "~1.12.1",
"expo-system-ui": "~3.0.7",
"expo-web-browser": "~13.0.3",
"npm": "^10.9.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.3",
Expand Down

0 comments on commit e99e299

Please sign in to comment.