Skip to content

Commit

Permalink
fix(chat): fix Simple Rag example (Issue #2750) (#2857)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaBondar authored Dec 27, 2024
1 parent 30f8545 commit 45dba39
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions apps/chat/src/constants/code-apps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { DefaultsService } from '../utils/app/data/defaults-service';

import {
CODEAPPS_REQUIRED_FILES,
FEATURES_ENDPOINTS,
Expand Down Expand Up @@ -64,6 +62,7 @@ if __name__ == "__main__":
},
};

// From https://github.com/epam/ai-dial-sdk/tree/development/examples/langchain_rag
const SIMPLE_RAG_EXAMPLE: Example = {
files: {
[CODEAPPS_REQUIRED_FILES.APP]: `"""
Expand All @@ -84,6 +83,7 @@ from langchain_community.document_loaders import PyPDFLoader, WebBaseLoader
from langchain_community.vectorstores import Chroma
from langchain_openai import AzureChatOpenAI, AzureOpenAIEmbeddings
from langchain_text_splitters import RecursiveCharacterTextSplitter
from pydantic import SecretStr
from utils import get_last_attachment_url, sanitize_namespace
from aidial_sdk import DIALApp
Expand Down Expand Up @@ -165,8 +165,8 @@ class SimpleRAGApplication(ChatCompletion):
azure_deployment=EMBEDDINGS_MODEL,
azure_endpoint=DIAL_URL,
# Header propagation automatically propagates the API key from the request headers.
openai_api_key="-",
openai_api_version=API_VERSION,
api_key=SecretStr("-"),
api_version=API_VERSION,
# The check leads to tokenization of the input strings.
# Tokenized input is only supported by OpenAI embedding models.
# For other models, the check should be disabled.
Expand All @@ -188,8 +188,8 @@ class SimpleRAGApplication(ChatCompletion):
azure_deployment=CHAT_MODEL,
azure_endpoint=DIAL_URL,
# Header propagation automatically propagates the API key from the request headers.
openai_api_key="-",
openai_api_version=API_VERSION,
api_key=SecretStr("-"),
api_version=API_VERSION,
temperature=0,
streaming=True,
callbacks=[CustomCallbackHandler(choice)],
Expand All @@ -216,12 +216,13 @@ if __name__ == "__main__":
uvicorn.run(app, port=5000)
`,
[CODEAPPS_REQUIRED_FILES.REQUIREMENTS]: `aidial-sdk>=0.10
langchain==0.2.10
langchain-community==0.2.9
langchain-openai==0.1.17
langchain-text-splitters==0.2.2
langchain==0.3.7
langchain-community==0.3.0
langchain-openai==0.2.6
langchain-text-splitters==0.3.0
tiktoken==0.7.0
openai==1.35.15
openai==1.54.0
httpx==0.27.2
beautifulsoup4==4.12.3
chromadb==0.5.4
uvicorn==0.30.1
Expand Down Expand Up @@ -281,7 +282,7 @@ def get_last_attachment_url(messages: List[Message]) -> str:
'/openai/deployments/simple-rag/chat/completions',
},
variables: {
DIAL_URL: () => DefaultsService.get('dialApiHost', ''),
DIAL_URL: () => '<Please enter DIAL API Url here>',
},
};

Expand Down

0 comments on commit 45dba39

Please sign in to comment.