Merge pull request #264 from arc53/bug/sendingsources

fix for sending sources + azure embeddings issue
This commit is contained in:
Alex
2023-06-15 11:39:31 +01:00
committed by GitHub
6 changed files with 20 additions and 24 deletions

View File

@@ -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=

View File

@@ -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)

View File

@@ -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()

View File

@@ -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
@@ -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

View File

@@ -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
@@ -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:
@@ -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

View File

@@ -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',
@@ -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);