Skip to content

Commit

Permalink
handle failed generation tasks slightly better (#50)
Browse files Browse the repository at this point in the history
Co-authored-by: Douglas Reid <doug@steamship.com>
  • Loading branch information
douglas-reid and Douglas Reid committed Jun 5, 2023
1 parent d805ab4 commit 2b5c6d4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/steamship_langchain/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@
from langchain.llms.openai import BaseOpenAI
from langchain.llms.openai import OpenAIChat as BaseOpenAIChat
from pydantic import Extra, root_validator
from steamship import Block, File, MimeTypes, PluginInstance, Steamship, SteamshipError, Tag
from steamship import (
Block,
File,
MimeTypes,
PluginInstance,
Steamship,
SteamshipError,
Tag,
TaskState,
)
from steamship.data import TagKind, TagValueKey
from steamship.data.tags.tag_constants import RoleTag

Expand Down Expand Up @@ -182,6 +191,10 @@ def _batch(
# the llm_plugin handles retries and backoff. this wait()
# will allow for that to happen.
task.wait(max_timeout_s=self.batch_task_timeout_seconds)

if not task.state == TaskState.succeeded:
raise SteamshipError(f"generation task failed: {task.status_message}")

generation_file = task.output.file

for text_block in generation_file.blocks:
Expand Down

0 comments on commit 2b5c6d4

Please sign in to comment.