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

Added column nlp_server for set url nlp custom #282

Merged
merged 2 commits into from
Aug 30, 2019
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
9 changes: 9 additions & 0 deletions bothub/api/v2/repository/serializers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.utils.translation import gettext as _
from django.conf import settings
from rest_framework import serializers
from rest_framework.exceptions import PermissionDenied

Expand Down Expand Up @@ -188,6 +189,7 @@ class Meta:
'use_language_model_featurizer',
'use_competing_intents',
'use_name_entities',
'nlp_server',
]
read_only = [
'uuid',
Expand All @@ -199,6 +201,7 @@ class Meta:
'ready_for_train',
'created_at',
'authorization',
'nlp_server',
]
ref_name = None

Expand Down Expand Up @@ -232,6 +235,12 @@ class Meta:
request_authorization = serializers.SerializerMethodField()
available_request_authorization = serializers.SerializerMethodField()
entities = serializers.SerializerMethodField()
nlp_server = serializers.SerializerMethodField()

def get_nlp_server(self, obj):
if obj.nlp_server:
return obj.nlp_server
return settings.BOTHUB_NLP_BASE_URL

def create(self, validated_data):
validated_data.update({
Expand Down
18 changes: 18 additions & 0 deletions bothub/common/migrations/0034_repository_nlp_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.5 on 2019-08-30 17:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('common', '0033_auto_20190816_2030'),
]

operations = [
migrations.AddField(
model_name='repository',
name='nlp_server',
field=models.URLField(blank=True, null=True, verbose_name='Base URL NLP'),
),
]
18 changes: 15 additions & 3 deletions bothub/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,23 @@ class Meta:
null=False
)

nlp_server = models.URLField(
_('Base URL NLP'),
null=True,
blank=True
)

objects = RepositoryManager()

nlp_train_url = '{}train/'.format(settings.BOTHUB_NLP_BASE_URL)
nlp_analyze_url = '{}parse/'.format(settings.BOTHUB_NLP_BASE_URL)
nlp_evaluate_url = '{}evaluate/'.format(settings.BOTHUB_NLP_BASE_URL)
nlp_train_url = '{}train/'.format(
nlp_server if nlp_server else settings.BOTHUB_NLP_BASE_URL
)
nlp_analyze_url = '{}parse/'.format(
nlp_server if nlp_server else settings.BOTHUB_NLP_BASE_URL
)
nlp_evaluate_url = '{}evaluate/'.format(
nlp_server if nlp_server else settings.BOTHUB_NLP_BASE_URL
)

@classmethod
def request_nlp_train(cls, user_authorization):
Expand Down