Skip to content

Commit

Permalink
added fetch references field (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker authored Oct 10, 2023
1 parent 567993d commit 7408a64
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
24 changes: 24 additions & 0 deletions ayushma/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from simple_history.admin import SimpleHistoryAdmin

from ayushma.models.services import Service, TempToken
from ayushma.models.testsuite import Feedback, TestQuestion, TestRun, TestSuite

from .models import APIKey, Chat, ChatMessage, Document, Project, User

Expand Down Expand Up @@ -102,3 +103,26 @@ class TempTokenAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
@admin.register(Service)
class ServiceAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


@admin.register(Feedback)
class FeedbackAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


@admin.register(TestSuite)
class TestSuiteAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


@admin.register(TestQuestion)
class TestQuestionAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


@admin.register(TestRun)
class TestRunAdmin(DjangoQLSearchMixin, admin.ModelAdmin):
pass


admin.site.site_header = "Ayushma Admin"
17 changes: 17 additions & 0 deletions ayushma/migrations/0045_testrun_references.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.1 on 2023-10-10 16:31

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("ayushma", "0044_alter_project_stt_engine"),
]

operations = [
migrations.AddField(
model_name="testrun",
name="references",
field=models.BooleanField(default=True),
),
]
1 change: 1 addition & 0 deletions ayushma/models/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TestRun(BaseModel):
test_suite = ForeignKey(TestSuite, on_delete=CASCADE)
project = ForeignKey(Project, on_delete=CASCADE)
status = IntegerField(choices=StatusChoices.choices, default=StatusChoices.RUNNING)
references = models.BooleanField(default=True)


class TestResult(BaseModel):
Expand Down
1 change: 1 addition & 0 deletions ayushma/serializers/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class Meta:
"modified_at",
"status",
"test_results",
"references",
)
read_only_fields = (
"external_id",
Expand Down
1 change: 1 addition & 0 deletions ayushma/tasks/testrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def mark_test_run_as_completed(self, test_run_id):
user_language=test_question.language + "-IN",
stream=False,
generate_audio=False,
fetch_references=test_run.references,
)
)

Expand Down
3 changes: 2 additions & 1 deletion ayushma/utils/openaiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ def converse(
references=None,
generate_audio=True,
noonce=None,
fetch_references=True,
):
if not openai_key:
raise Exception("OpenAI-Key header is required to create a chat or converse")
Expand All @@ -288,7 +289,7 @@ def converse(

if references:
reference = references
elif chat.project and chat.project.external_id:
elif fetch_references and chat.project and chat.project.external_id:
try:
reference = get_reference(
english_text, openai_key, str(chat.project.external_id), match_number
Expand Down

0 comments on commit 7408a64

Please sign in to comment.