Skip to content

Commit

Permalink
Merge branch 'microsoft:main' into workflow-lite
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrabach authored Nov 22, 2024
2 parents f8607b8 + 0040353 commit f642eca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,14 @@ def __init__(

@asynccontextmanager
async def lifespan() -> AsyncIterator[None]:
# connect to workbench on startup
logger.info(
"connecting to semantic-workbench-service on startup; workbench_service_url: %s, assistant_service_id: %s, callback_url: %s",
"connecting to semantic-workbench-service; workbench_service_url: %s, assistant_service_id: %s, callback_url: %s",
settings.workbench_service_url,
self.service_id,
settings.callback_url,
)

async with self.workbench_client.for_service() as service_client:
try:
await self._ping_semantic_workbench(service_client)
logger.info(
"connected to semantic-workbench-service on startup; workbench_service_url: %s, assistant_service_id: %s, callback_url: %s",
settings.workbench_service_url,
self.service_id,
settings.callback_url,
)
except httpx.HTTPError:
logger.warning("failed to connect workbench on startup", exc_info=True)

# start periodic pings to workbench
ping_task = asyncio.create_task(
self._periodically_ping_semantic_workbench(service_client), name="ping-workbench"
Expand All @@ -116,16 +104,16 @@ async def _periodically_ping_semantic_workbench(
) -> NoReturn:
while True:
try:
jitter = random.uniform(0, settings.workbench_service_ping_interval_seconds / 2.0)
await asyncio.sleep(settings.workbench_service_ping_interval_seconds + jitter)

try:
await self._ping_semantic_workbench(client)
except httpx.HTTPError:
logger.error("ping to workbench failed", exc_info=True)
logger.exception("ping to workbench failed")

jitter = random.uniform(0, settings.workbench_service_ping_interval_seconds / 2.0)
await asyncio.sleep(settings.workbench_service_ping_interval_seconds + jitter)

except Exception:
logger.exception("unexpected error in ping loop", exc_info=True)
logger.exception("unexpected error in ping loop")

@backoff.on_exception(
backoff.expo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import logging

from .guided_conversation_skill import GuidedConversationSkill

logger = logging.getLogger(__name__)

__all__ = [
"GuidedConversationSkill",
]
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import Any

from form_filler_skill.guided_conversation.message import Conversation, ConversationMessageType
Expand All @@ -10,11 +11,12 @@
message_from_completion,
validate_completion,
)
from pydantic import BaseModel
from skill_library.types import LanguageModel

from .. import logger
from ..artifact import Artifact
from .generate_artifact_updates import UpdateAttempt

logger = logging.getLogger(__name__)

ARTIFACT_ERROR_CORRECTION_SYSTEM_TEMPLATE = """You are a helpful, thoughtful, and meticulous assistant.
Expand All @@ -36,6 +38,11 @@
"""


class UpdateAttempt(BaseModel):
field_value: str
error: str


async def generate_artifact_field_update_error_fix(
language_model: LanguageModel,
artifact: Artifact,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from ..artifact import Artifact
from ..message import Conversation
from .fix_artifact_error import generate_artifact_field_update_error_fix
from .fix_artifact_error import UpdateAttempt, generate_artifact_field_update_error_fix

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,11 +61,6 @@ class ArtifactUpdates(BaseModel):
updates: list[ArtifactUpdate]


class UpdateAttempt(BaseModel):
field_value: str
error: str


async def generate_artifact_updates(
language_model: LanguageModel,
definition: GCDefinition,
Expand Down

0 comments on commit f642eca

Please sign in to comment.