Skip to content

Commit

Permalink
add machine id
Browse files Browse the repository at this point in the history
  • Loading branch information
catgirlinspace committed Nov 29, 2023
1 parent 2f1453d commit d44ad1f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
17 changes: 17 additions & 0 deletions assistant/migrations/0004_thread_runner_machine_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.7 on 2023-11-29 17:02

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('assistant', '0003_thread_status_alter_thread_openai_file_id'),
]

operations = [
migrations.AddField(
model_name='thread',
name='runner_machine_id',
field=models.CharField(blank=True, max_length=20),
),
]
1 change: 1 addition & 0 deletions assistant/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ class Status(models.TextChoices):
created_date = models.DateTimeField(auto_now_add=True)
initial_message = models.TextField(default='')
status = models.CharField(blank=True, choices=Status.choices, max_length=25)
runner_machine_id = models.CharField(blank=True, max_length=20)
3 changes: 3 additions & 0 deletions assistant/orchestrator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os

import requests
Expand Down Expand Up @@ -45,3 +46,5 @@ def schedule_machine(thread: Thread):
if response.status_code != 200:
print(response.text)
response.raise_for_status()
data = json.loads(response.text)
return data.id
2 changes: 1 addition & 1 deletion assistant/templates/assistant/view_thread.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1 class="text-2xl font-splatoon1">
<p>Thread ID: {{ thread.openai_thread_id }}</p>
<p>File ID:
{% if thread.status == thread.Status.PENDING %}
Waiting for thread data...
Waiting for thread data... (Runner ID: {{ thread.runner_machine_id }})
{% else %}
{{ thread.openai_file_id }}
{% endif %}</p>
Expand Down
5 changes: 4 additions & 1 deletion assistant/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def create_thread(request):
initial_message=form.cleaned_data['initial_message'])
thread.save()

orchestrator.schedule_machine(thread)
machine_id = orchestrator.schedule_machine(thread)

thread.runner_machine_id = machine_id
thread.save()

return redirect("assistant:view_thread", thread.id)

Expand Down

0 comments on commit d44ad1f

Please sign in to comment.