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

fix for sending sources + azure embeddings issue #264

Merged
merged 1 commit into from
Jun 15, 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
2 changes: 1 addition & 1 deletion .env-template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
OPENAI_API_KEY=<LLM api key (for example, open ai key)>
EMBEDDINGS_KEY=<LLM embeddings api key (for example, open ai key)>

# Azure
#For Azure
OPENAI_API_BASE=
OPENAI_API_VERSION=
AZURE_DEPLOYMENT_NAME=
Expand Down
3 changes: 0 additions & 3 deletions application/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ def api_answer():
messages_combine.append(HumanMessagePromptTemplate.from_template(i["prompt"]))
messages_combine.append(AIMessagePromptTemplate.from_template(i["response"]))
messages_combine.append(HumanMessagePromptTemplate.from_template("{question}"))
import sys

print(messages_combine, file=sys.stderr)
p_chat_combine = ChatPromptTemplate.from_messages(messages_combine)
elif settings.LLM_NAME == "openai":
llm = OpenAI(openai_api_key=api_key, temperature=0)
Expand Down
6 changes: 3 additions & 3 deletions application/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class Settings(BaseSettings):

API_KEY: str = None # LLM api key
EMBEDDINGS_KEY: str = None # api key for embeddings (if using openai, just copy API_KEY
OPENAI_API_BASE: str = "" # azure openai api base url
OPENAI_API_VERSION: str = "" # azure openai api version
AZURE_DEPLOYMENT_NAME: str = "" # azure deployment name
OPENAI_API_BASE: str = None # azure openai api base url
OPENAI_API_VERSION: str = None # azure openai api version
AZURE_DEPLOYMENT_NAME: str = None # azure deployment name


path = Path(__file__).parent.parent.absolute()
Expand Down
4 changes: 2 additions & 2 deletions application/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Jinja2==3.1.2
jmespath==1.0.1
joblib==1.2.0
kombu==5.2.4
langchain==0.0.179
langchain==0.0.200
loguru==0.6.0
lxml==4.9.2
MarkupSafe==2.1.2
Expand All @@ -55,7 +55,7 @@ networkx==3.0
nltk==3.8.1
numcodecs==0.11.0
numpy==1.24.2
openai==0.27.0
openai==0.27.8
packaging==23.0
pathos==0.3.0
Pillow==9.4.0
Expand Down
21 changes: 6 additions & 15 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
version: "3.9"

services:
frontend:
build: ./frontend
environment:
- VITE_API_HOST=http://localhost:5001
- VITE_API_STREAMING=$VITE_API_STREAMING
ports:
- "5173:5173"
depends_on:
- backend

backend:
build: ./application
Expand All @@ -19,9 +10,9 @@ services:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/1
- MONGO_URI=mongodb://mongo:27017/docsgpt
- OPENAI_API_BASE=$OPENAI_API_BASE
- OPENAI_API_VERSION=$OPENAI_API_VERSION
- AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME
#- OPENAI_API_BASE=$OPENAI_API_BASE
#- OPENAI_API_VERSION=$OPENAI_API_VERSION
#- AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME
ports:
- "5001:5001"
volumes:
Expand All @@ -42,9 +33,9 @@ services:
- CELERY_RESULT_BACKEND=redis://redis:6379/1
- MONGO_URI=mongodb://mongo:27017/docsgpt
- API_URL=http://backend:5001
- OPENAI_API_BASE=$OPENAI_API_BASE
- OPENAI_API_VERSION=$OPENAI_API_VERSION
- AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME
#- OPENAI_API_BASE=$OPENAI_API_BASE
#- OPENAI_API_VERSION=$OPENAI_API_VERSION
#- AZURE_DEPLOYMENT_NAME=$AZURE_DEPLOYMENT_NAME
depends_on:
- redis
- mongo
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/conversation/conversationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export function fetchAnswerApi(
selectedDocs.model +
'/';
}
//in history array remove all keys except prompt and response
history = history.map((item) => {
return { prompt: item.prompt, response: item.response };
});

return fetch(apiHost + '/api/answer', {
method: 'POST',
Expand Down Expand Up @@ -82,6 +86,10 @@ export function fetchAnswerSteaming(
'/';
}

history = history.map((item) => {
return { prompt: item.prompt, response: item.response };
});

return new Promise<Answer>((resolve, reject) => {
const url = new URL(apiHost + '/stream');
url.searchParams.append('question', question);
Expand Down