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

naming #38

Merged
merged 1 commit into from
Mar 28, 2024
Merged
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
24 changes: 23 additions & 1 deletion app/generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import re
import os
import uuid
import requests
from fastapi import BackgroundTasks

from .scenarios.tasks import general_assistant
from .models.tasks import SimpleAssistantRequest

from .models import (
MonologueRequest,
DialogueRequest,
Expand Down Expand Up @@ -51,6 +55,24 @@
]


def name_interaction(prompt: str):
naming_prompt = f"Take the following text prompt and output a short phrase or sentence with 5-15 words which captures the essence of the text. It will be used to give a name to the interaction. If the text given is already a short phrase, just output that. Output *only* the short phrase. Do not include pretext, restatement, or other extraneous text.\n\n---\n\nText:\n {prompt}"
print("----")
print(naming_prompt)
request = SimpleAssistantRequest(
prompt=naming_prompt,
model="gpt-3.5-turbo",
params={"temperature": 0.0, "max_tokens": 100},
)
try:
name = general_assistant(request)
except Exception as e:
name = re.sub(r"\W+", " ", prompt).replace("\n", "").replace("\r", "")[:100]
print(name)
print("----")
return name


def process_task(task_id: str, request: TaskRequest):
print("config", request.config)

Expand Down Expand Up @@ -255,7 +277,7 @@ def send_progress_update(progress: float):
output = TaskResult(
files=[output_url],
thumbnails=[thumbnail_url],
name=prompt,
name=name_interaction(prompt),
attributes={},
progress=1,
isFinal=True,
Expand Down
Loading