Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Sep 7, 2024
2 parents a7de8e0 + eb38817 commit a0e3285
Show file tree
Hide file tree
Showing 51 changed files with 444 additions and 617 deletions.
37 changes: 19 additions & 18 deletions .funcignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
# Local dev
__pycache__/
.devcontainer/
.gitmodules/
.python_packages/
.python-version
.ruff_cache/
.syft.yaml
.venv/
.version.cache
.version.config
.vscode/
*.egg-info/
*.pyc
*.sqlite*
bicep/
cicd/
build/
configs/
DevTunnels/
Makefile
requirements-dev.txt

# Local app config file
# CICD
.github/
bicep/
cicd/

# Config
*.env
*.settings.json
config.*
Expand All @@ -20,21 +35,7 @@ sbom-reports/
test-reports/
tests/

# Documentation and examples
# Documentation
*.md
docs/
examples/

# Local cache
__pycache__/
.python_packages/
.venv/
.version.cache
.version.config
*.egg-info/
*.pyc
build/
DevTunnels/

# GitHub
.github/
5 changes: 1 addition & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
"recommendations": [
"bierner.markdown-mermaid",
"bradlc.vscode-tailwindcss",
"charliermarsh.ruff",
"DavidAnson.vscode-markdownlint",
"EditorConfig.EditorConfig",
"github.vscode-github-actions",
"mechatroner.rainbow-csv",
"mikestead.dotenv",
"ms-azuretools.vscode-azurefunctions",
"ms-azuretools.vscode-bicep",
"ms-python.black-formatter",
"ms-python.debugpy",
"ms-python.isort",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-toolsai.jupyter",
Expand Down
12 changes: 6 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "standard",
"python.languageServer": "Pylance",
"python.analysis.typeCheckingMode": "basic",
"ruff.nativeServer": "on",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
"[markdown]": {
"editor.defaultFormatter": "DavidAnson.vscode-markdownlint",
Expand Down
28 changes: 9 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@ search_location := francecentral
# Sanitize variables
name_sanitized := $(shell echo $(name) | tr '[:upper:]' '[:lower:]')
# App configuration
bot_phone_number ?= $(shell cat config.yaml | yq '.communication_services.phone_number')
event_subscription_name ?= $(shell echo '$(name_sanitized)-$(bot_phone_number)' | tr -dc '[:alnum:]-')
twilio_phone_number ?= $(shell cat config.yaml | yq '.sms.twilio.phone_number')
# Bicep inputs
prompt_content_filter ?= true
# Bicep outputs
app_url ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["appUrl"].value')
blob_storage_public_name ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["blobStoragePublicName"].value')
communication_id ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["communicationId"].value')
function_app_name ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["functionAppName"].value')
log_analytics_workspace_customer_id ?= $(shell az deployment sub show --name $(name_sanitized) | yq '.properties.outputs["logAnalyticsWorkspaceName"].value')

version:
@bash ./cicd/version/version.sh -g . -c
Expand Down Expand Up @@ -80,17 +78,8 @@ upgrade:
az bicep upgrade

test:
@echo "➡️ Test generic formatter (Black)..."
python3 -m black --check .

@echo "➡️ Test import formatter (isort)..."
python3 -m isort --jobs -1 --check .

@echo "➡️ Test dependencies issues (deptry)..."
python3 -m deptry .

@echo "➡️ Test code smells (Pylint)..."
python3 -m pylint .
@echo "➡️ Test code smells (Ruff)..."
python3 -m ruff check --select I,PL,RUF,UP,ASYNC,A,DTZ,T20,ARG,PERF --ignore RUF012

@echo "➡️ Test types (Pyright)..."
python3 -m pyright .
Expand All @@ -101,11 +90,11 @@ test:
tests/*.py

lint:
@echo "➡️ Fix with generic formatter (Black)..."
python3 -m black .
@echo "➡️ Fix with formatter..."
python3 -m ruff format

@echo "➡️ Fix with import formatter (isort)..."
python3 -m isort --jobs -1 .
@echo "➡️ Lint with linter..."
python3 -m ruff check --select I,PL,RUF,UP,ASYNC,A,DTZ,T20,ARG,PERF --ignore RUF012 --fix

tunnel:
@echo "➡️ Creating tunnel..."
Expand Down Expand Up @@ -148,6 +137,7 @@ deploy-bicep:
'functionappLocation=$(functionapp_location)' \
'instance=$(name)' \
'openaiLocation=$(openai_location)' \
'promptContentFilter=$(prompt_content_filter)' \
'searchLocation=$(search_location)' \
'version=$(version_full)' \
--template-file bicep/main.bicep \
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ curl \
- [x] Customizable prompts
- [x] Disengaging from a human agent when needed
- [x] Filter out inappropriate content from the LLM, like profanity or concurrence company names
- [x] Fine understanding of the customer request with GPT-4 Turbo
- [x] Fine understanding of the customer request with GPT-4o and GPT 4o-mini
- [x] Follow a specific data schema for the claim
- [x] Has access to a documentation database (few-shot training / RAG)
- [x] Help the user to find the information needed to complete the claim
Expand Down Expand Up @@ -380,16 +380,16 @@ llm:
azure_openai:
api_key: xxx
context: 16385
deployment: gpt-35-turbo-0125
deployment: gpt-4o-mini-2024-07-18
endpoint: https://xxx.openai.azure.com
model: gpt-35-turbo
model: gpt-4o-mini
streaming: true
slow:
mode: azure_openai
azure_openai:
api_key: xxx
context: 128000
deployment: gpt-4o-2024-05-13
deployment: gpt-4o-2024-08-06
endpoint: https://xxx.openai.azure.com
model: gpt-4o
streaming: true
Expand Down Expand Up @@ -620,17 +620,17 @@ llm:
mode: openai
openai:
api_key: xxx
context: 16385
context: 128000
endpoint: https://api.openai.com
model: gpt-35-turbo
model: gpt-4o-mini
streaming: true
slow:
mode: openai
openai:
api_key: xxx
context: 128000
endpoint: https://api.openai.com
model: gpt-4
model: gpt-4o
streaming: true
```

Expand Down
67 changes: 33 additions & 34 deletions bicep/app.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ param llmSlowQuota int
param llmSlowVersion string
param location string
param openaiLocation string
param promptContentFilter bool
param searchLocation string
param tags object
param version string
Expand Down Expand Up @@ -113,7 +114,6 @@ var config = {

output appUrl string = appUrl
output blobStoragePublicName string = storageAccount.name
output communicationId string = communicationServices.id
output functionAppName string = functionAppName
output logAnalyticsCustomerId string = logAnalytics.properties.customerId

Expand Down Expand Up @@ -422,19 +422,6 @@ resource cognitiveCommunication 'Microsoft.CognitiveServices/accounts@2024-04-01
}
}

resource cognitiveDocument 'Microsoft.CognitiveServices/accounts@2024-04-01-preview' = {
name: '${prefix}-${location}-document'
location: location
tags: tags
sku: {
name: 'S0' // Pay-as-you-go
}
kind: 'FormRecognizer'
properties: {
customSubDomainName: '${prefix}-${location}-document'
}
}

// Cognitive Services OpenAI Contributor
resource roleOpenaiContributor 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = {
name: 'a001fd3d-188f-4b5d-821b-7da978bf7442'
Expand Down Expand Up @@ -473,77 +460,89 @@ resource contentfilter 'Microsoft.CognitiveServices/accounts/raiPolicies@2024-04
contentFilters: [
// Indirect attacks
{
allowedContentLevel: 'Medium'
blocking: true
enabled: true
name: 'indirect_attack'
source: 'Prompt'
}
// Jailbreak
{
allowedContentLevel: 'Medium'
blocking: true
enabled: true
name: 'jailbreak'
source: 'Prompt'
}
// Prompt
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'hate'
source: 'Prompt'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'sexual'
source: 'Prompt'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'selfharm'
source: 'Prompt'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'violence'
source: 'Prompt'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'profanity'
source: 'Prompt'
}
// Completion
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'hate'
source: 'Completion'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'sexual'
source: 'Completion'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'selfharm'
source: 'Completion'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'violence'
source: 'Completion'
}
{
blocking: false
enabled: false
allowedContentLevel: 'Low'
blocking: !promptContentFilter
enabled: !promptContentFilter
name: 'profanity'
source: 'Completion'
}
Expand Down
Loading

0 comments on commit a0e3285

Please sign in to comment.