Skip to content

Commit

Permalink
Merge b6fe638 into 39ab066
Browse files Browse the repository at this point in the history
  • Loading branch information
dyohan9 authored Aug 30, 2019
2 parents 39ab066 + b6fe638 commit a6ed98f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
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

0 comments on commit a6ed98f

Please sign in to comment.